理论部分
Zabbix Proxy适用于大规模分布式监控场景,采用的一种分担Server端压力的分层结构,Proxy只负责一定区域内的数据采集工作,然后定期将数据一次性发送给Server,极大的减轻了Server的负载压力,使得可以支持更大规模的监控需求。
实践部分
环境:
三台机器,其中proxy和agent可以通过内网访问,proxy和server需通过公网访问
IP:180.153.51.130(server端)
IP:180.163.175.40(proxy端)
IP:10.100.4.32(agent端)
一、proxy代理服务器端的配置(公网地址180.163.175.40内网地址172.16.66.22)
zabbix服务器端是zabbix-3.0的版本
1、机器是CentOS 6 的系统,先安装下载和安装zabbix的yum源
wget http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
rpm -ivh zabbix-release-3.0-1.el6.noarch.rpm
2、安装mysql数据库
yum install -y mysql-server mysql-devel mysql
3、初始化数据库
/usr/bin/mysql_secure_installation
4、安装zabbix-proxy
yum install zabbix-proxy-mysql.x86_64
5、创建数据库并授权访问
mysql> create database zabbix_proxy default charset utf8;
mysql> grant all on zabbix_proxy.* to ‘zabbix‘@‘localhost‘ identified by ‘huaxia‘ with grant option;
mysql> flush privileges;
6、把数据表导入到数据库中
cd /usr/share/doc/zabbix-proxy-mysql-3.0.6
zcat schema.sql.gz | mysql -uzabbix -p zabbix_proxy
7、配置代理服务
vim /etc/zabbix/zabbix_proxy.conf
Server=180.153.51.130#zabbix server 的IP地址
Hostname=180.163.175.40#本机的地址,zabbix server要能识别
DBName=zabbix_proxy#数据库名称
DBUser=zabbix#数据库用户
DBPassword=huaxia#数据库密码
8、编辑防火墙的设置
开放10051端口
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT
9、启动zabbix_proxy
Service zabbix_proxy start
10、查看zabbix_proxy监听的端口
[[email protected] ~]# ss -tnlp|grep zabbix
LISTEN 0 128 :::10051 :::* users:(("zabbix_proxy",13001,5),("zabbix_proxy",13006,5),("zabbix_proxy",13007,5),("zabbix_proxy",13008,5),("zabbix_proxy",13009,5),("zabbix_proxy",13010,5),("zabbix_proxy",13011,5),("zabbix_proxy",13012,5),("zabbix_proxy",13013,5),("zabbix_proxy",13014,5),("zabbix_proxy",13015,5),("zabbix_proxy",13016,5),("zabbix_proxy",13018,5),("zabbix_proxy",13019,5),("zabbix_proxy",13021,5),("zabbix_proxy",13022,5),("zabbix_proxy",13023,5),("zabbix_proxy",13024,5),("zabbix_proxy",13025,5),("zabbix_proxy",13026,5),("zabbix_proxy",13027,5),("zabbix_proxy",13028,5),("zabbix_proxy",13029,5),("zabbix_proxy",13030,5))
LISTEN 0 128 *:10051 *:* users:(("zabbix_proxy",13001,4),("zabbix_proxy",13006,4),("zabbix_proxy",13007,4),("zabbix_proxy",13008,4),("zabbix_proxy",13009,4),("zabbix_proxy",13010,4),("zabbix_proxy",13011,4),("zabbix_proxy",13012,4),("zabbix_proxy",13013,4),("zabbix_proxy",13014,4),("zabbix_proxy",13015,4),("zabbix_proxy",13016,4),("zabbix_proxy",13018,4),("zabbix_proxy",13019,4),("zabbix_proxy",13021,4),("zabbix_proxy",13022,4),("zabbix_proxy",13023,4),("zabbix_proxy",13024,4),("zabbix_proxy",13025,4),("zabbix_proxy",13026,4),("zabbix_proxy",13027,4),("zabbix_proxy",13028,4),("zabbix_proxy",13029,4),("zabbix_proxy",13030,4))
二、agent 客户端的配置(内网地址10.100.4.32)
1、机器是CentOS 6 的系统,先安装下载和安装zabbix的yum源
wget http://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
rpm -ivh zabbix-release-3.0-1.el6.noarch.rpm
2、安装agent
yum install zabbix-agent.x86_64 zabbix-sender.x86_64
3、配置agent
vim /etc/zabbix/zabbix_agentd.conf
Server=172.16.66.22#代理服务器端地址
ServerActive=172.16.66.22#代理服务器端地址
Hostname=10.100.4.32#本机地址,代理服务器要可以识别
4启动agent服务
service zabbix-agent start
5、查看agent监听的端口
[[email protected] zabbix]# ss -tnlp|grep zabbix
0 128 :::10050 :::* users:(("zabbix_agentd",8193,5),("zabbix_agentd",8194,5),("zabbix_agentd",8195,5),("zabbix_agentd",8197,5),("zabbix_agentd",8198,5),("zabbix_agentd",8199,5))
0 128 *:10050 *:* users:(("zabbix_agentd",8193,4),("zabbix_agentd",8194,4),("zabbix_agentd",8195,4),("zabbix_agentd",8197,4),("zabbix_agentd",8198,4),("zabbix_agentd",8199,4))
三、zabbix server 端设置(公网地址180.153.51.130)
1、添加主机和服务
2、代理服务器设置
3、查看采集到的数据