Назад | Перейти на главную страницу

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 frank@avalonnet.com
Does not exist notification is sent to tom@avalonnet.com
'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?

/usr/sbin/apachectl start неправильно устанавливает файл PID для httpd.

Поскольку ваш файл конфигурации Monit отслеживает процесс через /var/run/httpd.pid, вам действительно стоит использовать /etc/init.d/httpd start в качестве стартовой программы.

Если вам нужны дополнительные параметры, вы можете поместить их в другой файл конфигурации. Это частично зависит от того, какую версию Linux вы используете.