Centos7安裝zabbix3.4.0以及配置和使用


一、安裝ZABBIX

1、環境和軟件版本

注:此次是采用的rpm包方式安裝,所以服務器必須要能連接互聯網通過yum方式解決依賴關系

①系統:

[root@zabbix ~]# cat /etc/redhat-release 
CentOS Linux release 7.3.1611 (Core) 

②軟件:

zabbix-3.4.0

2、zabbix安裝

 2.1 系統環境配置

關閉防火牆和SElinux

[root@zabbix ~]# systemctl stop firewalld.service
[root@zabbix ~]# systemctl disable firewalld.service
[root@zabbix ~]# vim /etc/selinux/config
SELINUX=enforcing改為SELINUX=disabled
[root@zabbix ~]# reboot

 2.2 配置zabbix的yum源

[root@zabbix ~]# wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
[root@zabbix ~]# rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm 
警告:zabbix-release-3.4-2.el7.noarch.rpm: 頭V4 RSA/SHA512 Signature, 密鑰 ID a14fe591: NOKEY
准備中...                          ################################# [100%]
正在升級/安裝...
   1:zabbix-release-3.4-2.el7         ################################# [100%]

 2.3 下載相關軟件

下載地址:http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/

各種包的作用:

服務端

zabbix-server-mysql-3.4.0-1.el7.x86_64.rpm       //zabbix連接mysql的程序包
zabbix-web-3.4.0-1.el7.noarch.rpm            //web界面程序包
zabbix-web-mysql-3.4.0-1.el7.noarch.rpm        //web程序連接mysql的程序包
zabbix-get-3.4.0-1.el7.x86_64.rpm               //獲取agent端信息的程序包

 

被監控端

zabbix-agent-3.4.0-1.el7.x86_64.rpm              //zabbix的agent程序
zabbix-sender-3.4.0-1.el7.x86_64.rpm            //agent端主動發送信息的程序

 

2.4 安裝和配置Mariadb

安裝
[root@zabbix ~]# yum install mariadb-server -y
[root@zabbix ~]# systemctl start mariadb
[root@zabbix ~]# ss -tnl | grep 3306
LISTEN     0      50           *:3306                     *:*     
#安全初始化數據庫
[root@zabbix ~]# mysql_secure_installation 
Enter current password for root (enter for none): 
Set root password? [Y/n] y
New password: 
Re-enter new password: 
Remove anonymous users? [Y/n] y
Disallow root login remotely? [Y/n] n
Remove test database and access to it? [Y/n] n
Reload privilege tables now? [Y/n] y
#編輯my.cnf加入以下兩項參數
innodb_file_per_table=1
skip_name_resolve=1
[root@zabbix ~]# systemctl restart mariadb
[root@zabbix ~]# systemctl enable mariadb

 

2.5 創建和授權zabbix需要的數據庫

MariaDB [(none)]> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> GRANT ALL ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix123';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

2.6 測試數據庫是否能登錄

[root@zabbix ~]# mysql -u zabbix -p
Enter password: 
MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| test               |
| zabbix             |
+--------------------+
3 rows in set (0.00 sec)

 

2.7 安裝zabbix服務端

因為服務端自身也要被監控(如若不然誰來監控錦衣衛?)所以也需要安裝agent端的程序,后面的被監控點就只需要安裝agnet即可,另外還提一點就是 web展示的服務不一定非要和zabbixserver端裝在一起,也可以分離。

[root@zabbix ~]# cd zabbix3.4.0/
[root@zabbix zabbix3.4.0]# ll
總用量 5384
-rw-r--r-- 1 root root  361136 8月  22 2017 zabbix-agent-3.4.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root  247312 8月  22 2017 zabbix-get-3.4.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root  258700 8月  22 2017 zabbix-sender-3.4.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2046168 8月  22 2017 zabbix-server-mysql-3.4.0-1.el7.x86_64.rpm
-rw-r--r-- 1 root root 2577060 8月  22 2017 zabbix-web-3.4.0-1.el7.noarch.rpm
-rw-r--r-- 1 root root    5972 8月  22 2017 zabbix-web-mysql-3.4.0-1.el7.noarch.rpm
[root@zabbix zabbix3.4.0]# yum localinstall *.rpm -y   //會自動解決依賴關系

 

2.8 導入sql文件

編譯安裝的ZABBIX的sql文件會在web程序的文件夾中,但是我們這里是rpm方式安裝,所以sql文件並非和tar包一樣並且不再是3個.sql文件,而是一個create.sql.gz的壓縮文件

[root@zabbix ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.0/
[root@zabbix zabbix-server-mysql-3.4.0]# ll
總用量 2028
-rw-r--r-- 1 root root      98 8月  21 2017 AUTHORS
-rw-r--r-- 1 root root  777403 8月  21 2017 ChangeLog
-rw-r--r-- 1 root root   17990 8月  21 2017 COPYING
-rw-r--r-- 1 root root 1263114 8月  21 2017 create.sql.gz
[root@zabbix zabbix-server-mysql-3.4.0]# gunzip -c create.sql.gz > create.sql
[root@zabbix zabbix-server-mysql-3.4.0]# mysql -uzabbix -pzabbix123 -Dzabbix < create.sql
導入完成后檢查數據庫,成功導入的話一共是140張表
| users_groups               |
| usrgrp                     |
| valuemaps                  |
| widget                     |
| widget_field               |
+----------------------------+
140 rows in set (0.00 sec)

MariaDB [zabbix]> 

 

2.9 配置zabbix-server端

[root@zabbix ~]# vim /etc/zabbix/zabbix_server.conf 
改如下幾項,有注釋的就去掉注釋
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix123

 

2.10 配置zabbix-agent端(是服務器端的agent)

[root@zabbix ~]# vim /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1,192.168.116.137             //被動讓server端采集數據的,服務器地址可以有多個,使用逗號隔開
ServerActive=127.0.0.1,192.168.116.137           //主動向zabbix-server發送數據,注意這是server端,所以127.0.0.1不能刪除否則會報錯
Hostname=Zabbix server                  //agent名稱,如果是采用主動發送數據這個名稱必須全局唯一

 

2.11 配置zabbix和httpd開機啟動

[root@zabbix ~]# systemctl enable zabbix-server.service 
[root@zabbix ~]# systemctl enable zabbix-agent.service 
[root@zabbix ~]# systemctl enable httpd.service

 

2.12 啟動zabbix和httpd

[root@zabbix ~]# systemctl start zabbix-server
[root@zabbix ~]# systemctl start zabbix-agent
[root@zabbix ~]# systemctl start httpd
[root@zabbix ~]# ss -tnl
State       Recv-Q Send-Q                                 Local Address:Port                                                Peer Address:Port              
LISTEN      0      50                                                 *:3306                                                           *:*LISTEN      0      128                                                *:10050                                                          *:*                  
LISTEN      0      128                                                *:10051                                                          *:*LISTEN      0      128                                               :::80                                                            :::*LISTEN      0      128                                               :::10050                                                         :::*                  
LISTEN      0      128                                               :::10051                                                         :::*                  

2.13 配置zabbix-web

[root@zabbix ~]# vim /etc/php.ini
;date.timezone =    改為  date.timezone = Asia/Shanghai

  

2.14 web配置

瀏覽器訪問 http://192.168.116.137/zabbix

下一步后會進行條件檢查,符合后才能下一步

 這個地方的參數和上面改zabbix-server配置文件的參數一樣

 用戶名 Admin (一定要大寫A)

 密碼 zabbix

改為中文顯示

至此zabbix的安裝已經完成,下一篇文件將介紹zabbix的使用

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM