monit-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Question about monitrc file.


From: Jovan Kostovski
Subject: Re: Question about monitrc file.
Date: Wed, 29 Aug 2007 20:57:37 +0200

On 8/28/07, address@hidden <address@hidden> wrote:
> Ok, and if i want to switch between the 2 nodes ? How can i do ?
> "When problems appear on active node it will ask the standby to take over the
> resources, and the failover is made."
>
> How to configure monit to do that ? on my config, monit can restart a stopped
> service, but if the service failed to start, the service is declared as "timed
> out" and....nothing, the node is always primary...do you follow me ?

Hi VIanney,

Sorry for the late reply but I've been busy :(

What monit can do is start, stop, restart and if the service fails to
start several
times its marked as timedout. That's were heartbeat steps in. When
some service can not start heartbeat will detect that the service
can't be started and will ask
the other node to take over the resources.

Here is a good example of configuring monit + heartbeat:
http://linux.die.net/man/1/monit
It will give better preview of the setup that I'm talking about.

You just need to change the monitrc file to look like the following
(monit+heartbeat+drbd = monitoring the mounted filesystem + mysql +apache):

check process postfix with pidfile /var/spool/postfix/pid/master.pid

  start program = "/etc/init.d/postfix start"

  stop program  = "/etc/init.d/postfix stop"

  mode  active

  group local



check process heartbeat with pidfile /var/run/heartbeat.pid

  start program = "/etc/init.d/heartbeat start"

  stop  program = "/etc/init.d/heartbeat stop"

  mode  active

  group local



check device fs with path /dev/drbd0

  start program  = "/etc/ha.d/resource.d/ha-fs start"

  stop program  = "/etc/ha.d/resource.d/ha-fs stop"

  if failed permission 660 then unmonitor

  if failed uid root then unmonitor

  if failed gid root then unmonitor

  if space usage > 80% then alert

  if space usage > 99% then stop

  mode  manual

  group cluster



check process mysql with pidfile /var/lib/mysql/mysqld.pid

  start program = "/etc/ha.d/resource.d/ha-mysql start"

  stop program  = "/etc/ha.d/resource.d/ha-mysql stop"

  if failed host localhost port 3306 then restart

  if 5 restarts within 5 cycles then timeout

  mode  manual

  group cluster

  depends on fs



check process apache with pidfile /var/run/httpd2.pid

  start program = "/etc/ha.d/resource.d/ha-apache start"

  stop program  = "/etc/ha.d/resource.d/ha-apache stop"

  if failed host myhost.com port 80

    protocol HTTP request "/monit/token" then restart

  if cpu is greater than 60% for 2 cycles then alert

  if cpu > 80% for 5 cycles then restart

  if children > 250 then restart

  if loadavg(5min) greater than 10 for 8 cycles then stop

  if 5 restarts within 5 cycles then timeout

  mode  manual

  group cluster

  depends on mysql

----------------------------------------------------------------------

There are two groups:
local (postfix + hearbeat) and
cluster (drbd + mysql + apache)

All the services that are montored by heartbeat (the wrapper shell
scripts) should be added in /etc/ha.d/resource.d. What ever you put
and start from that location
will be monitored by heartbeat, so whenever one of the services from
the cluster group will fail to start for several times, heartbeat will
take over and will exec failover.

You should specify the hostaname and the IP address in the
/etc/ha.d/haresources as well.

For more info on configuring heartbeat check http://www.linux-ha.org/

I hope the thins are much more clear now ;)

BR, Jovan




reply via email to

[Prev in Thread] Current Thread [Next in Thread]