zabbix proxy的部署分3个部分.
1. 安装proxy
2. 配置proxy配置文件, 启动proxy
3. 在zabbix WEB接口中添加proxy.
在zabbix web配置好后, 我们配置并启动了server.
本文要讲一下proxy的配置, 如果你的环境比较大的话, 为了降低server的访问压力, 可以配置一些proxy.
或者被监控的agent无法直接和server建立连接, 我们可以在网络边界放一台proxy, 来实现分布式监控.
![zabbix proxy configure (optional) - 德哥@Digoal - PostgreSQL research](http://img0.ph.126.net/dbbUaxyGBCrGkzKCyrISLw==/6619209532793081385.png)
proxy 负责sender从agent receive的请求到server.
2. proxy 的配置, 因为proxy需要database 壳, 还需要连接到server, 所以主要的配置如下 :
-rwxr-xr-x 1 root root 256830 Aug 31 12:10 zabbix_get
-rwxr-xr-x 1 root root 314325 Aug 31 12:10 zabbix_sender
2. proxy 的配置, 因为proxy需要database 壳, 还需要连接到server, 所以主要的配置如下 :
特别注意, zabbix proxy的数据库不要和zabbix server混用, 因为zabbix proxy的配置也要存储在数据库中, 混用的话会搞乱配置.
注意如果zabbix server和zabbix proxy在同一台主机允许, 需要使用不同的监听端口.
另外需要配置schema.
开启数据库访问权限
如果server和proxy在同一台主机运行, 建议使用zabbix以外的用户启动proxy, 同时注意监听端口要区分开.
3. 在zabbix WEB添加proxy
Porxy name 指为proxy取的名字, 必须和proxy配置文件的Hostname=proxy150 一致.
# vi /opt/zabbix/etc/zabbix_proxy.conf
ProxyMode=0
Server=172.16.3.150
ServerPort=10051
Hostname=proxy150
ListenPort=10052
LogFile=/tmp/zabbix_proxy.log
LogFileSize=10
PidFile=/tmp/zabbix_proxy.pid
DBHost=172.16.3.150
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=digoal
DBPort=5432
另外需要配置schema.
[root@150 etc]# su - postgres
postgres@150-> psql
psql (9.3.5)
Type "help" for help.
postgres=# create database zabbix_proxy with template template0 encoding 'UTF8';
CREATE DATABASE
postgres=# grant all on database zabbix_proxy to zabbix;
GRANT
postgres=# \q
postgres@150-> psql zabbix_proxy zabbix -f /opt/soft_bak/zabbix-2.2.6/database/postgresql/schema.sql
开启数据库访问权限
vi pg_hba.conf
host all all 0.0.0.0/0 md5
vi postgresql.conf
listen_addresses = '0.0.0.0'
port = 5432
pg_ctl reload
如果server和proxy在同一台主机运行, 建议使用zabbix以外的用户启动proxy, 同时注意监听端口要区分开.
[root@150 etc]# useradd zabbix_proxy
[root@150 etc]# su - zabbix_proxy -c "zabbix_proxy -c /opt/zabbix/etc/zabbix_proxy.conf"
[root@150 etc]# ps -ewf|grep zabbix_proxy
503 19363 1 0 10:25 ? 00:00:00 zabbix_proxy -c /opt/zabbix/etc/zabbix_proxy.conf
503 19366 19363 0 10:25 ? 00:00:00 zabbix_proxy: configuration syncer [synced config 67 bytes in 0.011459 sec, idle 3600 sec]
503 19367 19363 0 10:25 ? 00:00:00 zabbix_proxy: heartbeat sender [sending heartbeat message failed in 0.004483 sec, idle 60 sec]
503 19368 19363 0 10:25 ? 00:00:00 zabbix_proxy: data sender [sent 0 values in 0.002888 sec, idle 1 sec]
503 19369 19363 0 10:25 ? 00:00:00 zabbix_proxy: poller #1 [got 0 values in 0.000037 sec, idle 5 sec]
503 19371 19363 0 10:25 ? 00:00:00 zabbix_proxy: poller #2 [got 0 values in 0.000034 sec, idle 5 sec]
503 19372 19363 0 10:25 ? 00:00:00 zabbix_proxy: poller #3 [got 0 values in 0.000030 sec, idle 5 sec]
503 19374 19363 0 10:25 ? 00:00:00 zabbix_proxy: poller #4 [got 0 values in 0.000021 sec, idle 5 sec]
503 19375 19363 0 10:25 ? 00:00:00 zabbix_proxy: poller #5 [got 0 values in 0.000031 sec, idle 5 sec]
503 19376 19363 0 10:25 ? 00:00:00 zabbix_proxy: unreachable poller #1 [got 0 values in 0.000028 sec, idle 5 sec]
503 19377 19363 0 10:25 ? 00:00:00 zabbix_proxy: trapper #1 [processed data in 0.000000 sec, waiting for connection]
503 19378 19363 0 10:25 ? 00:00:00 zabbix_proxy: trapper #2 [processed data in 0.000000 sec, waiting for connection]
503 19379 19363 0 10:25 ? 00:00:00 zabbix_proxy: trapper #3 [processed data in 0.000000 sec, waiting for connection]
503 19380 19363 0 10:25 ? 00:00:00 zabbix_proxy: trapper #4 [processed data in 0.000000 sec, waiting for connection]
503 19381 19363 0 10:25 ? 00:00:00 zabbix_proxy: trapper #5 [processed data in 0.000000 sec, waiting for connection]
503 19382 19363 0 10:25 ? 00:00:00 zabbix_proxy: icmp pinger #1 [got 0 values in 0.000031 sec, idle 5 sec]
503 19383 19363 0 10:25 ? 00:00:00 zabbix_proxy: housekeeper [deleted 0 records in 0.002591 sec, idle 3600 sec]
503 19384 19363 0 10:25 ? 00:00:00 zabbix_proxy: http poller #1 [got 0 values in 0.002798 sec, idle 5 sec]
503 19385 19363 0 10:25 ? 00:00:00 zabbix_proxy: discoverer #1 [processed 0 rules in 0.002625 sec, idle 60 sec]
503 19386 19363 0 10:25 ? 00:00:00 zabbix_proxy: history syncer #1 [synced 0 items in 0.000015 sec, idle 5 sec]
503 19388 19363 0 10:25 ? 00:00:00 zabbix_proxy: history syncer #2 [synced 0 items in 0.000015 sec, idle 5 sec]
503 19389 19363 0 10:25 ? 00:00:00 zabbix_proxy: history syncer #3 [synced 0 items in 0.000016 sec, idle 5 sec]
503 19390 19363 0 10:25 ? 00:00:00 zabbix_proxy: history syncer #4 [synced 0 items in 0.000020 sec, idle 5 sec]
503 19392 19363 0 10:25 ? 00:00:00 zabbix_proxy: self-monitoring [processed data in 0.000004 sec, idle 1 sec]
监听
[root@150 etc]# netstat -anp|grep 10052
tcp 0 0 0.0.0.0:10052 0.0.0.0:* LISTEN 19363/zabbix_proxy
tcp 0 0 :::10052 :::* LISTEN 19363/zabbix_proxy
[root@150 etc]# netstat -anp|grep 10051
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 17605/zabbix_server
3. 在zabbix WEB添加proxy
![zabbix proxy configure (optional) - 德哥@Digoal - PostgreSQL research](http://img2.ph.126.net/WMxe3ONTdWqSzorKVrlUiw==/6608215516028411048.png)
Proxy mode和配置文件ProxyMode=0表示的意思一致.
# 0 - proxy in the active mode
# 1 - proxy in the passive mode
Hosts 指被Proxy监控的主机列表. 如果zabbix中已经添加了主机的话, 这里都能看到.
[其他]
1. proxy在将监控数据发送给server之前, 是会先缓存在本地的, 所以proxy和server发生短暂的离线问题也不大.
### Option: ProxyLocalBuffer
# Proxy will keep data locally for N hours, even if the data have already been synced with the server.
# This parameter may be used if local data will be used by third party applications.
#
# Mandatory: no
# Range: 0-720
# Default:
# ProxyLocalBuffer=0
### Option: ProxyOfflineBuffer
# Proxy will keep data for N hours in case if no connectivity with Zabbix Server.
# Older data will be lost.
#
# Mandatory: no
# Range: 1-720
# Default:
# ProxyOfflineBuffer=1
[参考]