- 安装Nginx
参考:http://nginx.org/en/linux_packages.html#RHEL-CentOS
[root@nginx ~]# vi /etc/yum.repos.d/nginx.repo
[root@nginx ~]# cat /etc/yum.repos.d/nginx.repo
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[root@nginx ~]# dnf install nginx -y
- 安装Zabbix-Agent
[root@nginx ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
[root@nginx ~]# dnf clean all
[root@nginx ~]# dnf install zabbix-agent
- 备份Zabbix-Agent配置文件
[root@nginx ~]# cp /etc/zabbix/zabbix_agentd.conf{,.bak}
[root@nginx ~]# sed -E '/^#|^$/d' /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
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@nginx ~]# sed -E '/^#|^$/d' /etc/zabbix/zabbix_agentd.conf.bak > /etc/zabbix/zabbix_agentd.conf
[root@nginx ~]#
- 修改Zabbix-Agent配置文件
[root@nginx ~]# echo "13.13.100.100 zabbix" > /etc/hosts
[root@nginx ~]# sed -i 's/127.0.0.1/zabbix/g' /etc/zabbix/zabbix_agentd.conf
[root@nginx ~]# sed -i 's/Zabbix server/Nginx/g' /etc/zabbix/zabbix_agentd.conf
[root@nginx ~]# cat /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=zabbix
ServerActive=zabbix
Hostname=Nginx
Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@nginx ~]#
- 配置防火墙
[root@nginx ~]# firewall-cmd --permanent --add-service=zabbix-agent
[root@nginx ~]# firewall-cmd --permanent --add-service=http
[root@nginx ~]# firewall-cmd --reload
[root@nginx ~]#
- 开启服务
[root@nginx ~]# systemctl enable nginx.service zabbix-agent.service
[root@nginx ~]# systemctl start nginx.service zabbix-agent.service
[root@nginx ~]#
- 服务端测试连通性
[root@zabbix ~]# dnf install zabbix-get -y
[root@zabbix ~]# zabbix_get -s 13.13.50.1 -k agent.hostname
Nginx
[root@zabbix ~]#
- 添加新的监控主机
、