monit 无法启动 apache

monit 无法启动 apache

我正在运行 Apache,并尝试使用 Monit 对其进行监控。监控似乎运行良好,但当 Apache 关闭时,Monit 无法成功启动它。

Monit 确实检测到它已关闭,但是启动命令失败。

以下是监控配置

check process httpd with pidfile /var/run/httpd.pid
start program = "/usr/bin/apachestart start"
stop program = "/etc/init.d/httpd stop"
if failed host 127.0.0.1 port 80
protocol http then restart
if 5 restarts within 5 cycles then timeout

这是指Apache的启动脚本,其中包括以下内容:

# cat /usr/bin/apachestart
## start Apache with default settings
ulimit -l 256;
ulimit -s 56000;
/usr/sbin/apachectl start;

此脚本设置了几个参数,这些参数似乎是此特定 Apache/PHP 设置所必需的。以 root 身份从命令行运行时运行良好,但显然,对于 Monit 来说,这有点问题。

在调试模式下运行 monit 时(以“monit -Iv”启动),我得到以下信息

monit: pidfile '/var/run/httpd.pid' does not exist
'httpd' process is not running
-------------------------------------------------------------------------------
    monit [0x40de4d]
    monit(LogError+0x9f) [0x40e59f]
    monit(Event_post+0x406) [0x40ba96]
    monit(check_process+0x98) [0x41d798]
    monit(validate+0x1b3) [0x41dbf3]
    monit [0x410547]
    monit(main+0x492) [0x410d72]
    /lib64/libc.so.6(__libc_start_main+0xf4) [0x30f961d994]
    monit [0x408e39]
-------------------------------------------------------------------------------
Does not exist notification is sent to [email protected]
Does not exist notification is sent to [email protected]
'httpd' trying to restart
Monitoring disabled -- service httpd
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
'httpd' start: /usr/bin/apachestart
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
monit: pidfile '/var/run/httpd.pid' does not exist
'httpd' failed to start
-------------------------------------------------------------------------------
    monit [0x40de4d]
    monit(LogError+0x9f) [0x40e59f]
    monit(Event_post+0x406) [0x40ba96]
    monit [0x409b7a]
    monit(control_service+0xcb) [0x409d8b]
    monit [0x40b3ae]
    monit(Event_post+0x445) [0x40bad5]
    monit(check_process+0x98) [0x41d798]
    monit(validate+0x1b3) [0x41dbf3]
    monit [0x410547]
    monit(main+0x492) [0x410d72]
    /lib64/libc.so.6(__libc_start_main+0xf4) [0x30f961d994]
    monit [0x408e39]
-------------------------------------------------------------------------------
Execution failed notification is sent to ...

知道为什么 monit 无法启动 Apache 吗?

答案1

/usr/sbin/apachectl start没有正确设置 httpd 的 PID 文件。

由于您的 Monit 配置文件通过跟踪进程/var/run/httpd.pid,因此您应该真正使用它/etc/init.d/httpd start作为启动程序。

如果您需要其他参数,可以将它们放在另一个配置文件中。这部分取决于您使用的 Linux 版本。

相关内容