
systemd(chkconfig 등) 없이 이를 구현하는 방법은 무엇입니까?
PostgreSQL, Mongod, RabbitMQ를 다시 시작하고 싶습니다.
답변1
서비스 자동 복구를 수행하려면 을 사용할 수 있습니다 monit
. 상당히 가볍고 사용하기 쉬운 서비스입니다.
데비안에 설치하려면 다음을 수행하십시오.
sudo apt-get install monit
/etc/monit/monitrc
구성하는 경우 서비스를 편집 하고 다시 시작합니다.
예를 들어 데몬이 실행 중인지, 서비스가 해당 포트에서 응답하는지 모니터링하고 PostgreSQL, RabbitMQ 및 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
더 많은 서비스를 보려면 다음을 참조하세요.모니트 위키
Monit을 사용하면 규칙에 따라 이메일을 보내고 서버 로드를 수행할 수도 있습니다. 누구에게나 더 잘 조사하라고 조언하고 싶습니다.
답변2
RedHat 6 사용갑자기 나타나다초기화 시스템으로.
/etc/init
(참고: NOT ) 에서 적절한 초기화 정의를 생성해야 합니다 /etc/init.d
.
예(그러나 디버깅이 필요할 수 있음)/etc/init/myservice
start on runlevel [2345]
stop on runlevel [S016]
respawn
exec /code/to/program
값 이 종료되면 다시 시작 respawn
됩니다 .program