- 被监控主机安装zabbix-agent
yum install zabbix-agent -y 或者官网下载安装包: https://www.zabbix.com/download_agents - 修改配置文件
centos7配置文件路径:/etc/zabbix_agentd.conf
centos6配置文件路径:/etc/zabbix/zabbix_agentd.conf
以下以centos7为例:
sed -i 's/Server=127.0.0.1/Server=192.168.40.128/' /etc/zabbix_agentd.conf #192.168.40.128为zabbix server的IP,根据实际填写
sed -i 's/Server=127.0.0.1/ServerActive=192.168.40.128/'
sed -i 's/Hostname=Zabbix Server/Hostname=myhostname/ /etc/zabbix_agentd.conf #myhostname的务必要与server端添加被监控端时设置的主机名一样
sed -i '/# Hostname=/d' /etc/zabbix_agentd.conf ##删除这行以避免报错cannot send list of active checks to “IP“: host [Hostname] not found
- 防火墙放行zabbix-agent 10050端口
centos7:
centos7: firewall-cmd --add-port=10050/tcp --permanent && firewall-cmd --reload && firewall-cmd --list-port
centos6:
centos6: iptables -A OUTPUT -p TCP --sport 10050 -j ACCEPT && service iptables save && iptables -nL
- 启动zabbix-agent并设置开机自启动
centos7:
systemctl enable --now zabbix-agent && systemctl status zabbix-agent
centos6:
service zabbix-agent start && chkconfig zabbix-agent on