1. 程式人生 > >centos7 yum安裝zabbix監控

centos7 yum安裝zabbix監控

一、安裝zabbix server

1、升級系統元件到最新版本

[[email protected] ~]# yum -y update

2、安裝過程中為了方便,關閉seliunx和防火牆

3、安裝mysql5.7,操作過程請另外參考檔案(省略)

1.png

4、安裝Apache

[[email protected] ~]# yum -y install httpd

[[email protected] ~]# systemctl start httpd.service #啟動

[[email protected] ~]# systemctl stop httpd.service #停止

[[email protected] ~]# systemctl restart httpd.service #重啟

[[email protected] ~]# systemctl enable httpd.service #開機啟動

[[email protected] ~]# systemctl disable httpd.service #開機不啟動

5.1、安裝php(參考php5.6安裝手冊)

[[email protected] log]# yum -y install php56w.x86_64 (省略了一部分操作)

5.2、安裝php擴充套件

[[email protected] log]# yum install php-mysqlnd php-gd libjpeg* php-snmp php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash php-common php-ctype php-xml php-xmlreader php-xmlwriter php-session php-mbstring php-gettext php-ldap php-mysqli --skip-broken

[[email protected]

log]# yum install wget telnet net-tools python-paramiko gcc gcc-c++ dejavu-sans-fonts python-setuptools python-devel sendmail mailx net-snmp net-snmp-devel net-snmp-utils freetype-devel libpng-devel perl unbound libtasn1-devel p11-kit-devel OpenIPMI unixODBC

2.png

6、資料庫授權

mysql>create database zabbix character set utf8; #建立資料庫

mysql> grant all privileges on zabbix.* to [email protected]'%' identified by '[email protected]';

mysql>flush privileges;

7.1、安裝 Zabbix源3.4

[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

7.2、安裝zabbix

[[email protected] ~]# yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-java-gateway zabbix-web

7.3、匯入 zabbix 所需資訊

[[email protected] ~]# cd /usr/share/doc/zabbix-server-mysql-3.4.8/

3.png

[[email protected] zabbix-server-mysql-3.4.8]# zcat create.sql.gz | mysql -uroot zabbix -p

7.4、配置 zabbix 引數

[[email protected] ~]# vim /etc/zabbix/zabbix_server.conf

DBPassword 配置為第 126 行中設定的自定義密碼

4.png

CacheSize=512M

(CacheSize在385行)

HistoryCacheSize=128M

(HistoryCacheSize在410行)

HistoryIndexCacheSize=128M

(HistoryIndexCacheSize在419行)

TrendCacheSize=128M

(TrendCacheSize在428行)

ValueCacheSize=256M

(ValueCacheSize在438行)

Timeout=30

(Timeout在448)

其它引數保持預設值即可

如果需要監控VMware虛擬機器,則還需要設定以下選項引數:

StartVMwareCollectors=2

(StartVMwareCollectors在272行

VMwareCacheSize=256M

(VMwareCacheSize 在298行)

VMwareTimeout=300

(VMwareTimeout在306行)

7.5、配置 Apache 中的 PHP 引數(8GB 記憶體為例)

[[email protected] ~]# vim /etc/httpd/conf.d/zabbix.conf

php_value max_execution_time 600

php_value memory_limit 256M

php_value post_max_size 32M

php_value upload_max_filesize 32M

php_value max_input_time 600

php_value always_populate_raw_post_data -1

date.timezone 去掉註釋符號#,並將值修改為 Asia/Shanghai

7.6、關閉服務,重啟系統

[[email protected] ~]# systemctl stop mysqld && reboot

7.7、 啟動zabbix

[[email protected] ~]# systemctl start mysqld       #啟動資料庫

[[email protected] ~]# systemctl start httpd           #啟動Apache

[[email protected] ~]# systemctl start zabbix-server  #啟動zabbix

7.7在瀏覽器中輸入 http://zbx監控伺服器的IP地址/zabbix,進行 zabbix 的頁面初始化配置

http://192.168.232.133/zabbix/

5.png

補充:

故障問題收集:https://blog.csdn.net/zhangrandl/article/details/38339169

1、修改zabbix連結的資料庫IP地址、賬號,密碼

[[email protected] zabbix]# vim /etc/zabbix/web/zabbix.conf.php

2、檢視zabbix日誌

[[email protected] zabbix]# cat /var/log/zabbix/zabbix_server.log

3;常見報錯

6.png

解決思路:記憶體和cup檢視均未監控,並發現10050埠未啟動,安裝zabbix_agent,配置相關引數即可

[[email protected] zabbix]# vim zabbix_agentd.conf

Server=192.168.232.133

ServerActive=192.168.232.133

Hostname=192.168.232.133

4.1、Zabbix discoverer processes more than 75% busy報錯

4.2.原因

1)配置的每個discovery任務在一定時間內佔用1個discovery程序,而zabbix_server.conf中預設配置只有1個discovery(被註釋,預設生效);

2)同時為了快速驗證自動發現效果,將discovery任務的"Delay"時間由預設的3600s設定成60s。

總結:兩個原因導致平均時間內discovery processes過高而報警。

4.3、解決方法

1) 修改zabbix_server.conf中discovery程序數量;

#StartDiscoverers可根據設定的discovery任務數量設定,範圍是0~250

[[email protected] zabbix]# sed -i 's|# StartDiscoverers=1|StartDiscoverers=2|g' /etc/zabbix/zabbix_server.conf

[[email protected] zabbix]# systemctl restart zabbix-server

2) 將discovery任務的"Delay"時間設定足夠長,降低平均時間內程序的佔用率。

7.png

5.1,日誌報錯:

no active checks on server [192.168.232.133:10051]: host [192.168.232.130] not found

原因:主機明設定問題

解決方法:

8.png



二、安裝zabbix agengt

1、安裝新版3.4

[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm

2、安裝zabbix agengt

[[email protected] ~]# yum clean all

[[email protected] ~]# yum -y install zabbix-agent

3、配置

[[email protected] zabbix]# vim /etc/zabbix/zabbix_agentd.conf

sed -i "s/Server=127.0.0.1/Server=192.168.232.133/" /etc/zabbix/zabbix_agentd.conf sed -i "s/ServerActive=127.0.0.1/ServerActive=192.168.232.133/" /etc/zabbix/zabbix_agentd.conf      (主動模式) sed -i "s/Hostname=Zabbix server/Hostname=192.168.232.130/" /etc/zabbix/zabbix_agentd.conf

4、開啟防火牆埠

[[email protected] zabbix]# firewall-cmd --zone=public --add-port=10050/tcp --permanent

[[email protected] zabbix]# firewall-cmd --reload

9.png

5、啟動服務

[[email protected] zabbix]# systemctl start zabbix-agent.service