Centos7安裝Zabbix教程
Centos7安裝Zabbix教程
安裝初始環境Mysql(Mariadb)
Centos升級到7版本之後,系統預設的是Mariadb資料庫,MariaDB資料庫管理系統是MySQL的一個分支,主要由開源社群在維護,採用GPL授權許可。開發這個分支的原因之一是:甲骨文公司收購了MySQL後,有將MySQL閉源的潛在風險,因此社群採用分支的方式來避開這個風險。MariaDB的目的是完全相容MySQL,包括API和命令列,使之能輕鬆成為MySQL的代替品。
yum install mariadb-server mariadb
mariadb資料庫的相關命令
systemctl start mariadb#啟動MariaDB systemctl stop mariadb#停止MariaDB systemctl restart mariadb#重啟MariaDB systemctl enable mariadb#設定開機啟動
啟動mariadb服務後,就可以使用mysql(沒有密碼)
mysql -uroot -p
設定遠端連結
grant all privileges on *.* to root@'%'identified by 'password'; flush privileges;
安裝PHP和Apache伺服器(zabbix依賴)
yum install httpd yum install php-common php-gd php-mbstring php-xml php-bcmath php-mysql php-cli php-devel php-pear
安裝zabbix3.4(請先保證mysql、php、httpd安裝完成後再安裝)
rpm -i http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
此處安裝時候可能會遇到錯誤
warning: /var/tmp/rpm-tmp.z7O820: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY #####解決方案 #由於安裝了舊版本的GPG keys造成,將新版本匯入一下 rpm --import /etc/pki/rpm-gpg/RPM* #檢視已安裝的zabbix rpm源 rpm -qa | grep zabbix #刪除源 rpm -e zabbix-release-3.4-2.el7.noarch
安裝zabbix的服務端、監控端、介面
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent
在mysql中建立zabbix資料庫
#建立表 create database zabbix character set utf8 collate utf8_bin; #設定本地的zabbix使用者訪問許可權以及密碼 grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix'; #讓許可權生效 flush privileges;
將zabbix的資料表指令碼檔案在mysql中執行
zcat /usr/share/doc/zabbix-server-mysql-3.4.*/create.sql.gz |mysql -uzabbix -pzabbix zabbix
修改zabbix server配置資料庫資訊
vim /etc/zabbix/zabbix_server.conf #####結合實際修改如下欄位 DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix
修改zabbix前端配置中的時區資訊為中國上海
vim /etc/httpd/conf.d/zabbix.conf ####修改如下時區配置即可 php_value date.timezone Asia/Shanghai
啟動服務
systemctl start httpd systemctl start zabbix-server systemctl start zabbix-agent
啟動zabbix-server時候可能出錯
Job for zabbix-server.service failed. See 'systemctl status zabbix-server.service' and 'journalctl -xn' for details. journalctl -xn zabbix_server[46512]: segfault at 18 ip 00007f78842b4bd0 sp 00007fff1995a818 error 4 in libpthread-2.17.so[7f78842ab000+16000] ####Centos7 中 gnutls.x86_64 (gnutls.x86_64 3.3.8-14.el7_2 ) 版本過高,需要降級 3.1.18-8.el7(1.20) ####解決方案 #利用下面的地址下載rpm包 http://rpm.pbone.net/index.php3/stat/4/idpl/27382700/dir/scientific_linux_7/com/gnutls-3.1.18-8.el7.x86_64.rpm.html/ #上傳後進行降級 rpm -Uvh --forcegnutls-3.1.18-8.el7.x86_64.rpm #如果降級過程中,遇到其他庫依賴gnutls 3.3.8,解除安裝即可 yum -y remove gnutls-dane-3.3.8-12.el7.x86_64 #降級完成後重啟zabbix-server服務 systemctl restart zabbix-server
到這部署就基本結束了,後續的相關配置和玩法請參考https://www.zabbix.com/documentation/3.4/manual/installation/install#installing_frontend