- 直接安装,无法安装
[root@JumpServer ~]# yum install -y zabbix-agent2
OS 101 kB/s | 3.8 kB 00:00
everything 96 kB/s | 3.8 kB 00:00
EPOL 82 kB/s | 3.0 kB 00:00
debuginfo 87 kB/s | 3.8 kB 00:00
source 86 kB/s | 3.8 kB 00:00
update 91 kB/s | 3.5 kB 00:00
update 14 MB/s | 28 MB 00:01
No match for argument: zabbix-agent2
Error: Unable to find a match: zabbix-agent2
- 因为没有仓库
[root@JumpServer ~]# ls /etc/yum.repos.d/
openEuler.repo
- 安装zabbix仓库
[root@JumpServer ~]# rpm -Uvh https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-4.el8.noarch.rpm
- 再看看仓库列表
[root@JumpServer ~]# ls /etc/yum.repos.d/
openEuler.repo zabbix-agent2-plugins.repo zabbix.repo
- 好了,可以安装了。
[root@JumpServer ~]# yum install -y zabbix-agent2
- 设置开机自动启动
[root@JumpServer ~]# systemctl enable zabbix-agent2.service
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service → /usr/lib/systemd/system/zabbix-agent2.service.
- 修改zabbix-agent2配置文件
[root@JumpServer ~]# cat /etc/zabbix/zabbix_agent2.conf | grep -Ev '^$|^#'
PidFile=/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=172.16.30.120
ServerActive=172.16.30.120
Hostname=JumpServer
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
Include=./zabbix_agent2.d/plugins.d/*.conf
就改这三个值
Server=172.16.30.120
ServerActive=172.16.30.120
Hostname=JumpServer
- 重启zabbix-agent2服务并查看其状态
[root@JumpServer ~]# systemctl restart zabbix-agent2.service
[root@JumpServer ~]# systemctl status zabbix-agent2.service
● zabbix-agent2.service - Zabbix Agent 2
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent2.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2022-12-08 22:38:20 CST; 55s ago
Main PID: 322754 (zabbix_agent2)
Tasks: 12 (limit: 98896)
Memory: 9.4M
CGroup: /system.slice/zabbix-agent2.service
└─322754 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf
12月 08 22:38:20 JumpServer systemd[1]: Started Zabbix Agent 2.
12月 08 22:38:20 JumpServer zabbix_agent2[322754]: Starting Zabbix Agent 2 (6.0.12)
12月 08 22:38:20 JumpServer zabbix_agent2[322754]: Zabbix Agent2 hostname: [JumpServer]
12月 08 22:38:20 JumpServer zabbix_agent2[322754]: Press Ctrl+C to exit.
[root@JumpServer ~]# ps -ef | grep zabbix
zabbix 322754 1 0 22:38 ? 00:00:00 /usr/sbin/zabbix_agent2 -c /etc/zabbix/zabbix_agent2.conf
root 324891 280852 0 22:40 pts/0 00:00:00 grep --color=auto zabbix
[root@JumpServer ~]# netstat -tnlp | grep zabbix
tcp6 0 0 :::10050 :::* LISTEN 322754/zabbix_agent
- 设置防火墙放行10050端口
[root@JumpServer ~]# firewall-cmd --permanent --add-port=10050/tcp
success
[root@JumpServer ~]# firewall-cmd --reload
success
- 成功。