目录
新运行一个台服务器安装部署zabbix-agent作为被监控服务器
如果本文章对你有帮助,麻烦点赞评论,如果在操作过程遇到问题及时留言
安装zabbix库
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/7.2/release/alma/9/noarch/zabbix-release-latest-7.2.el9.noarch.rpm
Retrieving https://repo.zabbix.com/zabbix/7.2/release/alma/9/noarch/zabbix-release-latest-7.2.el9.noarch.rpm
warning: /var/tmp/rpm-tmp.z1vz3H: Header V4 RSA/SHA512 Signature, key ID b5333005: NOKEY
Verifying... ################################# [100%]
Preparing... ################################# [100%]
Updating / installing...
1:zabbix-release-7.2-1.el9 ################################# [100%]
[root@localhost ~]# dnf clean all
21 files removed
[root@localhost ~]# dnf install zabbix-agent
CentOS Stream 9 - BaseOS [ === ] --- B/s | 0 B --:-- ETA
安装启动zabbix-agent
[root@localhost ~]# dnf install zabbix-agent
CentOS Stream 9 - BaseOS 250 kB/s | 8.7 MB 00:35
-----------------------------
----------------------------
[root@localhost ~]# systemctl restart zabbix-agent
[root@localhost ~]# systemctl enable zabbix-agent
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent.service → /usr/lib/systemd/system/zabbix-agent.service.
[root@localhost ~]# netstat -pltun
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:10050 0.0.0.0:* LISTEN 16564/zabbix_agentd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1420/sshd: /usr/sbi
tcp6 0 0 :::10050 :::* LISTEN 16564/zabbix_agentd
tcp6 0 0 :::22 :::* LISTEN 1420/sshd: /usr/sbi
udp 0 0 127.0.0.1:323 0.0.0.0:* 691/chronyd
udp6 0 0 ::1:323 :::* 691/chronyd
[root@localhost ~]#
关闭防火墙
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
修改zabbix-agent配置文件
[root@localhost zabbix]# cd /etc/zabbix
[root@localhost zabbix]# grep -E "^[a-Z]" zabbix_agentd.conf
PidFile=/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@localhost zabbix]# sed -i 's/127.0.0.1/192.168.25.151/g' zabbix_agentd.conf
[root@localhost zabbix]# grep -E "^[a-Z]" zabbix_agentd.conf
PidFile=/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.25.151
ServerActive=192.168.25.151
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/*.conf
[root@localhost zabbix]# systemctl restart zabbix-agent
# 指定了Zabbix代理程序的进程ID文件路径
PidFile=/run/zabbix/zabbix_agentd.pid
# 指定了Zabbix代理程序的日志文件路径
LogFile=/var/log/zabbix/zabbix_agentd.log
# 设置了Zabbix代理程序日志文件的最大大小限制为0
LogFileSize=0
# 指定了Zabbix服务器的IP地址,Zabbix代理程序将向此IP地址报告数据
Server=192.168.25.151
# 指定了Zabbix代理程序主动连接到的Zabbix服务器的IP地址
ServerActive=192.168.25.151
# 设置了Zabbix代理程序的主机名为"Zabbix server"
Hostname=Zabbix server
# 指定了Zabbix代理程序应该包含的其他配置文件的路径,这些文件通常包含特定的监控项配置
Include=/etc/zabbix/zabbix_agentd.d/*.conf
配置zabbix-ui界面,设置监控
创建主机
监测-主机-创建主机
主机名称: agent服务器的ip
模板:选择系统自带的agent
主机群组:选择系统 (比如 摸鱼群、吃饭群这样理解)
接口: 监控数据来源地址
主机查看是否监控成功
创建群组
数据采集-主机群组-创建群组
新建主机设置新的群组
监控仪表盘
停止agent服务(但是响应会很慢需要等待界面告警)
systemctl stop zabbix-agent
可以看到报错信息,提示服务不可用