服务器重启之后,zabbix-agent服务无法启动

安装的时候因为添加过开机自启的,但是这次服务器重启之后,zabbix-agent端没有自动启动,然后我手动启动zabbix-agent
查看服务状态:systemctl status zabbix-agent

[root@ly~]# systemctl status zabbix-agent    
● zabbix-agent.service - LSB: Start and stop Zabbix agent
   Loaded: loaded  (/etc/rc.d/init.d/zabbix-agent; bad; vendor preset: disabled)
   Active: active (exited) since 三 2018-06-27 15:31:07 CST; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 26022 ExecStop=/etc/rc.d/init.d/zabbix-agent stop (code=exited, status=0/SUCCESS)
  Process: 26038 ExecStart=/etc/rc.d/init.d/zabbix-agent start (code=exited, status=0/SUCCESS)
627 15:31:07 ly systemd[1]: Starting LSB: Start and stop Zabbix agent...
627 15:31:07 ly zabbix-agent[26038]: Starting Zabbix agent: [  确定  ]
627 15:31:07 ly systemd[1]: Started LSB: Start and stop Zabbix agent.

重启Zabbix-agent服务:systemctl restart zabbix-agent

[root@ly ~]# systemctl restart zabbix-agent 
[root@ly ~]# systemctl status zabbix-agent    
● zabbix-agent.service - LSB: Start and stop Zabbix agent
   Loaded: loaded  (/etc/rc.d/init.d/zabbix-agent; bad; vendor preset: disabled)
   Active: active (exited) since 三 2018-06-27 15:31:07 CST; 5s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 26022 ExecStop=/etc/rc.d/init.d/zabbix-agent stop (code=exited, status=0/SUCCESS)
  Process: 26038 ExecStart=/etc/rc.d/init.d/zabbix-agent start (code=exited, status=0/SUCCESS)
627 15:31:07 ly systemd[1]: Starting LSB: Start and stop Zabbix agent...
627 15:31:07 ly zabbix-agent[26038]: Starting Zabbix agent: [  确定  ]
627 15:31:07 ly systemd[1]: Started LSB: Start and stop Zabbix agent.

重启失败
查看服务日志:cat /var/log/zabbix/zabbix_agentd.log

[root@ly ~]# cat /var/log/zabbix/zabbix_agentd.log 
  6478:20180627:142902.769 Got signal [signal:15(SIGTERM),sender_pid:3944,sender_uid:0,reason:0]. Exiting ...
  6478:20180627:142902.773 Zabbix Agent stopped. Zabbix 3.0.15 (revision 78010).
zabbix_agentd [1274]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory
zabbix_agentd [26050]: cannot create PID file [/var/run/zabbix/zabbix_agentd.pid]: [2] No such file or directory    #缺少Pid文件。

说到Pid文件,这里讲解一些 这个Pid文件的作用,
Linux下/var/run/目录下的pid文件
linux系统中/var/run/目录下的*.pid文件是一个文本文件,其内容只有一行,即某个进程的Pid。.pid文件的作用是防止进程启动多个副本,只有获得特定pid文件(固定路径和文件名)的写入权限(F_WRLCK)的进程才能正常启动并将自身的进程Pid写入该文件,其它同一程序的多余进程则自动退出。
这里zabbix因为缺少,我们可以手动创建一个

进入/var/run目录创建目录去创建一个Pid文件

[root@ly ~]# cd /var/run/
[root@ly run]# mkdir zabbix    #创建zabbix目录。
[root@ly run]# cd zabbix/
[root@ly zabbix]# touch zabbix_agentd.pid    #创建PID文件。
[root@ly run]# systemctl restart zabbix-agent    #重启Zabbix-agent服务。
[root@ly run]# systemctl status zabbix-agent    #查看服务状态,服务已经起来了。
● zabbix-agent.service - LSB: Start and stop Zabbix agent
   Loaded: loaded (/etc/rc.d/init.d/zabbix-agent; bad; vendor preset: disabled)
   Active: active (running) since 三 2018-06-27 15:32:53 CST; 7s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 26270 ExecStop=/etc/rc.d/init.d/zabbix-agent stop (code=exited, status=0/SUCCESS)
  Process: 26275 ExecStart=/etc/rc.d/init.d/zabbix-agent start (code=exited, status=0/SUCCESS)
   Memory: 2.2M
   CGroup: /system.slice/zabbix-agent.service
           ├─25272 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
           ├─25274 /usr/sbin/zabbix_agentd: collector [idle 1 sec]
           ├─25275 /usr/sbin/zabbix_agentd: listener #1 [waiting for connection]
           ├─25276 /usr/sbin/zabbix_agentd: listener #2 [waiting for connection]
           ├─25277 /usr/sbin/zabbix_agentd: listener #3 [waiting for connection]
           └─25278 /usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]

627 15:32:53 ly systemd[1]: Starting LSB: Start and stop Zabbix agent...
627 15:32:53 ly zabbix-agent[26270]: Starting Zabbix agent: [  确定  ]
627 15:32:53 ly systemd[1]: Started LSB: Start and stop Zabbix agent.
[root@ly run]# netstat -ant | grep 10050    #查看监听端口,已经监听了。
tcp        0      0 0.0.0.0:10050           0.0.0.0:*               LISTEN  

你可能感兴趣的:(服务器重启之后,zabbix-agent服务无法启动)