zabbix proxy就是所謂的分布式監控,主要是代理zabbix server進行采集資料,zabbix proxy端也需要搭建另外一個mysql資料庫,并且mysql需要建立一個zabbix_proxy資料庫.
如果你有多個proxy和一個zabbix server組合,這就可以叫分布式監控了。
zabbix proxy 隻是一個程序 需要一個資料庫 沒有web界面 不會處理事件 也不會發送郵件 隻是一個采集資料的功能
zabbix proxy的作用,官方描述
A Zabbix proxy can collect performance and availability data on behalf of the Zabbix server. This way, a proxy can take on itself some of the load of collecting data and offload the Zabbix server.
Also, using a proxy is the easiest way of implementing centralized and distributed monitoring, when all agents and proxies report to one Zabbix server and all data is collected centrally.
A Zabbix proxy can be used to:
Monitor remote locations
Monitor locations having unreliable communications
Offload the Zabbix server when monitoring thousands of devices 監控上萬台伺服器就靠他
Simplify the maintenance of distributed monitoring
<a href="https://s1.51cto.com/wyfs02/M02/A5/C7/wKioL1nDNa3h5R3aAABR9mylmzc004.png-wh_500x0-wm_3-wmp_4-s_2211427240.png" target="_blank"></a>
<a href="https://s3.51cto.com/wyfs02/M00/07/16/wKiom1nDNjzwAcgyAAChru2Zx00564.png" target="_blank"></a>
先說說思路:安裝zabbix proxy >安裝mysql資料庫 >導入zabbix_proxy資料庫結構 > 配置zabbix proxy(server ip 需要指向zabbix server位址) > 安裝zabbix agent 并配置即可
<code>#安裝zabbix proxy</code>
<code>rpm -ivh http:</code><code>//repo</code><code>.zabbix.com</code><code>/zabbix/3</code><code>.4</code><code>/rhel/7/x86_64/zabbix-release-3</code><code>.4-1.el7.centos.noarch.rpm</code>
<code>yum -y </code><code>install</code> <code>zabbix-proxy zabbix-proxy-mysql</code>
<code>#安裝資料庫5.6</code>
<code>wget http:</code><code>//dev</code><code>.mysql.com</code><code>/get/mysql-community-release-el7-5</code><code>.noarch.rpm</code>
<code>rpm -ivh mysql-community-release-el7-5.noarch.rpm</code>
<code>yum </code><code>install</code> <code>mysql-community-server</code>
<code>systemctl restart mysqld.service</code>
<code>#設定msyql密碼為 123456</code>
<code>mysql> </code><code>set</code> <code>password </code><code>for</code> <code>'root'</code><code>@</code><code>'localhost'</code> <code>=password(</code><code>'123456'</code><code>);</code>
<code> </code>
<code>#遠端連接配接設定,所有以root賬号連接配接的遠端使用者,設其密碼為 123456</code>
<code>mysql> grant all on xxxx.* to </code><code>'root'</code><code>@</code><code>'%'</code> <code>identified by </code><code>'123456'</code> <code>with grant option;</code>
<code>#更新權限</code>
<code>mysql>flush privileges;</code>
<code>#資料庫開機啟動</code>
<code>systemctl </code><code>enable</code> <code>mysqld.service</code>
<code>###建立MySQL zabbix_proxy資料庫和使用者</code>
<code>mysql –u root –p</code>
<code>mysql> create database zabbix_proxy character </code><code>set</code> <code>utf8;</code>
<code>mysql> grant all privileges on zabbix_proxy.* to </code><code>'zabbix'</code><code>@</code><code>'127.0.0.1'</code> <code>identified by </code><code>'zabbix'</code><code>;</code>
<code>mysql> flush privileges;</code>
<code>#資料庫導入zabbix schema.sql.gz</code>
<code>zcat </code><code>/usr/share/doc/zabbix-proxy-mysql-3</code><code>.4.*</code><code>/schema</code><code>.sql.gz | mysql -uzabbix -p zabbix_proxy</code>
<code>#登陸資料庫</code>
<code>mysql -uroot -p</code>
<code>#檢視資料庫,多了一個zabbix_proxy資料庫</code>
<code>mysql> show databases;</code>
<code>+--------------------+</code>
<code>| Database |</code>
<code>| information_schema |</code>
<code>| mysql |</code>
<code>| performance_schema |</code>
<code>| zabbix_proxy |</code>
<code>4 rows </code><code>in</code> <code>set</code> <code>(0.01 sec)</code>
<code>#zabbix proxy配置檔案</code>
<code>grep</code> <code>'^[a-Z]'</code> <code>/etc/zabbix/zabbix_proxy</code><code>.conf</code>
<code>Server=zabbix server端伺服器ip位址</code>
<code>Hostname=Zabbix proxy final</code>
<code>LogFile=</code><code>/var/log/zabbix/zabbix_proxy</code><code>.log</code>
<code>LogFileSize=0</code>
<code>PidFile=</code><code>/var/run/zabbix/zabbix_proxy</code><code>.pid</code>
<code>SocketDir=</code><code>/var/run/zabbix</code>
<code>DBHost=127.0.0.1</code>
<code>DBName=zabbix_proxy</code>
<code>DBUser=zabbix</code>
<code>DBPassword=zabbix</code>
<code>SNMPTrapperFile=</code><code>/var/log/snmptrap/snmptrap</code><code>.log</code>
<code>Timeout=4</code>
<code>ExternalScripts=</code><code>/usr/lib/zabbix/externalscripts</code>
<code>LogSlowQueries=3000</code>
<code>#zabbix agent用戶端</code>
<code>grep</code> <code>'^[a-Z]'</code> <code>/etc/zabbix/zabbix_agentd</code><code>.conf</code>
<code>PidFile=</code><code>/var/run/zabbix/zabbix_agentd</code><code>.pid</code>
<code>LogFile=</code><code>/var/log/zabbix/zabbix_agentd</code><code>.log</code>
<code>Server=zabbix proxy ip位址</code>
<code>ServerActive=zabbix proxy ip位址</code>
<code>Hostname=nginx02</code>
<code>Include=</code><code>/etc/zabbix/zabbix_agentd</code><code>.d/*.conf</code>
#server 日志
<code>#server 日志 </code>
<code> </code><code>105825:20170920:155704.097 cannot parse proxy data from active proxy at </code><code>"xx.xx.xx.xx"</code><code>: proxy </code><code>"Zabbix proxy final"</code> <code>not found</code>
<code>105826:20170920:155705.108 cannot parse proxy data from active proxy at </code><code>"xx.xx.xx.xx"</code><code>: proxy </code><code>"Zabbix proxy final"</code> <code>not found</code>
<code>105826:20170920:155706.119 cannot parse proxy data from active proxy at </code><code>"xx.xx.xx.xx"</code><code>: proxy </code><code>"Zabbix proxy final"</code> <code>not found</code>
<code>105825:20170920:155707.128 cannot parse proxy data from active proxy at </code><code>"xx.xx.xx.xx"</code><code>: proxy </code><code>"Zabbix proxy final"</code> <code>not found</code>
<code>105826:20170920:155708.139 cannot parse proxy data from active proxy at </code><code>"xx.xx.xx.xx"</code><code>: proxy </code><code>"Zabbix proxy final"</code> <code>not found</code>
<code>105825:20170920:155709.149 cannot parse proxy data from active proxy at </code><code>"xx.xx.xx.xx"</code><code>: proxy </code><code>"Zabbix proxy final"</code> <code>not found</code>
<code>105826:20170920:155710.160 cannot parse proxy data from active proxy at </code><code>"xx.xx.xx.xx"</code><code>: proxy </code><code>"Zabbix proxy final"</code> <code>not found</code>
<code>105825:20170920:164017.897 sending configuration data to proxy </code><code>"Zabbix proxy final"</code> <code>at </code><code>"xx.xx.xx.xx"</code><code>, datalen 8172</code>
<code>105800:20170920:165042.107 executing housekeeper</code>
<code>105800:20170920:165052.563 housekeeper [deleted 37754 hist</code><code>/trends</code><code>, 0 items, 0 events, 0 problems, 0 sessions, 0 alarms, 0 audit items </code><code>in</code> <code>10.439203 sec, idle </code><code>for</code> <code>1 hour(s)]</code>
<code>#按照我的推斷是,server端沒有及時發送配置資料給proxy,應該是同步配置問題。這個過程中,我差不多度娘了一個小時,突然發現自己可以監控資料了。</code>
<code>後面我都試驗了幾次,時間長就可以正常同步了。隻要server端發送資料給proxy</code>
#proxy日志
<code>#zabbix_proxy日志</code>
<code>t [nginx02] not found</code>
<code> </code><code>17523:20170920:163748.893 cannot send list of active checks to </code><code>"127.0.0.1"</code><code>: host [nginx02] not found</code>
<code> </code><code>17523:20170920:163948.912 cannot send list of active checks to </code><code>"127.0.0.1"</code><code>: host [nginx02] not found</code>
<code> </code><code>17504:20170920:164140.772 received configuration data from server at </code><code>"xx.xx.xx.xx"</code><code>, datalen 8172</code>
<code> </code><code>17516:20170920:164150.825 enabling Zabbix agent checks on host </code><code>"nginx02"</code><code>: host became available</code>
#檢查proxy是否為一個程序
<code>[root@nginx02~]</code><code># ps -ef|grep proxy</code>
<code>zabbix 17503 1 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code> <code>-c </code><code>/etc/zabbix/zabbix_proxy</code><code>.conf</code>
<code>zabbix 17504 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: configuration syncer [synced config 13741 bytes </code><code>in</code> <code>0.079034 sec, idle 3600 sec]</code>
<code>zabbix 17505 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: heartbeat sender [sending heartbeat message success </code><code>in</code> <code>0.014880 sec, idle 60 sec]</code>
<code>zabbix 17506 17503 0 15:41 ? 00:00:04 </code><code>/usr/sbin/zabbix_proxy</code><code>: data sender [sent 1 values </code><code>in</code> <code>0.018079 sec, sending data]</code>
<code>zabbix 17507 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: housekeeper [deleted 2169 records </code><code>in</code> <code>0.034788 sec, idle </code><code>for</code> <code>1 hour(s)]</code>
<code>zabbix 17508 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: http poller </code><code>#1 [got 0 values in 0.000464 sec, idle 5 sec]</code>
<code>zabbix 17509 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: discoverer </code><code>#1 [processed 0 rules in 0.000326 sec, idle 60 sec]</code>
<code>zabbix 17510 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: </code><code>history</code> <code>syncer </code><code>#1 [synced 0 items in 0.000001 sec, idle 1 sec]</code>
<code>zabbix 17511 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: </code><code>history</code> <code>syncer </code><code>#2 [synced 0 items in 0.000001 sec, idle 1 sec]</code>
<code>zabbix 17512 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: </code><code>history</code> <code>syncer </code><code>#3 [synced 1 items in 0.008008 sec, idle 1 sec]</code>
<code>zabbix 17513 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: </code><code>history</code> <code>syncer </code><code>#4 [synced 0 items in 0.000001 sec, idle 1 sec]</code>
<code>zabbix 17514 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: self-monitoring [processed data </code><code>in</code> <code>0.000004 sec, idle 1 sec]</code>
<code>zabbix 17515 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: task manager [processed 0 task(s) </code><code>in</code> <code>0.000326 sec, idle 5 sec]</code>
<code>zabbix 17516 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: poller </code><code>#1 [got 0 values in 0.000003 sec, idle 1 sec]</code>
<code>zabbix 17517 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: poller </code><code>#2 [got 0 values in 0.000003 sec, idle 1 sec]</code>
<code>zabbix 17518 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: poller </code><code>#3 [got 1 values in 0.000417 sec, idle 1 sec]</code>
<code>zabbix 17519 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: poller </code><code>#4 [got 0 values in 0.000003 sec, idle 1 sec]</code>
<code>zabbix 17520 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: poller </code><code>#5 [got 0 values in 0.000003 sec, idle 1 sec]</code>
<code>zabbix 17521 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: unreachable poller </code><code>#1 [got 0 values in 0.000004 sec, idle 5 sec]</code>
<code>zabbix 17522 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: trapper </code><code>#1 [processed data in 0.000000 sec, waiting for connection]</code>
<code>zabbix 17523 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: trapper </code><code>#2 [processed data in 0.020794 sec, waiting for connection]</code>
<code>zabbix 17524 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: trapper </code><code>#3 [processed data in 0.000000 sec, waiting for connection]</code>
<code>zabbix 17525 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: trapper </code><code>#4 [processed data in 0.000713 sec, waiting for connection]</code>
<code>zabbix 17526 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: trapper </code><code>#5 [processed data in 0.000000 sec, waiting for connection]</code>
<code>zabbix 17527 17503 0 15:41 ? 00:00:00 </code><code>/usr/sbin/zabbix_proxy</code><code>: icmp pinger </code><code>#1 [got 0 values in 0.000005 sec, idle 5 sec]</code>
<code>root 31094 31000 0 18:22 pts</code><code>/0</code> <code>00:00:00 </code><code>grep</code> <code>--color=auto proxy</code>
剛配置提示的錯誤
17506:20170920:154253.213 cannot send proxy data to server at "xx.xx.xx.xx": proxy "Zabbix proxy final" not found
17506:20170920:154254.228 cannot send proxy data to server at "xx.xx.xxx.xx": proxy "Zabbix proxy final" not found
web方面操作
第一個步驟配置agent代理程式
<a href="https://s4.51cto.com/wyfs02/M02/A5/C7/wKioL1nDN6Tgp85PAAB3I9yR_M0302.png" target="_blank"></a>
<a href="https://s5.51cto.com/wyfs02/M02/07/16/wKiom1nDN9mA8oUKAAB5XpX5Zw0128.png" target="_blank"></a>
第二個步驟配置自動注冊
本文轉自 yanconggod 51CTO部落格,原文連結:http://blog.51cto.com/yanconggod/1967387