Zabbix4.0 LTS企業級監控系統之二進制安裝

Zabbix4.0 LTS企業級監控系統安裝

在這裏插入圖片描述

1. 初始化centos 7
[root@localhost ~]# yum -y install wget  #安裝wget命令
[root@localhost ~]# yum -y install vim #安裝vim編輯器
[root@localhost ~]# yum -y install bash-completion  #安裝命令補齊功能,安裝完成關閉重啓xShell或者secureCRT即可

2. 防火牆和selinux設置

方式一:關閉防火牆和selinux(測試環境)

[root@Zabbix-Server ~]# systemctl stop firewalld.service 
[root@Zabbix-Server ~]# systemctl enable firewalld.service 
[root@Zabbix-Server ~]# getenforce
[root@Zabbix-Server ~]# vim /etc/selinux/config 
	SELINUX=disabled

方式二:添加防火牆策略和修改selinux的sebool值(生產環境)
firewall防火牆(開啓狀態下)
本服務器同爲server和agent端,所以以下命令都需執行

server端:

[root@Zabbix-Server ~]# firewall-cmd --zone=public --add-port=10050/tcp --permanent 
[root@Zabbix-Server ~]# firewall-cmd --zone=public --add-port=10051/tcp --permanent
[root@Zabbix-Server ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent

agentd端:

[root@docker-web-test~]# firewall-cmd --zone=public --add-port=10050/tcp --permanent
[root@docker-web-test~]# firewall-cmd --reload		#重啓
[root@docker-web-test~]# firewall-cmd --list-all		#查詢

配置selinux(開啓狀態下)

[root@Zabbix-Server ~]# getsebool httpd_can_network_connect
[root@Zabbix-Server ~]# setsebool -P httpd_can_network_connect on
3. 在CentOS7添加 Zabbix 軟件倉庫

安裝軟件倉庫配置包,這個包包含了 yum(軟件包管理器)的配置文件。

#centos 7 添加阿里雲鏡像
[root@localhost ~]#wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost ~]#yum install epel-release
#增加Zabbix鏡像源
[root@localhost ~]# rpm -ivh http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
4. 安裝 Zabbix Server/Frontend(前端Web展示)
[root@localhost ~]# yum -y install  zabbix-server-mysql zabbix-web-mysql
5. 安裝MariaDB

MariaDB數據庫管理系統是MySQL的一個分支,主要由開源社區在維護,採用GPL授權許可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能輕鬆成爲MySQL的代替品。開發這個分支的原因之一是:甲骨文公司收購了MySQL後,有將MySQL閉源的潛在風險,因此社區採用分支的方式來避開這個風險。

[root@localhost ~]# yum search mariadb-server
	mariadb-server.x86_64 : The MariaDB server and related files
[root@localhost ~]# yum -y install mariadb-server.x86_64 #安裝mariadb
[root@localhost ~]# systemctl  start mariadb.service  #啓動mariadb
[root@localhost ~]# systemctl  enable mariadb.service #開機自啓mariadb
[root@localhost ~]# ps -ef | grep mysql  /  ps aux | grep mysql
#查看mariadb進程
[root@localhost ~]# systemctl  status mariadb.service #查看服務

初始化mariadb

[root@localhost ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):  #當前沒有密碼直接回車
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y #是否設置root密碼
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y #是否移除匿名用戶
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] n #不允許root遠程登陸
 ... skipping.

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y #移除測試數據庫
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y  #是否重新加載權限表
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
至此初始化完成

創建用戶及導入數據

[root@localhost ~]# mysql -uroot -p
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin; #創建zabbix數據庫字符集爲utf8
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; #創建用戶zabbix並授權
MariaDB [(none)]> flush privileges; #刷新權限
MariaDB [(none)]> quit #退出 

[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix #導入Zabbix server 的初始數據庫 schema 和數據
Enter password: 
[root@localhost ~]# mysql -uroot -p
Enter password: 
 MariaDB [(none)]> use zabbix;
 MariaDB [zabbix]> show tables;
 144 rows in set (0.00 sec) #至此導入數據完成
6. 配置Zabbix Server

編輯 zabbix_server.conf

[root@localhost ~]#vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

啓動 Zabbix server 進程

[root@localhost ~]# systemctl start zabbix-server.service 
[root@localhost ~]# systemctl enable zabbix-server.service
more /var/log/zabbix/zabbix_server.log
[root@localhost ~]# cat /var/log/zabbix/zabbix_server.log
cannot start preprocessing service: Cannot bind socket to "/var/run/zabbix/zabbix_server_preprocessing.sock": [13] Permission denied. #報錯是因爲設置selinux沒有重啓,重啓解決
7. Zabbix 前端配置

Zabbix 前端的 Apache 配置文件位於 /etc/httpd/conf.d/zabbix.conf。

[root@localhost ~]# vim /etc/httpd/conf.d/zabbix.conf
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value always_populate_raw_post_data -1
php_value date.timezone Asia/Shanghai

[root@localhost ~]# systemctl start httpd.service #啓動Apache
[root@localhost ~]# systemctl enable httpd.service #開機自啓
8. 訪問前端

瀏覽器訪問:http://zabbix-server-ip/zabbix
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
在這裏插入圖片描述
安裝 Zabbix agent :

[root@localhost ~]# yum -y install zabbix-agent
[root@localhost ~]# systemctl start zabbix-agent.service 
[root@localhost ~]# systemctl enable zabbix-agent.service

重新刷新頁面;
在這裏插入圖片描述

9. 解決中文亂碼

在這裏插入圖片描述

[root@localhost ~]# yum search lrzsz 
[root@localhost ~]# yum -y install lrzsz.x86_64 #安裝上傳下載功能,lrzsz是一款在linux裏可代替ftp上傳和下載的程序

在window系統C:\Windows\Fonts找一個字體;

[root@localhost ~]# cd /usr/share/zabbix/assets/fonts/
[root@localhost fonts]# ls
graphfont.ttf
[root@localhost fonts]# rz #選擇剛纔的字體
[root@localhost fonts]# ll -h
總用量 14M
lrwxrwxrwx. 1 root root  33 5月  28 16:56 graphfont.ttf -> /etc/alternatives/zabbix-web-font
-rw-r--r--  1 root root 14M 6月  11 2016 YaheiConsolasHybrid.ttf
[root@localhost fonts]# \mv YaheiConsolasHybrid.ttf graphfont.ttf  #強制吧YaheiConsolasHybrid重命名爲graphfont覆蓋,刷新頁面查看

在這裏插入圖片描述
至此二進制安裝zabbix完成;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章