highlight: a11y-dark
theme: juejin
1. 主动模式
107
下载 wget http://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3%2Bbionic_all.deb
dpkg -i zabbix-release_4.0-3+bionic_all.deb
更新源并安装包 apt update apt install -y zabbix-agent
查看zabbixagentd版本 zabbix_agentd --version
更改zabbixagentd配置文件 ``` vim /etc/zabbix/zabbix_agentd.conf
修改下面信息
Server=192.168.37.101 StartAgents=3 ServerActive=192.168.37.101 <--(主动)
Hostname=192.168.37.107 看文件内容
grep "^[a-Z]" /etc/zabbix/zabbixagentd.conf PidFile=/var/run/zabbix/zabbixagentd.pid LogFile=/var/log/zabbix/zabbixagentd.log LogFileSize=0 Server=192.168.37.101 StartAgents=3 ServerActive=192.168.37.101 Hostname=192.168.37.107 Include=/etc/zabbix/zabbixagentd.d/*.conf 重启zabbix-agent服务
systemctl restart zabbix-agent
systemctl enable zabbix-agent ```
做模板
全克隆
修改'监控项原型'
创建主机、关联模板
101
测试 zabbix_get -s 192.168.37.107 -p 10050 -k "agent.ping" 1 <--返回值
2. 主动模式proxy模式(性能好)
102 wget http://repo.zabbix.com/zabbix/4.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_4.0-3%2Bbionic_all.deb
dpkg -i zabbix-release_4.0-3+bionic_all.deb
apt update
apt install -y zabbix-proxy-mysql
编辑zabix-proxy ``` vim /etc/zabbix/zabbix_proxy.conf
ProxyMode=0 <--0主动模式、1被动模式 Server=192.168.37.101 ServerPort=10051 Hostname=linux-proxy-active <-- ListenPort=10051 DBHost=192.168.37.104 <--数据库地址 DBName=zabbixproxyactive <--数据库名称 DBUser=zabbix <--数据库账号名 DBPassword=123456 <--数据库密码 ```
104
创建主动模式proxy模式数据库 ```
进入数据库
mysql
创建数据库
create database zabbixproxyactive character set utf8 collate utf8_bin;
授权
grant all privileges on zabbixproxyactive.* to zabbix@'192.168.37.%' identified by '123456'; ``` 102
初始化数据库、否则会报错
zcat /usr/share/doc/zabbix-proxy-mysql/schema.sql.gz |mysql -uzabbix -p123456 -h192.168.37.104 zabbix_proxy_active
重启服务 systemctl restart zabbix-proxy systemctl enable zabbix-proxy
104
验证表是否生成 ``` mysql> use zabbixproxyactive;
mysql> show tables; ... | usersgroups | | usrgrp | | valuemaps | | widget | | widgetfield | +-------------------------------+ 144 rows in set (0.00 sec) ```
107
``` grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbixagentd.pid LogFile=/var/log/zabbix/zabbixagentd.log LogFileSize=0 Server=192.168.37.101 StartAgents=3 ServerActive=192.168.37.102 <-- Hostname=192.168.37.107 Include=/etc/zabbix/zabbix_agentd.d/*.conf
重启服务
systemctl restart zabbix-agent ```
102
102
编辑配置 ``` grep "^[a-Z]" /etc/zabbix/zabbix_proxy.conf
ProxyMode=0 Server=192.168.37.101 ServerPort=10051 Hostname=linux-proxy-active ListenPort=10051 LogFile=/var/log/zabbix/zabbixproxy.log LogFileSize=0 PidFile=/var/run/zabbix/zabbixproxy.pid SocketDir=/var/run/zabbix DBHost=192.168.37.104 DBName=zabbixproxyactive DBUser=zabbix DBPassword=123456 ProxyLocalBuffer=720 <-- ProxyOfflineBuffer=720 <-- HeartbeatFrequency=60 <-- ConfigFrequency=60 <-- DataSenderFrequency=5 <-- SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 ExternalScripts=/usr/lib/zabbix/externalscripts FpingLocation=/usr/bin/fping Fping6Location=/usr/bin/fping6 LogSlowQueries=3000
重启
systemctl restart zabbix-proxy ```
107
看文件中内容 ``` grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbixagentd.pid LogFile=/var/log/zabbix/zabbixagentd.log LogFileSize=0 Server=192.168.37.101,192.168.37.102 <-- StartAgents=3 ServerActive=192.168.37.102 Hostname=192.168.37.107 Include=/etc/zabbix/zabbix_agentd.d/*.conf
重启服务
systemctl restart zabbix-agent ```