实战环境
- zabbix server服务器:192.168.3.111
- zabbix agent服务器(本实验不涉及):192168.3.199、192.168.3.198
- zabbix proxy服务器(分布式服务器):192.168.3.150
- proxy监控的agent:192.168.3.151
分布式架构
- zabbix server --> zabbix proxy --> zabbix agent
- zabbix agent的白名单要配置proxy的
分布式服务器安装zabbix proxy
- 安装mysql,缓存监控数据
yum install -y mariadb-server mariadb mariadb-devel
systemctl restart mariadb
systemctl enable mariadb
- 安装zabbix proxy
yum install -y tar gcc make gcc-c++ net-snmp-devel libxml2-devel libcurl-devel pcre-devel libevent libevent-devel
useradd -s /sbin/nologin zabbix
cd /usr/local/src
wget "https://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.4.4/zabbix-4.4.4.tar.gz"
tar -zxvf zabbix-4.4.4.tar.gz
cd zabbix-4.4.4
./configure --prefix=/usr/local/zabbix --enable-proxy --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make && make install
chown zabbix:zabbix -R /usr/local/zabbix
- 初始化数据库
mysql -uroot -h 127.0.0.1
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to 'zabbix'@'127.0.0.1' identified by 'zabbixpwd';
set names utf8;
use zabbix;
source /usr/local/src/zabbix-4.4.4/database/mysql/schema.sql;
环境变量
echo "export PATH=$PATH:/usr/local/zabbix/sbin:/usr/local/zabbix/bin" >>/etc/profile && source /etc/profile
proxy配置
Hostname为zabbix proxy服务器的名称,Server为zabbix server的IP地址
cat >/usr/local/zabbix/etc/zabbix_proxy.conf <<EOF
Hostname=proxy_3
Server=192.168.3.111
LogFile=/usr/local/zabbix/zabbix_proxy.log
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=zabbixpwd
DBPort=3306
ConfigFrequency=60
EOF
验证
- 启动 zabbix_proxy
- 进程 ps auxf | grep zabbix
- 端口 netstat -tulnp | grep zabbix
- 日志 tail -f /usr/local/zabbix/zabbix_proxy.log
zabbix server的web端配置
- 管理--agent程序代理(一般采用主动式)
- 观察最近出现的时间,没有超过60s(配置文件中ConfigFrequency=60规定的时间,即配置刷新时间)就证明proxy添加正常