Linux下Zabbix5.0 LTS監(jiān)控基礎原理及安裝部署(圖文教程)
Zabbix 是什么?
- zabbix 是一個基于 Web 界面的提供分布式系統(tǒng)監(jiān)視以及網(wǎng)絡監(jiān)視功能的企業(yè)級的開源解決方案。通過 C/S 模式采集數(shù)據(jù),通過 B/S 模式在 Web 端展示和配置,能監(jiān)視各種網(wǎng)絡參數(shù),保證服務器系統(tǒng)的安全運營;并提供靈活的通知機制以讓系統(tǒng)管理員快速定位/解決存在的各種問題。
- zabbix 由2部分構(gòu)成,zabbix server 與可選組件 zabbix agent;zabbix server 可以通過 SNMP,zabbix agent,ping,端口監(jiān)視等方法提供對遠程服務器/網(wǎng)絡狀態(tài)的監(jiān)視,數(shù)據(jù)收集等功能。zabbix agent 需要安裝在被監(jiān)視的目標服務器上,它主要完成對硬件信息或與操作系統(tǒng)有關(guān)的內(nèi)存,CPU 等信息的收集。
Zabbix監(jiān)控系統(tǒng)運行大概流程:
Zabbix由zabbix server與可選組件zabbix agent兩部分組成。
- Zabbix Server 可以通過 SNMP,Zabbix agent,Ping,端口監(jiān)視等方法提供對遠程服務器/網(wǎng)絡狀態(tài)的監(jiān)視,數(shù)據(jù)收集功能,可以在運行 Linux,Solaris,HP-UX,AIX,F(xiàn)reeBSD,OpenBSD,OS X,Windows多平臺。
- Zabbix Agent 安裝在需要被監(jiān)控的目標服務器上,主要完成對硬件信息與操作系統(tǒng)有關(guān)的內(nèi)存,CPU 等信息收集。
- Zabbix Server可以單獨監(jiān)視遠程服務器的服務狀態(tài),同時也可以與Zabbix Agent結(jié)合。可以輪詢Zabbix Agent主動接收監(jiān)視數(shù)據(jù)(trapping傳遞 方式),同時還可以被動接收Zabbix Agent發(fā)送的數(shù)據(jù)。
- 主動:agent請求server獲取主動的監(jiān)控項列表,并主動將監(jiān)控項內(nèi)需要檢測的數(shù)據(jù)提交給server/proxy。
- 被動:server向agent請求獲取監(jiān)控項的數(shù)據(jù),agent返回數(shù)據(jù)。
那實際監(jiān)控中是用主動的還是被動的呢?這里主要涉及兩個地方:
- (1) 新建監(jiān)控項目時,選擇的是zabbix代理還是zabbix端點代理程式(主動式),前者是被動模式,后者是主動模式。
- (2) agentd配置文件中StartAgents參數(shù)的設置,如果為0,表示禁止被動模式,否則開啟。一般建議不要設置為0,因為監(jiān)控項目很多時,可以部分使用主動,部分使用被動模式。
Zabbix監(jiān)控常用架構(gòu):
- (1) server-agentd模式:這個是最簡單的架構(gòu)了,常用于監(jiān)控主機比較少的情況下。
- (2) server-proxy-agentd模式:這個常用于比較多的機器,使用proxy進行分布式監(jiān)控,有效的減輕server端的壓力。

Zabbix官方站點:【文檔、源碼包、rpm包】下載提供了兩種版本:LTS版(Long Term Support)和標準版。
Zabbix YUM安裝部署過程如下:
| 屬性 | Zabbix Server | Zabbix Client |
| 節(jié)點 | ZabbixServer-01 | ZabbixClient-01 |
| 系統(tǒng) | CentOS Linux release 7.5.1804 (Minimal) | CentOS Linux release 7.5.1804 (Minimal) |
| 內(nèi)核 | 3.10.0-862.el7.x86_64 | 3.10.0-862.el7.x86_64 |
| SELinux | setenforce 0 | disabled | setenforce 0 | disabled |
| Firewlld | systemctl stop/disable firewalld | systemctl stop/disable firewalld |
| IP地址 | 172.16.70.37 |
172.16.70.171 |
第一部分:ZabbixServer-01 上操作。
# 準備環(huán)境
[root@ZabbixServer-01 ~] # cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@ZabbixServer-01 ~] # uname -r
3.10.0-862.el7.x86_64
[root@ZabbixServer-01 ~] # setenforce 0
[root@ZabbixServer-01 ~] # sed -i_bak$(date +%Y%m%d) '7s#enforcing#disabled#' /etc/selinux/config
[root@ZabbixServer-01 ~] # systemctl stop firewalld && systemctl disable firewalld
[root@ZabbixServer-01 ~] # yum install -y vim net-tools lsof wget curl lrzsz
# 安裝NTP
[root@ZabbixServer-01 ~] # yum install -y ntp
[root@ZabbixServer-01 ~] # systemctl start ntpd && systemctl enable ntpd
# 安裝zabbix noarch.rpm
[root@ZabbixServer-01 ~] # rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
# 修改/etc/yum.repos.d/zabbix.repo,將[zabbix-frontend]下的enabled改為1【注意項】
[root@ZabbixServer-01 ~] # sed -i_bak$(date +%Y%m%d) '11s#enabled=0#enabled=1#' /etc/yum.repos.d/zabbix.repo
[root@ZabbixServer-01 ~] # yum clean all
[root@ZabbixServer-01 ~] # yum repolist | grep zabbix
zabbix /x86_64 Zabbix Official Repository - x86_64 200
zabbix-frontend /x86_64 Zabbix Official Repository frontend - x86_64 183
zabbix-non-supported /x86_64 Zabbix Official Repository non-supported - x8 5
# 安裝zabbix server和agent
[root@ZabbixServer-01 ~] # yum install -y zabbix-server-mysql zabbix-agent zabbix-get
# 安裝Software Collections便于后續(xù)安裝高版本的php
[root@ZabbixServer-01 ~] # yum install -y centos-release-scl
# 安裝zabbix FE和相關(guān)環(huán)境
[root@ZabbixServer-01 ~] # yum install -y zabbix-web-mysql-scl zabbix-apache-conf-scl
# 安裝centos7默認的mariadb數(shù)據(jù)庫
[root@ZabbixServer-01 ~] # yum install -y mariadb mariadb-server
[root@ZabbixServer-01 ~] # systemctl start mariadb && systemctl enable mariadb
# 安全初始化mariadb并配置root密碼
[root@ZabbixServer-01 ~] # 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: # root密碼
Re-enter new password: # 再次輸入root密碼
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 ] Y # 是否禁止root遠程登錄
... Success!
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 # 是否刪除test庫和test庫的訪問權(quán)限
- 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 # 是否刷新授權(quán)表使其立即生效
... 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登錄,并授權(quán)
[root@ZabbixServer-01 ~] # mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
# 創(chuàng)建zabbix數(shù)據(jù)庫
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
# 創(chuàng)建zabbix用戶
MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix@01' ;
Query OK, 0 rows affected (0.00 sec)
# 授權(quán)zabbix權(quán)限
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)
# 刷新授權(quán),使其立即生效
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
# 查看用戶權(quán)限
MariaDB [(none)]> select user,host,password from mysql.user;
+--------+-----------+-------------------------------------------+
| user | host | password |
+--------+-----------+-------------------------------------------+
| root | localhost | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF |
| root | 127.0.0.1 | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF |
| root | ::1 | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF |
| zabbix | localhost | *A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF |
+--------+-----------+-------------------------------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> show grants for zabbix@ 'localhost' ;
+---------------------------------------------------------------------------------------------------------------+
| Grants for zabbix@localhost |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zabbix' @ 'localhost' IDENTIFIED BY PASSWORD '*A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF' |
| GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix' @ 'localhost' |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.01 sec)
# 測試zabbix用戶登錄
[root@ZabbixServer-01 ~] # mysql -u zabbix -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 13
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show grants for current_user();
+---------------------------------------------------------------------------------------------------------------+
| Grants for zabbix@localhost |
+---------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'zabbix' @ 'localhost' IDENTIFIED BY PASSWORD '*A35F952D7E492A65F4DB82E1ECBFB4BBBC415BFF' |
| GRANT ALL PRIVILEGES ON `zabbix`.* TO 'zabbix' @ 'localhost' |
+---------------------------------------------------------------------------------------------------------------+
2 rows in set (0.00 sec)
# 導入zabbix數(shù)據(jù)庫,zabbix數(shù)據(jù)庫用戶為zabbix,密碼為zabbix@01
[root@ZabbixServer-01 ~] # zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
# 編輯配置文件/etc/zabbix/zabbix_server.conf,設置數(shù)據(jù)庫密碼
[root@ZabbixServer-01 ~] # sed -i_bak$(date +%Y%m%d) '/# DBPassword=/a\DBPassword=zabbix@01' /etc/zabbix/zabbix_server.conf
# 編輯配置文件/etc/zabbix/zabbix_agentd.conf,設置ZabbixServerIP,Hostname
[root@ZabbixServer-01 ~] # sed -i_bak$(date +%Y%m%d) 's/^Server=127.0.0.1/Server=127.0.0.1,172.16.70.37/' /etc/zabbix/zabbix_agentd.conf
[root@ZabbixServer-01 ~] # sed -i 's/^ServerActive=127.0.0.1/ServerActive=127.0.0.1,172.16.70.37/' /etc/zabbix/zabbix_agentd.conf
[root@ZabbixServer-01 ~] # sed -i 's/^Hostname=Zabbix server/Hostname=ZabbixServer-01/' /etc/zabbix/zabbix_agentd.conf
[root@ZabbixServer-01 ~] # grep -E '^Server|^Hostname' /etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1,172.16.70.37
ServerActive=127.0.0.1,172.16.70.37
Hostname=ZabbixServer-01
# 編輯配置文件/etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf,修改時區(qū)
[root@ZabbixServer-01 ~] # sed -i_bak$(date +%Y%m%d) '$c php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
# 重啟服務并設置開啟自啟動
[root@ZabbixServer-01 ~] # systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@ZabbixServer-01 ~] # systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@ZabbixServer-01 ~] # netstat -nutpl | grep -E 'zabbix|mysql|php|http'
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2120 /zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 2127 /zabbix_server
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 2118 /php-fpm : maste
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 1991 /mysqld
tcp6 0 0 :::10050 :::* LISTEN 2120 /zabbix_agentd
tcp6 0 0 :::10051 :::* LISTEN 2127 /zabbix_server
tcp6 0 0 :::80 :::* LISTEN 2117 /httpd
[root@ZabbixServer-01 ~] # hostname -I
172.16.70.37
瀏覽器訪問 http: //172 .16.70.37 /zabbix
首次訪問時需要進行一些初始化的設置,我們按照提示操作即可,點擊“Next setp”。

檢查各個組件配置是否正常,全部顯示“OK”,點擊“Next setp”。


默認數(shù)據(jù)庫端口3306,若在安裝數(shù)據(jù)庫自定義了端口,則需要在這修改,點擊“Next setp”。

可選配置,當有多臺ZabbixServer時,可在這設置“Name”,會顯示在頁面標簽,以便區(qū)分,點擊“Next setp”。

檢查所填的信息,如有誤點擊“Back”返回修改,無誤,點擊“Next setp”。

點擊“Finish”完成配置。

登錄賬號默認為 Admin,默認密碼:zabbix

首頁,儀表盤。

設置中文模式。

此時,頁面已成為中文模式。

語言設置為中文時,頁面亂碼如圖,有小方塊,影響閱讀。

Windows10字體路徑,選擇想更換的字體,復制粘貼至桌面。

再次回到ZabbixServer-01機操作。
[root@ZabbixServer-01 ~] # cd /usr/share/zabbix/assets/fonts/
[root@ZabbixServer-01 fonts] # mv graphfont.ttf graphfont.ttf.bak
[root@ZabbixServer-01 fonts] # rz # 上傳粘貼在桌面文字
[root@ZabbixServer-01 fonts] # ls
graphfont.ttf.bak simsun.ttc
[root@ZabbixServer-01 fonts] # mv simsun.ttc simsun.ttf # 修改拓展名
[root@ZabbixServer-01 fonts] # ls
graphfont.ttf.bak simsun.tt
# 修改Zabbix的配置文件/usr/share/zabbix/include/defines.inc.php
[root@ZabbixServer-01 ~] # sed -i_bak$(date +%Y%m%d) 's/graphfont/simsun/g' /usr/share/zabbix/include/defines.inc.php
解析:將下面兩行g(shù)raphfont改為simsun
define( 'ZBX_GRAPH_FONT_NAME' , 'graphfont' ); // font file name
define( 'ZBX_FONT_NAME' , 'graphfont' );
[root@ZabbixServer-01 ~] # systemctl restart zabbix-server

第二部分:ZabbixClient-01 上操作。
# 準備環(huán)境
[root@ZabbixClient-01 ~] # cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
[root@ZabbixClient-01 ~] # uname -r
3.10.0-862.el7.x86_64
[root@ZabbixClient-01 ~] # setenforce 0
[root@ZabbixClient-01 ~] # sed -i '7s#enforcing#disabled#' /etc/selinux/config
[root@ZabbixClient-01 ~] # systemctl stop firewalld && systemctl disable firewalld
[root@ZabbixClient-01 ~] # yum install -y vim net-tools lsof wget curl
# 安裝NTP
[root@ZabbixClient-01 ~] # yum install -y ntp
[root@ZabbixClient-01 ~] # systemctl start ntpd && systemctl enable ntpd
# 安裝zabbix-agent/sender
[root@ZabbixClient-01 ~] # rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@ZabbixClient-01 ~] # yum install -y zabbix-agent zabbix-sender
# 修改配置文件/etc/zabbix/zabbix_agentd.conf
[root@ZabbixClient-01 ~] # sed -i.bak '117s/Server=127.0.0.1/Server=172.16.70.37/;158s/ServerActive=127.0.0.1/ServerActive=172.16.70.37/' /etc/zabbix/zabbix_agentd.conf
[root@ZabbixClient-01 ~] # sed -i '169s/Hostname=Zabbix server/Hostname=ZabbixClient-01/' /etc/zabbix/zabbix_agentd.conf
# 解析
Server=172.16.70.37 # Zabbix Server服務器IP(被動)
ServerActive=172.16.70.37 # Zabbix Server服務器IP(主動)
Hostname=ZabbixClient-01 # 本機能被server端識別的名稱
# 啟動服務
[root@ZabbixClient-01 ~] # systemctl start zabbix-agent
[root@ZabbixClient-01 ~] # netstat -nuptl | grep zabbix
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 4839 /zabbix_agentd
tcp6 0 0 :::10050 :::* LISTEN 4839 /zabbix_agentd
[root@ZabbixClient-01 ~] # ps -ef |grep zabbix
zabbix 4839 1 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd .conf
zabbix 4840 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd : collector [idle 1 sec]
zabbix 4841 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd : listener #1 [waiting for connection]
zabbix 4842 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd : listener #2 [waiting for connection]
zabbix 4843 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd : listener #3 [waiting for connection]
zabbix 4844 4839 0 11:33 ? 00:00:00 /usr/sbin/zabbix_agentd : active checks #1 [idle 1 sec]
Zabbix Web設置,套用系統(tǒng)自帶的模板。







zabbix 修改數(shù)據(jù)庫密碼對應的配置修改。
# vim /etc/zabbix/zabbix_server.conf
DBPassword=Zabbix@01
# vim /etc/zabbix/web/zabbix.conf.php
$DB[ 'PASSWORD' ] = 'Zabbix@01' ;
# systemctl restart zabbix-server
附:
- 1、/etc/zabbix/zabbix_server.conf詳解【官方解析】
NodeID=0 #分布式節(jié)點id號,0代表是獨立服務器,默認是被注釋掉的,不強制配置
ListenPort=10051 #zabbix server的端口,默認是10051,可以自行修改,范圍是1024-32767 ,一般默認即可
SourceIP= #連接的源ip地址,默認為空,默認即可
LogFile= /tmp/zabbix_server .log #日志文件的存放位置
LogFileSize=1 #說明:日志達到多少M里就輪轉(zhuǎn);若此參數(shù)值為0時,則不輪轉(zhuǎn),日志將不斷變大,建議設置成輪轉(zhuǎn)。
DebugLevel=3 #指定調(diào)試級別,默認即可
PidFile= /tmp/zabbix_server .pid #pid文件的存放位置
DBHost=localhost #數(shù)據(jù)庫主機名,當設置為localhost時,連接mysql通過sock
DBName=zabbix #指定存放zabbix數(shù)據(jù)數(shù)據(jù)庫的名字
DBUser=zabbix #指定連接數(shù)據(jù)庫的用戶名
DBPassword=123456 #用戶連接數(shù)據(jù)庫需要的密碼
DBSocket= /var/lib/mysql/mysql .sock #前文主機設置為localhost,用戶連接數(shù)據(jù)庫所用的sock位置,
DBPort=3306 #數(shù)據(jù)庫的端口號,當用sock連接時,無關(guān)緊要,當通過網(wǎng)絡連接時需設置
StartPollers=5 #說明;初始化時,啟動子進程數(shù)量,數(shù)量越多,則服務端吞吐能力越強,對系統(tǒng)資源消耗越大。
StartIPMIPollers=0 #說明:主要用于IPmi技術(shù)用于獲取硬件狀態(tài)場景。若無相關(guān)監(jiān)控項,建議設置為0
StartTrappers=5 #用于設置諸如SNMP STRAPPER場景提交來的數(shù)據(jù)的接收進程數(shù),若客戶機SNMP TRAPPER技術(shù)較多,建議加大此參數(shù)值
StartPingers=1 #用于設置啟用icmp協(xié)議PING主機方式啟動線程數(shù)量,若單臺代理所管理機器超過500臺,建議加大此數(shù)值
StartDiscoverers=1 #用于設置自動發(fā)現(xiàn)主機的線程數(shù)量,若單臺代理所管理機器超過500臺,可以考慮加大此數(shù)值(僅適用于直接AGENT場景)
StartHTTPPollers=1 #說明:用于設置WEB撥測監(jiān)控線程數(shù),可視具體情況增加或減少此數(shù)值。
JavaGateway=127.0.0.1 #JavaGateway的ip地址或主機名
JavaGatewayPort=10052 #JavaGateway的端口號
StartJavaPollers=5 #開啟連接javagatey的進程數(shù)
SNMPTrapperFile= /tmp/zabbix_traps .tmp
StartSNMPTrapper=0 #如果設置為1,snmp trapper進程就會開啟
ListenIP=0.0.0.0 #監(jiān)聽來自trapper的ip地址
ListenIP=127.0.0.1
HousekeepingFrequency=1 #說明:多少小時清理一次代理端數(shù)據(jù)庫的history, alert, and alarms,以保持代理端數(shù)據(jù)庫輕便,建議保持默認
MaxHousekeeperDelete=500 #每次輪詢housekeeper這個任務的時候,超過這個閥值的行都會被清理。
SenderFrequency=30 #說明:多少秒后重試發(fā)送失敗的報警信息
CacheSize=8M #說明:zabbix初始化時占用多少系統(tǒng)共享內(nèi)存用于存儲配置信息,HOST,ITEM,TRIGGER數(shù)據(jù),視監(jiān)控主機數(shù)量和監(jiān)控項調(diào)整,建議調(diào)整到32M或者更大
CacheUpdateFrequency=60 #說明:zabbix更新操作系統(tǒng)CACHE配置,若管理頁面操作不頻繁,可以考慮加大參數(shù)值
StartDBSyncers=4 #將采集數(shù)據(jù)從CACHE同步到數(shù)據(jù)庫線程數(shù)量,視數(shù)據(jù)庫服務器I/O繁忙情況,和數(shù)據(jù)庫寫能力調(diào)整。數(shù)值越大,寫能力越強。對數(shù)據(jù)庫服務器I/O壓力越大。
HistoryCacheSize=8M #說明:用于設置劃分多少系統(tǒng)共享內(nèi)存用于存儲采集的歷史數(shù)據(jù),此數(shù)值越大,數(shù)據(jù)庫讀壓力越小
TrendCacheSize=4M #說明:用于設置劃分多少系統(tǒng)共享內(nèi)存用于存儲計算出來的趨勢數(shù)據(jù),此參數(shù)值從一定程度上可影響數(shù)據(jù)庫讀壓力
HistoryTextCacheSize=16M #說明:指定劃出多少系統(tǒng)共享內(nèi)存用于存儲 character, text or log history數(shù)據(jù),若二級代理內(nèi)存足夠,建議可適當擴大此數(shù)值,可很大程度上解決系統(tǒng)I/O壓力,和數(shù)據(jù)庫讀壓力
ValueCacheSize=8M #說明:劃出系統(tǒng)多少共享內(nèi)存用于已請求的存儲監(jiān)控項信息,若監(jiān)控項較多,建議加大此數(shù)值
NodeNoEvents=0 #說明:若節(jié)點為子結(jié)點,是否允許本地事件(events表)發(fā)送到主節(jié)點,1為不發(fā)送,但不影響此節(jié)點以下的節(jié)點的傳播能力,視ZABBIX分布式系統(tǒng)架構(gòu)設計開啟或關(guān)閉。在不明架構(gòu)前提下,建議保持默認
NodeNoHistory=0 #說明:若節(jié)點為子結(jié)點,是否允許本地歷史數(shù)據(jù)發(fā)送到主節(jié)點,1為不發(fā)送,但不影響此節(jié)點以下的節(jié)點的傳播能力,視ZABBIX分布式系統(tǒng)架構(gòu)設計開啟或關(guān)閉,在不明架構(gòu)前提下,建議保持默認
Timeout=3 #說明:與AGNET\SNMP設備和其它外部設備通信超時設置,單位為秒;若采集數(shù)據(jù)不完整或網(wǎng)絡繁忙,或從管理頁面發(fā)現(xiàn)客戶端狀態(tài)變化頻繁,可以考慮加大此數(shù)值。注意若此數(shù)值加大,應該考慮參數(shù) StartPollers 是否有相應加大的必要。
TrapperTimeout=300 #說明:啟用 trapper功能,用于進程等待超時設置。根據(jù)需要調(diào)整
UnreachablePeriod=45 #說明:當AGNET端處于不可用狀態(tài)下,間隔多少秒后,嘗試重新連接。建議根據(jù)具體情況設置。注意,若此數(shù)值過小,右agent端業(yè)務系統(tǒng)繁忙時,有可能造成報警信息誤報
UnavailableDelay=60 #說明:當AGENT端處于可用狀態(tài)下,間隔多少秒后,進行狀態(tài)檢查。若出現(xiàn)可正常采集數(shù)據(jù),但管理頁面AGENT狀態(tài)不正常;若在網(wǎng)絡,端口等均通暢情況下,AGENT狀態(tài)仍不正常,可以考慮加大此數(shù)值
UnreachableDelay=15 #說明:當agent端處于不可達狀態(tài)下,延遲多少秒后,進行重新嘗試,建議保持默認,在AGENT接入調(diào)試階段,可考慮減少此數(shù)值
AlertScriptsPath= /usr/local/zabbix/shell #監(jiān)控報警腳本的存放路徑
FpingLocation= /usr/local/sbin/fping #說明:IPv4 FPING命令路徑,僅ROOT可用。注意使用此命令時,應該確認此命令是否存在
SSHKeyLocation= #說明:在服務端需要SSH到AGENT端且采用用KEY驗證方式時使用。
LogSlowQueries=0 #說明:用于服務端數(shù)據(jù)庫慢查詢功能,單位是毫秒;1毫秒=0.001秒,若有服務端數(shù)據(jù)庫監(jiān)控慢查詢的需求,可以視具體情況調(diào)整此數(shù)。
TmpDir= /tmp
Include= /usr/local/etc/zabbix_server .general.conf
Include= /usr/local/etc/zabbix_server .conf.d/ #子配置文件路徑
StartProxyPollers=1 #在zabbix proxy被動模式下用此參數(shù)
ProxyConfigFrequency=3600 #同上
ProxyDataFrequency=1
zabbix_server.conf
1 NodeID=0 #分布式節(jié)點id號,0代表是獨立服務器,默認是被注釋掉的,不強制配置
2
3 ListenPort=10051 #zabbix server的端口,默認是10051,可以自行修改,范圍是1024-32767 ,一般默認即可
4
5 SourceIP= #連接的源ip地址,默認為空,默認即可
6
7 LogFile=/tmp/zabbix_server.log #日志文件的存放位置
8
9 LogFileSize=1 #說明:日志達到多少M里就輪轉(zhuǎn);若此參數(shù)值為0時,則不輪轉(zhuǎn),日志將不斷變大,建議設置成輪轉(zhuǎn)。
10
11 DebugLevel=3 #指定調(diào)試級別,默認即可
12
13 PidFile=/tmp/zabbix_server.pid #pid文件的存放位置
14
15 DBHost=localhost #數(shù)據(jù)庫主機名,當設置為localhost時,連接mysql通過sock
16
17 DBName=zabbix #指定存放zabbix數(shù)據(jù)數(shù)據(jù)庫的名字
18
19 DBUser=zabbix #指定連接數(shù)據(jù)庫的用戶名
20
21 DBPassword=123456 #用戶連接數(shù)據(jù)庫需要的密碼
22
23 DBSocket=/var/lib/mysql/mysql.sock #前文主機設置為localhost,用戶連接數(shù)據(jù)庫所用的sock位置,
24
25 DBPort=3306 #數(shù)據(jù)庫的端口號,當用sock連接時,無關(guān)緊要,當通過網(wǎng)絡連接時需設置
26
27 StartPollers=5 #說明;初始化時,啟動子進程數(shù)量,數(shù)量越多,則服務端吞吐能力越強,對系統(tǒng)資源消耗越大。
28
29 StartIPMIPollers=0 #說明:主要用于IPmi技術(shù)用于獲取硬件狀態(tài)場景。若無相關(guān)監(jiān)控項,建議設置為0
30
31 StartTrappers=5 #用于設置諸如SNMP STRAPPER場景提交來的數(shù)據(jù)的接收進程數(shù),若客戶機SNMP TRAPPER技術(shù)較多,建議加大此參數(shù)值
32
33 StartPingers=1 #用于設置啟用icmp協(xié)議PING主機方式啟動線程數(shù)量,若單臺代理所管理機器超過500臺,建議加大此數(shù)值
34
35 StartDiscoverers=1 #用于設置自動發(fā)現(xiàn)主機的線程數(shù)量,若單臺代理所管理機器超過500臺,可以考慮加大此數(shù)值(僅適用于直接AGENT場景)
36
37 StartHTTPPollers=1#說明:用于設置WEB撥測監(jiān)控線程數(shù),可視具體情況增加或減少此數(shù)值。
38
39 JavaGateway=127.0.0.1 #JavaGateway的ip地址或主機名
40
41 JavaGatewayPort=10052 #JavaGateway的端口號
42
43 StartJavaPollers=5 #開啟連接javagatey的進程數(shù)
44
45 SNMPTrapperFile=/tmp/zabbix_traps.tmp
46
47 StartSNMPTrapper=0 #如果設置為1,snmp trapper進程就會開啟
48
49 ListenIP=0.0.0.0 #監(jiān)聽來自trapper的ip地址
50
51 ListenIP=127.0.0.1
52
53 HousekeepingFrequency=1 #說明:多少小時清理一次代理端數(shù)據(jù)庫的history, alert, and alarms,以保持代理端數(shù)據(jù)庫輕便,建議保持默認
54
55 MaxHousekeeperDelete=500 #每次輪詢housekeeper這個任務的時候,超過這個閥值的行都會被清理。
56
57 SenderFrequency=30 #說明:多少秒后重試發(fā)送失敗的報警信息
58
59 CacheSize=8M #說明:zabbix初始化時占用多少系統(tǒng)共享內(nèi)存用于存儲配置信息,HOST,ITEM,TRIGGER數(shù)據(jù),視監(jiān)控主機數(shù)量和監(jiān)控項調(diào)整,建議調(diào)整到32M或者更大
60
61 CacheUpdateFrequency=60 #說明:zabbix更新操作系統(tǒng)CACHE配置,若管理頁面操作不頻繁,可以考慮加大參數(shù)值
62
63 StartDBSyncers=4 #將采集數(shù)據(jù)從CACHE同步到數(shù)據(jù)庫線程數(shù)量,視數(shù)據(jù)庫服務器I/O繁忙情況,和數(shù)據(jù)庫寫能力調(diào)整。數(shù)值越大,寫能力越強。對數(shù)據(jù)庫服務器I/O壓力越大。
64
65 HistoryCacheSize=8M #說明:用于設置劃分多少系統(tǒng)共享內(nèi)存用于存儲采集的歷史數(shù)據(jù),此數(shù)值越大,數(shù)據(jù)庫讀壓力越小
66
67 TrendCacheSize=4M #說明:用于設置劃分多少系統(tǒng)共享內(nèi)存用于存儲計算出來的趨勢數(shù)據(jù),此參數(shù)值從一定程度上可影響數(shù)據(jù)庫讀壓力
68
69 HistoryTextCacheSize=16M #說明:指定劃出多少系統(tǒng)共享內(nèi)存用于存儲 character, text or log history數(shù)據(jù),若二級代理內(nèi)存足夠,建議可適當擴大此數(shù)值,可很大程度上解決系統(tǒng)I/O壓力,和數(shù)據(jù)庫讀壓力
70
71 ValueCacheSize=8M #說明:劃出系統(tǒng)多少共享內(nèi)存用于已請求的存儲監(jiān)控項信息,若監(jiān)控項較多,建議加大此數(shù)值
72
73 NodeNoEvents=0 #說明:若節(jié)點為子結(jié)點,是否允許本地事件(events表)發(fā)送到主節(jié)點,1為不發(fā)送,但不影響此節(jié)點以下的節(jié)點的傳播能力,視ZABBIX分布式系統(tǒng)架構(gòu)設計開啟或關(guān)閉。在不明架構(gòu)前提下,建議保持默認
74
75 NodeNoHistory=0 #說明:若節(jié)點為子結(jié)點,是否允許本地歷史數(shù)據(jù)發(fā)送到主節(jié)點,1為不發(fā)送,但不影響此節(jié)點以下的節(jié)點的傳播能力,視ZABBIX分布式系統(tǒng)架構(gòu)設計開啟或關(guān)閉,在不明架構(gòu)前提下,建議保持默認
76
77 Timeout=3 #說明:與AGNET\SNMP設備和其它外部設備通信超時設置,單位為秒;若采集數(shù)據(jù)不完整或網(wǎng)絡繁忙,或從管理頁面發(fā)現(xiàn)客戶端狀態(tài)變化頻繁,可以考慮加大此數(shù)值。注意若此數(shù)值加大,應該考慮參數(shù) StartPollers 是否有相應加大的必要。
78
79 TrapperTimeout=300 #說明:啟用 trapper功能,用于進程等待超時設置。根據(jù)需要調(diào)整
80
81 UnreachablePeriod=45 #說明:當AGNET端處于不可用狀態(tài)下,間隔多少秒后,嘗試重新連接。建議根據(jù)具體情況設置。注意,若此數(shù)值過小,右agent端業(yè)務系統(tǒng)繁忙時,有可能造成報警信息誤報
82
83 UnavailableDelay=60 #說明:當AGENT端處于可用狀態(tài)下,間隔多少秒后,進行狀態(tài)檢查。若出現(xiàn)可正常采集數(shù)據(jù),但管理頁面AGENT狀態(tài)不正常;若在網(wǎng)絡,端口等均通暢情況下,AGENT狀態(tài)仍不正常,可以考慮加大此數(shù)值
84
85 UnreachableDelay=15 #說明:當agent端處于不可達狀態(tài)下,延遲多少秒后,進行重新嘗試,建議保持默認,在AGENT接入調(diào)試階段,可考慮減少此數(shù)值
86
87 AlertScriptsPath=/usr/local/zabbix/shell #監(jiān)控報警腳本的存放路徑
88
89 FpingLocation=/usr/local/sbin/fping #說明:IPv4 FPING命令路徑,僅ROOT可用。注意使用此命令時,應該確認此命令是否存在
90
91 SSHKeyLocation= #說明:在服務端需要SSH到AGENT端且采用用KEY驗證方式時使用。
92
93 LogSlowQueries=0 #說明:用于服務端數(shù)據(jù)庫慢查詢功能,單位是毫秒;1毫秒=0.001秒,若有服務端數(shù)據(jù)庫監(jiān)控慢查詢的需求,可以視具體情況調(diào)整此數(shù)。
94
95 TmpDir=/tmp
96
97 Include=/usr/local/etc/zabbix_server.general.conf
98
99 Include=/usr/local/etc/zabbix_server.conf.d/ #子配置文件路徑
100
101 StartProxyPollers=1 #在zabbix proxy被動模式下用此參數(shù)
102
103 ProxyConfigFrequency=3600#同上
104
105 ProxyDataFrequency
- 2、 /etc/zabbix/zabbix_agentd.conf詳解【官方解析】
PidFile= /tmp/zabbix_agentd .pid #pid文件的存放位置
LogFile= /tmp/zabbix_agentd .log #日志文件的位置
LogFileSize=1 #當日志文件達到多大時進行輪詢操作
DebugLevel=3 #日志信息級別
SourceIP= #連接的源ip地址,默認為空,即可
EnableRemoteCommands=0 #是否允許zabbix server端的遠程指令,
0表示不允許,
1表示允許
LogRemoteCommands=0 #是否開啟日志記錄shell命令作為警告 0表示不允許,1表示允許
Server=127.0.0.1 #zabbix server的ip地址或主機名,可同時列出多個,需要用逗號隔開
ListenPort=10050 #zabbix agent監(jiān)聽的端口
ListenIP=0.0.0.0 #zabbix agent監(jiān)聽的ip地址
StartAgents=3 #zabbix agent開啟進程數(shù)
ServerActive=127.0.0.1 #開啟主動檢查
Hostname=Zabbix server #在zabbix server前端配置時指定的主機名要相同,最重要的配置
RefreshActiveChecks=120 #主動檢查刷新的時間,單位為秒數(shù)
BufferSend=5 #數(shù)據(jù)緩沖的時間
BufferSize=100 #zabbix agent數(shù)據(jù)緩沖區(qū)的大小,當達到該值便會發(fā)送所有的數(shù)據(jù)到zabbix server
MaxLinesPerSecond=100 #zabbix agent發(fā)送給zabbix server最大的數(shù)據(jù)行
AllowRoot=0 #是否允許zabbix agent 以root用戶運行
Timeout=3 #設定處理超時的時間
Include= /usr/local/etc/zabbix_agentd .userparams.conf
Include= /usr/local/etc/zabbix_agentd .conf.d/ #包含子配置文件的路徑
UnsafeUserParameters=0 #是否允許所有字符參數(shù)的傳遞
UserParameter= #指定用戶自定義參數(shù)
zabbix_agentd.conf
********** 如果您認為這篇文章還不錯或者有所收獲,請點擊右下角的【推薦】/【贊助】按鈕,因為您的支持是我繼續(xù)創(chuàng)作分享的最大動力! **********
作者:講文張字
出處:http://www.rzrgm.cn/zhangwencheng
版權(quán):本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁面明顯位置給出 原文鏈接
出處:http://www.rzrgm.cn/zhangwencheng
版權(quán):本文版權(quán)歸作者和博客園共有,歡迎轉(zhuǎn)載,但未經(jīng)作者同意必須保留此段聲明,且在文章頁面明顯位置給出 原文鏈接

浙公網(wǎng)安備 33010602011771號