1. 关闭防火墙
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
systemctl disable --now firewalld
2. 同步时间服务器
在CentOS8上,ntpdate同步已经变成了chrony
yum install chrony -y
vi /etc/chrony.conf
第一行
server 192.168.122.55 iburst(zabbix-server的ip)
systemctl restart chronyd
systemctl status chronyd
注意服务器端也要开启一下chronyd才可以,然后可以同步发送一条date命令查看是否成功!
3. 统一时区
mv /etc/localtime{,.bak}
ln -s /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
4. 添加zabbix源并修改为清华源
rpm -Uvh https://repo.zabbix.com/zabbix/6.0/rhel/8/x86_64/zabbix-release-6.0-1.el8.noarch.rpm
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/6.0/rhel/8/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
gpgcheck=1
5. 安装zabbix-agent2
yum install zabbix-agent2 -y
6. 查看命令
[root@com yum.repos.d]# ls -l /usr/sbin/zabbix_agent2
-rwxr-xr-x 1 root root 18680048 Apr 4 22:08 /usr/sbin/zabbix_agent2
7. 启动客户端
[root@com yum.repos.d]# systemctl enable --now zabbix-agent2
Created symlink /etc/systemd/system/multi-user.target.wants/zabbix-agent2.service → /usr/lib/systemd/system/zabbix-agent2.service.
8. 配置zabbix-agent2文件
[root@com yum.repos.d]# vi /etc/zabbix/zabbix_agent2.conf
Server=192.168.122.55(Server端IP)
ServerActive=192.168.122.55(Server端IP)
Hostname=com.cnpc.engine(主机的名字)
9. 检查刚刚修改的内容
[root@com 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=192.168.122.55
ServerActive=192.168.122.55
Hostname=com.cnpc.engine
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
Include=./zabbix_agent2.d/plugins.d/*.conf
10. 重启使配置生效
[root@com yum.repos.d]# systemctl restart zabbix-agent2