一.zabbix-proxy
作用:
- 监控远程区域设备
- 监控本地网络不稳定区域
- 当 zabbix 监控上千设备时,使用它来减轻 server 的压力
- 简化分布式监控的维护
二.实验环境
主机名 | 角色 |
---|---|
server1 | zabbix-server, zabbix-agent, zabbix-mysql |
server2(proxy) | zabbix-proxy |
server3 | zabbix-agent |
三.配置proxy主机
关闭该主机之前的agent服务,或者新建主机
1.修改主机名,作解析(其他主机也作解析)
[root@server2 ~]# hostnamectl set-hostname proxy
[root@server2 ~]# vim /etc/hosts
2.安装zabbix-proxy及mariadb
[root@server2 yum.repos.d]# ls
dvd.repo redhat.repo zabbix.repo
[root@server2 yum.repos.d]# yum install -y zabbix-proxy
[root@server2 yum.repos.d]# yum install -y mariadb-server
[root@server2 yum.repos.d]# systemctl enable --now mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
3.修改zabbix-proxy配置文件并开启proxy
[root@server2 yum.repos.d]# cd /etc/zabbix/
[root@server2 zabbix]# ls
zabbix_agentd.conf zabbix_agentd.d zabbix_proxy.conf
[root@server2 zabbix]# vim zabbix_proxy.conf
[root@server2 zabbix]# systemctl start zabbix-proxy
[root@server2 zabbix]# grep -v ^# zabbix_proxy.conf
Server=172.25.13.1
Hostname=proxy
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=westos
4.进入mariadb创建zabbix用户及zabbix_proxy数据库
[root@server2 zabbix]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 5.5.60-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)]> create database zabbix_proxy character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'westos';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> exit
Bye
5.往数据库中导入数据
[root@server2 zabbix]# cd /usr/share/doc/zabbix-proxy-mysql-4.0.25/
[root@server2 zabbix-proxy-mysql-4.0.25]# ls
AUTHORS ChangeLog COPYING NEWS README schema.sql.gz
[root@server2 zabbix-proxy-mysql-4.0.25]# zcat schema.sql.gz | mysql -u zabbix -pwestos zabbix_proxy
[root@server2 zabbix-proxy-mysql-4.0.25]# systemctl enable zabbix-proxy
Created symlink from /etc/systemd/system/multi-user.target.wants/zabbix-proxy.service to /usr/lib/systemd/system/zabbix-proxy.service.
[root@server2 zabbix-proxy-mysql-4.0.25]# systemctl restart zabbix-proxy
6.查看日志,确定proxy可接收来自server的数据
[root@server2 ~]# tail /var/log/zabbix/zabbix_proxy.log
二.zabbix-agent:
1.更改server3配置文件,全部指向proxy主机
[root@server3 zabbix]# vim zabbix_agentd.conf
[root@server3 zabbix]# systemctl restart zabbix-agent
三.web端:
1.新建agent代理程序
2.server3上替换模板并更新为由proxy监测
四.添加对tomcat监控(不加也行)
[root@server2 zabbix]# vim zabbix_proxy.conf
[root@server2 zabbix]# systemctl restart zabbix-proxy