zabbix-agent2启动失败报错Unit zabbix-agent2.service entered failed state.

1,用systemctl status zabbix-agent2查看报错状态

[root@c1 zabbix]# systemctl status zabbix-agent2
● zabbix-agent2.service - Zabbix Agent 2
   Loaded: loaded (/usr/lib/systemd/system/zabbix-agent2.service; disabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Tue 2024-06-25 15:46:27 CST; 8s ago
  Process: 31777 ExecStop=/bin/kill -SIGTERM $MAINPID (code=exited, status=1/FAILURE)
  Process: 31767 ExecStart=/usr/sbin/zabbix_agent2 -c $CONFFILE (code=exited, status=0/SUCCESS)
 Main PID: 31767 (code=exited, status=0/SUCCESS)

Jun 25 15:46:27 c1 systemd[1]: Unit zabbix-agent2.service entered failed state.
Jun 25 15:46:27 c1 systemd[1]: zabbix-agent2.service failed.

发现只提示说Unit zabbix-agent2.service entered failed state,这样子的报错并不清晰,具体什么原因也没说。

2,用journalctl -xe查看一下报错日志

然并卵,这个也没给出实质性有帮助的报错提示,只说 zabbix-agent2.service failed,没啥用。

[root@c1 zabbix]# journalctl -xe
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit zabbix-agent2.service has finished starting up.
-- 
-- The start-up result is done.
Jun 25 15:47:32 c1 zabbix_agent2[31899]: Starting Zabbix Agent 2 []. (5.0.42)
Jun 25 15:47:32 c1 zabbix_agent2[31899]: Press Ctrl+C to exit.
Jun 25 15:47:33 c1 zabbix_agent2[31899]: Zabbix Agent 2 stopped. (5.0.42)
Jun 25 15:47:33 c1 kill[31910]: Usage:
Jun 25 15:47:33 c1 kill[31910]: kill [options] <pid|name> [...]
Jun 25 15:47:33 c1 kill[31910]: Options:
Jun 25 15:47:33 c1 kill[31910]: -a, --all              do not restrict the name-to-pid conversion to processes
Jun 25 15:47:33 c1 kill[31910]: with the same uid as the present process
Jun 25 15:47:33 c1 kill[31910]: -s, --signal <sig>     send specified signal
Jun 25 15:47:33 c1 kill[31910]: -q, --queue <sig>      use sigqueue(2) rather than kill(2)
Jun 25 15:47:33 c1 kill[31910]: -p, --pid              print pids without signaling them
Jun 25 15:47:33 c1 kill[31910]: -l, --list [=<signal>] list signal names, or convert one to a name
Jun 25 15:47:33 c1 kill[31910]: -L, --table            list signal names and numbers
Jun 25 15:47:33 c1 kill[31910]: -h, --help     display this help and exit
Jun 25 15:47:33 c1 kill[31910]: -V, --version  output version information and exit
Jun 25 15:47:33 c1 kill[31910]: For more details see kill(1).
Jun 25 15:47:33 c1 systemd[1]: zabbix-agent2.service: control process exited, code=exited status=1
Jun 25 15:47:33 c1 systemd[1]: Unit zabbix-agent2.service entered failed state.
Jun 25 15:47:33 c1 systemd[1]: zabbix-agent2.service failed.
Jun 25 15:47:43 c1 systemd[1]: zabbix-agent2.service holdoff time over, scheduling restart.
Jun 25 15:47:43 c1 systemd[1]: Stopped Zabbix Agent 2.

3,再看一下zabbix的日志。

vim /var/log/zabbix/zabbix_agent2.log

在vim里面搜索cannoterrorfailed等关键字。这是一个非常有用的技巧。
在很多时候我们分析日志的时候,不需要每一行都去看,要学会用关键字搜索,快速找到错误位置,比如这里,我搜了以下关键字cannot,正好就在这一天的日志内容中有这个关键字,它说cannot start agent: listen unix /tmp/agent.sock: bind: permission denied

  • 翻译过来就是/tmp/agent.sock没有被赋予权限。
    在这里插入图片描述

4,错误修改

查看一下/tmp文件夹的权限,发现确实权限缺失了

[root@c1 zabbix]# ls -ld /tmp
drwxr-xr-t 8 root root 4096 Jun 25 15:42 /tmp

赋予root用户组权限

[root@c1 zabbix]# chmod 777 /tmp
[root@c1 zabbix]# chown root:root /tmp

5, 再次重启zabbix-agent2

systemctl start  zabbix-agent2
systemctl status  zabbix-agent2

在这里插入图片描述
启动成功!

  • 思路总结,记得查看日志的时候,要学会关键字搜索,并且要在当时那个时间段的日志内搜索,这样可以提高错误定位的效率。
  • 4
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值