Zabbix Agent 需要安装到被监控的主机上,它负责定期收集各项数据,并发送到zabbix server端,zabbix server将数据存储到数据库中,zabbix web 访问数据库在前端进行展现和绘图。
安装Zabbix Agent 有三种方式
- 包安装
- 二进制安装
- 编译安装
包安装 Zabbix Agent
[root@zabbix-agent ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
[root@zabbix-agent ~]# yum clean all
[root@zabbix-agent ~]# yum install -y zabbix-agent2
[root@zabbix-agent ~]# systemctl restart zabbix-agent2.service
[root@zabbix-agent ~]# systemctl enable zabbix-agent2.service
二进制安装 Zabbix Agent
[root@zabbix-agent ~]# wget https://cdn.zabbix.com/zabbix/binaries/stable/5.0/5.0.30/zabbix_agent-5.0.30-linux-3.0-amd64-static.tar.gz
[root@zabbix-agent ~]# tar xf zabbix_agent-5.0.30-linux-3.0-amd64-static.tar.gz -C /apps/zabbix_agent/
[root@zabbix-agent ~]# tree /apps/zabbix_agent/
/apps/zabbix_agent/
├── bin
│ ├── zabbix_get
│ └── zabbix_sender
├── conf
│ ├── zabbix_agentd
│ │ ├── userparameter_examples.conf
│ │ └── userparameter_mysql.conf
│ └── zabbix_agentd.conf
└── sbin
└── zabbix_agentd
4 directories, 6 files
[root@zabbix-agent ~]# echo 'PATH=/apps/zabbix_agent/bin:/apps/zabbix_agent/sbin:$PATH' > /etc/profile.d/zabbix_agent.sh
[root@zabbix-agent ~]# . /etc/profile.d/zabbix_agent.sh
[root@zabbix-agent ~]# sed -i.bak -e "s/Server=127.0.0.1/Server=192.168.1.121/" -e "s/Hostname=Zabbix server/Hostname=192.168.1.122/" /apps/zabbix_agent/conf/zabbix_agentd.conf
[root@zabbix-agent ~]# zabbix_agentd -c /apps/zabbix_agent/conf/zabbix_agentd.conf
zabbix_agentd [1583]: user zabbix does not exist
zabbix_agentd [1583]: cannot run as root!
[root@zabbix-agent ~]# useradd zabbix
[root@zabbix-agent ~]# su - zabbix
[zabbix@zabbix-agent ~]$ zabbix_agentd -c /apps/zabbix_agent/conf/zabbix_agentd.conf
[zabbix@zabbix-agent ~]$ ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:111 *:*
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 *:10050 *:*
LISTEN 0 128 [::]:111 [::]:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 100 [::1]:25 [::]:*
[root@zabbix-agent ~]# killall zabbix_agentd
[root@zabbix-agent ~]# cat /lib/systemd/system/zabbix-agent.service
[Unit]
Description=Zabbix Agent
After=syslog.target
After=network.target
[Service]
Type=forking
Restart=on-failure
PIDFile=/tmp/zabbix_agentd.pid
KillMode=control-group
ExecStart=/apps/zabbix_agent/sbin/zabbix_agentd -c /apps/zabbix_agent/conf/zabbix_agentd.conf
ExecStop=/bin/kill -SIGTERM $MAINPID
RestartSec=10s
User=zabbix
Group=zabbix
[Install]
WantedBy=multi-user.target
[root@zabbix-agent ~]# systemctl daemon-reload
[root@zabbix-agent ~]# systemctl enable --now zabbix-agent.service
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END