Servicios de reinicio automático después de un accidente en rhel 6

Servicios de reinicio automático después de un accidente en rhel 6

¿Cómo implementar esto sin systemd (chkconfig, etc.)?

Me gustaría reiniciar PostgreSQL, Mongod y RabbitMQ.

Respuesta1

Para realizar la recuperación automática de servicios, puede utilizar monit. Es un servicio bastante ligero y fácil de usar.

Para instalarlo en Debian haz:

sudo apt-get install monit

Cómo instalar y configurar Monit

En cuanto a configurarlo, edita /etc/monit/monitrcy reinicia el servicio.

Por ejemplo, para monitorear si el demonio se está ejecutando y si el servicio está respondiendo en los puertos correspondientes, y configurar la recuperación automática para PostgreSQL, RabbitMQ y mongoDB:

check process postgres with pidfile /var/postgres/postmaster.pid
   group database
   start program = "/etc/init.d/postgresql start"
   stop  program = "/etc/init.d/postgresql stop"
   if failed unixsocket /var/run/postgresql/.s.PGSQL.5432 protocol pgsql 
      then restart
   if failed host 192.168.1.1 port 5432 protocol pgsql then restart

check host mongodb with address localhost
    start program = "/usr/bin/sudo /opt/database/mongo/bin/mongod"
    stop program = "/usr/bin/sudo /usr/bin/pkill -f mongod"
    if failed port 28017 protocol HTTP
        request /
        with timeout 10 seconds
        then start

check process rabbitmq-server with pidfile /var/run/rabbitmq.pid  
   group rabbitmq  
   start program "/etc/init.d/rabbitmq-server start"  
   stop program "/etc/init.d/rabbitmq-server stop"  
   if failed port 5672 type tcp then restart  
   if 3 restarts within 3 cycles then timeout  

Para más servicios, consulte:wiki de monito

Monit también te permite enviar un correo electrónico en reglas y actuando en carga del servidor. Aconsejaría a cualquiera que lo investigara mejor.

Respuesta2

Usos de Red Hat 6advenedizocomo sistema de inicio.

Debe crear una definición de inicio adecuada en /etc/init(nota: NOT /etc/init.d).

por ejemplo (pero es posible que necesite depuración)/etc/init/myservice

start on runlevel [2345]
stop on runlevel [S016]

respawn
exec /code/to/program

El respawnvalor hará programque se reinicie si finaliza.

información relacionada