CentOS7 二进制安装 zabbix_agent 5.0
环境准备
关闭防火墙和selinux
#关闭selinux
[root@centos7 ~]#sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
#关闭防火墙
[root@centos7 ~]#systemctl disable --now firewalld
#重启生效
[root@centos7 ~]#reboot
1. 安装zabbix rpm源
[root@centos7 ~]#rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@centos7 ~]#sed -i 's#http://repo.zabbix.com#https://mirrors.aliyun.com/zabbix#' /etc/yum.repos.d/zabbix.repo
[root@centos7 ~]#yum clean all
2. 安装zabbix agent
[root@centos7 ~]#yum install -y zabbix-agent
#编辑配置文件 /etc/yum.repos.d/zabbix.repo
[root@centos7 ~]#vim /etc/yum.repos.d/zabbix.repo
[zabbix-frontend]
...
enabled=1
...
3. 修改zabbix agent配置文件
[root@centos7 ~]#vim /etc/zabbix/zabbix_agentd.conf
Server=10.0.0.17 #指向当前zabbix server
ListenPort=10050 #监听端口
ListenIP=0.0.0.0 #监听IP
StartAgents=5 #被动状态时,默认启动的实例(进程数),0为不监听任何端口
Hostname=10.0.0.7 #区分大小写且在zabbix server唯一的值
[root@centos7 ~]#grep "^[a-Z]" /etc/zabbix/zabbix_agentd.conf
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=10.0.0.17
ListenPort=10050
ListenIP=0.0.0.0
StartAgents=5
ServerActive=127.0.0.1
Hostname=10.0.0.7
Include=/etc/zabbix/zabbix_agentd.d/*.conf
4 启动Zabbix agent进程
#启动Zabbix agent进程,并设置开机自启
[root@centos7 ~]#systemctl restart zabbix-agent.service
[root@centos7 ~]#systemctl enable zabbix-agent.service
[root@centos7 ~]#systemctl status zabbix-agent.service
● zabbix-agent.service - Zabbix Agent
Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; vendor preset: disabled)
Active: active (running) since Mon 2022-06-27 17:03:16 CST; 19min ago
Main PID: 2306 (zabbix_agentd)
CGroup: /system.slice/zabbix-agent.service
├─2306 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
├─2307 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
├─2308 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
├─2309 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
├─2310 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
├─2311 /usr/sbin/zabbix_agentd: listener #4 [waiting for connection]
├─2312 /usr/sbin/zabbix_agentd: listener #5 [waiting for connection]
└─2313 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
Jun 27 17:03:16 centos7 systemd[1]: Starting Zabbix Agent...
Jun 27 17:03:16 centos7 systemd[1]: Started Zabbix Agent.
#验证Zabbix agent进程是否存在
[root@centos7 ~]#ss -ntlp
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:10050 *:*users:(("zabbix_agentd",pid=2313,fd=4),("zabbix_agentd",pid=2312,fd=4),("zabbix_agentd",pid=2311,fd=4),("zabbix_agentd",pid=2310,fd=4),("zabbix_agentd",pid=2309,fd=4),("zabbix_agentd",pid=2308,fd=4),("zabbix_agentd",pid=2307,fd=4),("zabbix_agentd",pid=2306,fd=4))
LISTEN 0 128 *:22 *:*users:(("sshd",pid=1302,fd=3))
LISTEN 0 100 127.0.0.1:25 *:*users:(("master",pid=1395,fd=13))
LISTEN 0 128 [::]:22 [::]:*users:(("sshd",pid=1302,fd=4))
LISTEN 0 100 [::1]:25 [::]:*users:(("master",pid=1395,fd=14))
[root@centos7 ~]#ps -ef | grep zabbix_agentd
root 1798 1566 0 15:57 pts/0 00:00:02 vim /etc/zabbix/zabbix_agentd.conf
zabbix 2306 1 0 17:03 ? 00:00:00 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 2307 2306 0 17:03 ? 00:00:00 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
zabbix 2308 2306 0 17:03 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
zabbix 2309 2306 0 17:03 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
zabbix 2310 2306 0 17:03 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
zabbix 2311 2306 0 17:03 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #4 [waiting for connection]
zabbix 2312 2306 0 17:03 ? 00:00:00 /usr/sbin/zabbix_agentd: listener #5 [waiting for connection]
zabbix 2313 2306 0 17:03 ? 00:00:00 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]
root 2401 2179 0 17:25 pts/1 00:00:00 grep --color=auto zabbix_agentd
5. zabbix web界面添加被监控主机
点击【配置-主机-创建主机】
#【ZBX】绿色,表示主机可用,监控指标检查已成功,zabbix server对zabbix agent有权限进行数据采集并且当前通信正常
经过一段时间的数据采集后,就可以看到数据了
6. 在zabbix server主机上安装Zabbix get命令行工具
#Zabbix get是一个命令行应用,它可以用于与Zabbix agent进行通信,并从Zabbix agent那里获取所需的信息。
该应用通常被用于Zabbix agent故障排错。
[root@centos7 ~]#yum list all |grep zabbix-get
zabbix-get.x86_64 5.0.24-1.el7 zabbix
[root@centos7 ~]#yum -y install zabbix-get.x86_64
[root@centos7 ~]#/bin/zabbix_get -s 10.0.0.7 -p 10050 -k "agent.ping"
1
文章评论