96 |
the MONIT HTTPD section below. |
the MONIT HTTPD section below. |
97 |
|
|
98 |
B<reload> |
B<reload> |
99 |
Will reinitialize running monit daemon, specifically |
Reinitialize a running monit daemon, the daemon will |
100 |
it will reread its configuration, close and reopen |
reread its configuration, close and reopen log files. |
|
log files. |
|
101 |
|
|
102 |
B<restart> |
B<restart> |
103 |
Stop and start all programs. If the group option is |
Stop and start I<all> programs. If the group option is |
104 |
set, only restart the programs in the named group. |
set, only restart the programs in the named group. |
105 |
|
|
106 |
B<restart name> |
B<restart name> |
180 |
is stopped. |
is stopped. |
181 |
|
|
182 |
Normally it's not necessary to consider the location of the lock |
Normally it's not necessary to consider the location of the lock |
183 |
file but in certain very special situations, you may need to |
file but in certain special situations, you may need to control |
184 |
control the location. For instance if you run monit as root on |
the location. For instance if you run monit as root on two |
185 |
two different machines but with the same file system you will |
different machines but with the same file system you will need to |
186 |
need to change the location of the monit lock file via the I<-p> |
set the location of the monit lock file explicit per monit daemon |
187 |
option. You can also set the location of the lock file on a more |
via the I<-p> option. You can also set the location of the lock |
188 |
permanent basis via this global set-statement in a monitrc |
file on a more permanent basis via this global set-statement in a |
189 |
control file: (keywords are in capital) |
monitrc control file: (keywords are in capital) |
190 |
|
|
191 |
SET PIDFILE {pidfile} |
SET PIDFILE {pidfile} |
192 |
|
|
262 |
specifically B<not> try to fix a problem, but it will still raise |
specifically B<not> try to fix a problem, but it will still raise |
263 |
alerts in case of a problem. |
alerts in case of a problem. |
264 |
|
|
265 |
For clustered environments there is also a I<manual> mode. In |
For use in clustered environments there is also a I<manual> |
266 |
this mode, monit will enter I<active> mode only if a service was |
mode. In this mode, monit will enter I<active> mode only if a |
267 |
started under monit's control, for example by: |
service was started under monit's control, for example by: |
268 |
|
|
269 |
monit start sybase |
monit start sybase |
270 |
|
|
283 |
|
|
284 |
monit will not monitor the service at all. This allows for having |
monit will not monitor the service at all. This allows for having |
285 |
services configured in monitrc and start it with monit only if it |
services configured in monitrc and start it with monit only if it |
286 |
should run. This could be used for building simple failsafe |
should run. This can be used to build simple failsafe |
287 |
clusters. For instance, using the I<heartbeat> system |
clusters. For instance, using the I<heartbeat> system |
288 |
(http://linux-ha.org/) to watch the health of nodes and in the |
(http://linux-ha.org/) to watch the health of nodes and in case |
289 |
case of one machine failure start services on a secondary node. |
of one machine failure start services on a secondary node. See |
290 |
See section bellow for more informations. |
section bellow for more informations. |
291 |
|
|
292 |
|
|
293 |
|
|
294 |
=head2 Monit with Heartbeat |
=head2 Monit with Heartbeat |
295 |
|
|
296 |
The first thing you have to do is install and configure |
The first thing to do is to install and configure I<heartbeat> |
297 |
I<heartbeat> (http://www.linux-ha.org/downloads) . |
(http://www.linux-ha.org/downloads). It can be useful to have a |
298 |
The Getting Started Guide is very usefull for this task |
look at The Heartbeat Getting Started Guide at: |
299 |
(http://www.linux-ha.org/download/GettingStarted.html). |
http://www.linux-ha.org/download/GettingStarted.html. |
300 |
|
|
301 |
B<Starting up a Node> |
B<Starting up a Node> |
302 |
|
|
303 |
This is the normal start sequence for a cluster-node. |
This is the normal start sequence for a cluster-node. With this |
304 |
With this sequence, there should be no error-case, which is not |
sequence, there should be no error-case, which is not handled |
305 |
handled either by heartbeat or monit. For example, if monit |
either by heartbeat or monit. For example, if monit dies, initd |
306 |
dies, initd restart it. If heatbeat dies, monit restart it. If |
restarts it. If heatbeat dies, monit restarts it. If the node |
307 |
the node dies, heartbeat on the other node dedect it and restart |
dies, the heartbeat instance on the other node detects it and |
308 |
the services there. |
restart the services there. |
309 |
|
|
310 |
1) initd starts monit with group local |
1) initd starts monit with group local |
311 |
2) monit starts heartbeat in local group |
2) monit starts heartbeat in local group |
314 |
|
|
315 |
B<Monit F</etc/monitrc>> |
B<Monit F</etc/monitrc>> |
316 |
|
|
317 |
This sample describe a cluster with 2 nodes. |
This example describe a cluster with 2 nodes. Services running on |
318 |
Services running on Node 1 are in group I<node1>, Node 2 services |
Node 1 are in the group I<node1> and Node 2 services are in the |
319 |
are in I<node2>. |
group I<node2>. |
320 |
|
|
321 |
The local group entries are mode I<active>, the node group |
The local group entries are mode I<active>, the node group |
322 |
entries are mode I<manual> and controlled by heartbeat |
entries are mode I<manual> and controlled by heartbeat. |
323 |
|
|
324 |
|
|
325 |
# |
# |
326 |
# local services on every host |
# local services on every host |
327 |
# |
# |
|
# |
|
328 |
check heartbeat with pidfile /var/run/heartbeat.pid |
check heartbeat with pidfile /var/run/heartbeat.pid |
329 |
start program = "/etc/init.d/heartbeat start" |
start program = "/etc/init.d/heartbeat start" |
330 |
stop program = "/etc/init.d/heartbeat start" |
stop program = "/etc/init.d/heartbeat start" |
331 |
mode active |
mode active |
332 |
alert foo@bar |
alert foo@bar |
333 |
group local |
group local |
334 |
# |
|
|
# |
|
335 |
check postfix with pidfile /var/spool/postfix/pid/master.pid |
check postfix with pidfile /var/spool/postfix/pid/master.pid |
336 |
start program = "/etc/init.d/postfix start" |
start program = "/etc/init.d/postfix start" |
337 |
stop program = "/etc/init.d/postfix stop" |
stop program = "/etc/init.d/postfix stop" |
338 |
mode active |
mode active |
339 |
alert foo@bar |
alert foo@bar |
340 |
group local |
group local |
341 |
|
|
342 |
# |
# |
343 |
# node1 services |
# node1 services |
344 |
# |
# |
345 |
|
|
346 |
check apache with pidfile /var/apache/logs/httpd.pid |
check apache with pidfile /var/apache/logs/httpd.pid |
347 |
start program = "/etc/init.d/apache start" |
start program = "/etc/init.d/apache start" |
348 |
stop program = "/etc/init.d/apache stop" |
stop program = "/etc/init.d/apache stop" |
350 |
alert foo@bar |
alert foo@bar |
351 |
mode manual |
mode manual |
352 |
group node1 |
group node1 |
353 |
# |
|
|
# |
|
354 |
check named with pidfile /var/tmp/named.pid |
check named with pidfile /var/tmp/named.pid |
355 |
start program = "/etc/init.d/named start" |
start program = "/etc/init.d/named start" |
356 |
stop program = "/etc/init.d/named stop" |
stop program = "/etc/init.d/named stop" |
357 |
alert foo@bar |
alert foo@bar |
358 |
mode manual |
mode manual |
359 |
group node1 |
group node1 |
360 |
|
|
361 |
# |
# |
362 |
# node2 services |
# node2 services |
363 |
# |
# |
364 |
|
|
365 |
check named-slave with pidfile /var/tmp/named-slave.pid |
check named-slave with pidfile /var/tmp/named-slave.pid |
366 |
start program = "/etc/init.d/named-slave start" |
start program = "/etc/init.d/named-slave start" |
367 |
stop program = "/etc/init.d/named-slave stop" |
stop program = "/etc/init.d/named-slave stop" |
368 |
mode manual |
mode manual |
369 |
alert foo@bar |
alert foo@bar |
370 |
group node2 |
group node2 |
371 |
# |
|
|
# |
|
372 |
check squid with pidfile /var/squid/logs/squid.pid |
check squid with pidfile /var/squid/logs/squid.pid |
373 |
start program = "/etc/init.d/squid start" |
start program = "/etc/init.d/squid start" |
374 |
stop program = "/etc/init.d/squid stop" |
stop program = "/etc/init.d/squid stop" |
377 |
mode manual |
mode manual |
378 |
group node2 |
group node2 |
379 |
|
|
380 |
|
|
381 |
B<initd F</etc/inittab>> |
B<initd F</etc/inittab>> |
382 |
|
|
383 |
Monit is started on both nodes with initd. You have to add a |
Monit is started on both nodes with initd. You will need to add |
384 |
entry in F</etc/inittab> starting monit with the local group, |
an entry in F</etc/inittab> to start monit with the same local |
385 |
where heartbeat is member of. |
group heartbeat is member of. |
386 |
|
|
387 |
#/etc/inittab |
#/etc/inittab |
388 |
mo:2345:respawn:/usr/local/bin/monit -i -d 10 -c /etc/monitrc -g local |
mo:2345:respawn:/usr/local/bin/monit -i -d 10 -c /etc/monitrc -g local |
389 |
|
|
390 |
B<heartbeat F</etc/ha.d/haresources>> |
B<heartbeat F</etc/ha.d/haresources>> |
391 |
|
|
392 |
When heartbeat starts, heartbeat lookup for the node entry and |
When heartbeat starts, heartbeat look up the node entry and start |
393 |
start the script F</etc/init.d/monit-node1> or |
the script F</etc/init.d/monit-node1> or |
394 |
F</etc/init.d/monit-node2>. The script calls monit |
F</etc/init.d/monit-node2>. The script calls monit to start the |
395 |
to start the node specific group. |
specific group per node. |
396 |
|
|
397 |
# /etc/ha.d/haresources |
# /etc/ha.d/haresources |
398 |
node1 IPaddr::172.16.100.1 monit-node1 |
node1 IPaddr::172.16.100.1 monit-node1 |
403 |
|
|
404 |
#!/bin/bash |
#!/bin/bash |
405 |
# |
# |
406 |
# sample script for starting/stopping all services for node1 |
# sample script for starting/stopping all services on node1 |
407 |
# |
# |
408 |
prog="/usr/local/bin/monit -g node1" |
prog="/usr/local/bin/monit -g node1" |
409 |
start() |
start() |
416 |
stop() |
stop() |
417 |
{ |
{ |
418 |
echo -n $"Stopping $prog:" |
echo -n $"Stopping $prog:" |
419 |
$prog stop> |
$prog stop |
420 |
echo |
echo |
421 |
} |
} |
422 |
|
|
1389 |
system load average over a number of cylces. If |
system load average over a number of cylces. If |
1390 |
the compare expression matches then the action |
the compare expression matches then the action |
1391 |
start, alert or stop is avtivated. |
start, alert or stop is avtivated. |
|
|
|
1392 |
depends (on) Must be followed by the name of a process this |
depends (on) Must be followed by the name of a process this |
1393 |
process depends on to run before it starts. |
process depends on to run before it starts. |
1394 |
|
|