配置主机yum
下载rpm包,配置yum,安装agent
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo --no-check-certificate
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/6/x86_64/zabbix-release-5.0-1.el6.noarch.rpm
sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
yum install zabbix-agent2 -y
配置开机服务自启动
#添加zabbix-agent2 服务
chkconfig --add zabbix-agent2
#开机自启zabbix-agent2 服务
chkconfig zabbix-agent2 on
#关闭开机自启
chkconfig apache off
#查看
chkconfig --list | grep zabbix-agent2
service zabbix-agent2 start
修改agent2配置文件,修改如下,填写zabbix-server主机ip和主机名
默认配置文件为 /etc/zabbix/zabbix_agent2.conf
PidFile : 进程id
LogFile : 日志文件
Server : Zabbix的Server地址 或Zabbix的Proxy地址
ServerActive : Zabbix的Server地址 或Zabbix的Proxy地址
Hostname: 当前主机的hostname
Include: 包含的配置文件
[root@load-kfapplications yum.repos.d]# grep -Ev '^#|^$' /etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
重启zabbix-agent
[root@load-kfapplications yum.repos.d]# systemctl restart zabbix-agent2
在server上测试连通性及获取主机名,返回1则为true
[root@zabbix-server etc]# zabbix_get -s '192.168.1.38' -p 10050 -k "agent.ping"
1
[root@zabbix-server etc]# zabbix_get -s '192.168.1.38' -p 10050 -k "system.hostname"
load-kfapplications