1. Zabbix Proxy介绍
基本原理:
Proxy代替Zabbix-server去收集内容,它会把数据暂存在本地,然后转发给Zabbix-server,proxy不作告警等处理。
主要作用:
分担Zabbix-server压力,简化管理
解决跨机房及防火墙限制等问题
zabbix-server ==> zabbix proxy(数据存在本地需要数据库,纯收集转发给server) ==> zabbix agent
(zabbix proxy架构图)
2. Zabbix Proxy实战
1.安装Proxy
[root@linux-node2 ~]# yum install -y zabbix-proxy zabbix-proxy-mysql mariadb-server
#proxy需要数据库存收集的数据,还需安装fping,OpenIPMI*,snmp等包
2.配置数据库
#由于之前已经安装过Mysql,这里就没有使用mariadb啦
mysql> create database zabbix_proxy character set utf8;
mysql> grant all on zabbix_proxy.* to zabbix_proxy@localhost identified by 'zabbix_proxy';
mysql> exit
#导入zabbix_proxy数据库表
[root@linux-node2 ~]# cd /usr/share/doc/zabbix-proxy-mysql-3.0.1/
[root@linux-node2 zabbix-proxy-mysql-3.0.1]# ls
AUTHORS ChangeLog COPYING NEWS README schema.sql.gz
[root@linux-node2 zabbix-proxy-mysql-3.0.1]# zcat schema.sql.gz | mysql -uzabbix_proxy -p zabbix_proxy
Enter password:
[root@linux-node2 zabbix-proxy-mysql-3.0.1]# mysql -uzabbix_proxy -pzabbix_proxy -e "use zabbix_proxy;show tables;"
Warning: Using a password on the command line interface can be insecure.
+----------------------------+
| Tables_in_zabbix_proxy |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
3.修改zabbix-proxy配置文件
[root@linux-node2 ~]# egrep -v "^#|^$" /etc/zabbix/zabbix_proxy.conf
Server=192.168.56.11 #主机地址
Hostname=zabbix-proxy
LogFile=/var/log/zabbix/zabbix_proxy.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_proxy.pid
DBHost=localhost #proxy本地数据库配置
DBName=zabbix_proxy
DBUser=zabbix_proxy
DBPassword=zabbix_proxy
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000
4.启动zabbix-proxy
[root@linux-node2 ~]# systemctl start zabbix-proxy.service
[root@linux-node1 ~]# netstat -tunpl #zabbix-proxy监控本地的10051端口,代理server收集本地监控数据
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1378/php-fpm: maste
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 1086/rsync
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 4004/mysqld
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 2692/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1362/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 2556/master
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 2445/zabbix_agentd
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 4156/zabbix_server
5.zabbix-server端添加proxy代理
6.修改agent配置文件:ServerActive=192.168.56.12,重启agent
参考文档: