遇到一个问题 zabbix-agent 一直启动不起来
查看Zabbix Agent日志文件才究其原因。
tail /var/log/zabbix/zabbix_agentd.log
zabbix_agentd [3805]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory
zabbix_agentd [3843]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory
zabbix_agentd [3918]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory
zabbix_agentd [1541]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory
zabbix_agentd [2959]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory
zabbix_agentd [3036]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory
zabbix_agentd [3153]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory
zabbix_agentd [3294]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [13] Permission denied
zabbix_agentd [3350]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [13] Permission denied
[root@localhost run]# ll
drwxr-xr-x 2 root root 40 Aug 30 16:29 zabbix
进入 var/run 目录下, 查看到 文件夹zabbix 权限为 root ,需修改权限设定 所有者为 zabbix用户。
[root@localhost run]# chown -R zabbix.zabbix zabbix (或者 chmod 777 -R zabbix)
或者修改配置文件
vim /etc/zabbix/zabbix_agentd.conf
# Default:
PidFile=/tmp/zabbix_agentd.pid
#PidFile=/var/run/zabbix/zabbix_agentd.pid
[root@localhost run]# ll
drwxr-xr-x 2 zabbix zabbix 40 Aug 30 16:29 zabbix
此时重启zabbix-agent 服务 , 可看到服务启动了
[root@localhost run]# systemctl restart zabbix-agent
[root@localhost run]# ps aux|grep zabbix
zabbix 3492 0.0 0.0 82072 1384 ? S 16:31 0:00 zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
zabbix 3494 0.0 0.0 82072 1328 ? S 16:31 0:00 zabbix_agentd: collector [idle 1 sec]
zabbix 3495 0.0 0.0 82072 1084 ? S 16:31 0:00 zabbix_agentd: listener #1 [waiting for connection]
zabbix 3496 0.0 0.0 82072 1372 ? S 16:31 0:00 zabbix_agentd: listener #2 [waiting for connection]
zabbix 3497 0.0 0.0 82072 1084 ? S 16:31 0:00 zabbix_agentd: listener #3 [waiting for connection]
zabbix 3498 0.0 0.0 82072 1408 ? S 16:31 0:00 zabbix_agentd: active checks #1 [idle 1 sec]
在 zabbix 服务器上做 测试
[root@zabbix ~]# zabbix_get -s 103.***.***. 174 -p 21224 -k system.hostname
localhost