#一台虚拟机
hostname:Zabbix-agent
ip:server_ip_address
[yuki@Zabbix-agent ~]$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[yuki@Zabbix-agent ~]$ sudo rpm -qa |grep zabbix
[yuki@Zabbix-agent ~]$ sudo yum -y groupinstall "Development Tools"
[yuki@Zabbix-agent ~]$ sudo yum -y install lsof && sudo yum install -y net-tools
[yuki@Zabbix-agent ~]$ sudo yum -y install ntpdate && sudo ntpdate pool.ntp.org
注意:被监控机器上安装zabbix-agent最好是跟zabbix-server的版本保持一致。
[yuki@Zabbix-server ~] rpm -qa |grep zabbix
zabbix-web-mysql-3.4.15-1.el7.noarch
zabbix-get-3.4.15-1.el7.x86_64
zabbix-release-3.4-2.el7.noarch
zabbix-web-3.4.15-1.el7.noarch
zabbix-server-mysql-3.4.15-1.el7.x86_64
zabbix-agent-3.4.15-1.el7.x86_64
zabbix-sender-3.4.15-1.el7.x86_64
[yuki@Zabbix-agent ~]$ sudo mkdir -p /home/tools
[yuki@Zabbix-agent ~]$ cd /home/tools && sudo wget http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.15-1.el7.x86_64.rpm
[yuki@Zabbix-agent ~]$ sudo yum -y install /home/tools/zabbix-agent-3.4.15-1.el7.x86_64.rpm
上面两步等同于:
[yuki@Zabbix-agent ~]$ sudo rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.15-1.el7.x86_64.rpm
检查 zabbix-agent 是否安装成功:
[yuki@Zabbix-agent ~]$ sudo rpm -qa |grep zabbix
zabbix-agent-3.4.15-1.el7.x86_64
[yuki@Zabbix-server tools] sudo cp /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf_bak20190812
[yuki@Zabbix-agent tools]$ sudo egrep -v "^#|^$" /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=127.0.0.1 ###修改成zabbix-server端的ip地址###
ServerActive=127.0.0.1 ###修改成zabbix-server端的ip地址###
Hostname=Zabbix server ###修改成zabbix-agent端即本机的ip地址,不要用127.0.0.1###
Include=/etc/zabbix/zabbix_agentd.d/
[yuki@Zabbix-agent tools]$ sudo sed -i 's/Server=127.0.0.1/Server=x.x.x.x/g' /etc/zabbix/zabbix_agentd.conf
[yuki@Zabbix-agent tools]$ sudo sed -i 's/ServerActive=127.0.0.1/ServerActive=x.x.x.x/g' /etc/zabbix/zabbix_agentd.conf
[yuki@Zabbix-agent tools]$ sudo sed -i '149s/Zabbix\ server/x.x.x.x/g' /etc/zabbix/zabbix_agentd.conf
[yuki@Zabbix-agent tools]$ cd
[yuki@Zabbix-agent ~]$ sudo sed -i '/matahari/azabbix-agent 10050/tcp #Zabbix Agent' /etc/services
[yuki@Zabbix-agent ~]$ sudo sed -i '/matahari/azabbix-agent 10050/udp #Zabbix Agent' /etc/services
[yuki@Zabbix-agent ~]$ tail -2 /etc/services
zabbix-agent 10050/tcp #Zabbix Agent
zabbix-agent 10050/udp #Zabbix Agent
[yuki@Zabbix-agent ~]$ sudo systemctl start firewalld.service #临时开启防火墙
[yuki@Zabbix-agent ~]$ sudo systemctl enable firewalld.service #防火墙开机自启动
[yuki@Zabbix-agent ~]$ sudo systemctl restart firewalld.service #临时重启防火墙
[yuki@Zabbix-agent ~]$ sudo firewall-cmd --state #查看防火墙的状态
[yuki@Zabbix-agent ~]$ sudo firewall-cmd --list-ports #查看已经开放的端口
[yuki@Zabbix-agent ~]$ sudo firewall-cmd --list-services #查看开放的服务
[yuki@Zabbix-agent ~]$ sudo firewall-cmd --zone=public --permanent --add-port=10050/tcp #允许10050/tcp端口访问
[yuki@Zabbix-agent ~]$ sudo firewall-cmd --reload #重新加载配置
[yuki@Zabbix-agent ~]$ sudo setenforce 0 && sudo getenforce
[yuki@Zabbix-agent ~]$ sudo sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux
[yuki@Zabbix-agent ~]$ sudo sed -i '/subsys/asystemctl start zabbix-agent.service ' /etc/rc.local
[yuki@Zabbix-agent ~]$ tail -2 /etc/rc.local
[yuki@Zabbix-agent ~]$ systemctl enable zabbix-agent.service && echo $?
[yuki@Zabbix-agent ~]$ sudo systemctl start zabbix-agent.service
[yuki@Zabbix-agent ~]$ sudo systemctl restart zabbix-agent.service
[yuki@Zabbix-agent ~]$ ps -ef |grep zabbix && sudo netstat -lntup |grep zabbix && lsof -i:10050
错误集锦
cannot set resource limit: [13] Permission denied cannot disable core dump, exiting…解决办法
解决方法关闭selinux
[yuki@Zabbix-agent ~]$ setenforce 0 && sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux