原文链接:https://www.chenweiliang.com/cwl-1422.html
Monit启动监控进程消失提示monit.service failed.
在CWP控制面板(CWP7)安装Monit监控软件后,Monit启动监控进程消失,出现提示:monit.service failed.
值得注意的是,已经尝试启用过了systemctl enable monit
[root@stage-web-1 vagrant]# systemctl status monit
monit.service - Pro-active monitoring utility for unix systems
Loaded: loaded (/usr/lib/systemd/system/monit.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Thu 2017-06-01 16:37:00 UTC; 6min ago
Process: 1131 ExecStop=/usr/bin/monit quit (code=exited, status=1/FAILURE)
Process: 1079 ExecStart=/usr/bin/monit -I (code=exited, status=1/FAILURE)
Main PID: 1079 (code=exited, status=1/FAILURE)
Jun 01 16:37:00 stage-web-1 systemd[1]: Started Pro-active monitoring utility for unix systems.
Jun 01 16:37:00 stage-web-1 systemd[1]: Starting Pro-active monitoring utility for unix systems...
Jun 01 16:37:00 stage-web-1 monit[1079]: Error opening the log file '/var/www/html/nfs/monit/stage-web-1.log' for writing -- No such file or directory
Jun 01 16:37:00 stage-web-1 systemd[1]: monit.service: main process exited, code=exited, status=1/FAILURE
Jun 01 16:37:00 stage-web-1 monit[1131]: Error opening the log file '/var/www/html/nfs/monit/stage-web-1.log' for writing -- No such file or directory
Jun 01 16:37:00 stage-web-1 systemd[1]: monit.service: control process exited, code=exited status=1
Jun 01 16:37:00 stage-web-1 systemd[1]: Unit monit.service entered failed state.
Jun 01 16:37:00 stage-web-1 systemd[1]: monit.service failed.
事实说明,它/var/www/html/nfs
是通过NFS安装到网络驱动器的文件夹。
Monit是在NFS之前启动的,因此该文件夹尚不存在,从而导致monit错误Error opening the log file '/var/www/html/nfs/monit/stage-web-1.log' for writing -- No such file or directory
。
如何解决Monit启动监控进程消失monit.service failed.?
解决方法是编辑/lib/systemd/system/monit.service
:
[Unit]
Description=Pro-active monitoring utility for unix systems
After=network.target
[Service]
Type=simple
ExecStart=/usr/bin/monit -I
ExecStop=/usr/bin/monit quit
ExecReload=/usr/bin/monit reload
[Install]
WantedBy=multi-user.target
并添加nfs.service
到该After
后面。最终结果如下所示:
[Unit]
Description=Pro-active monitoring utility for unix systems
After=network.target nfs.service
[Service]
Type=simple
ExecStart=/usr/bin/monit -I
ExecStop=/usr/bin/monit quit
ExecReload=/usr/bin/monit reload
[Install]
WantedBy=multi-user.target
Monit监控程序现在可以在启动时,成功启动了。
欢迎转载《解决Monit启动监控进程消失monit.service failed.》
陈沩亮版权所有,转载请注明出处链接:https://www.chenweiliang.com/cwl-1422.html
网站地址:https://www.chenweiliang.com/
欲获取更多资讯内幕和秘技,欢迎进入Telegram频道:cwlboke
没有评论:
发表评论