[DRBD-user] DRBH/HeartBeat and CROND

Lars Ellenberg lars.ellenberg at linbit.com
Wed Aug 22 15:55:26 CEST 2007

Note: "permalinks" may not be as permanent as we would like,
direct links of old sources may well be a few messages off.


On Wed, Aug 22, 2007 at 12:55:39PM +0100, Rui Meireles wrote:
> 
> Hi there.
> 
> I've sucessfully installed DRBD and HeartBeat in 2 servers using a
> Primary/Secondary configuration.
> 
> I'm using Heartbeat to start/stop some services, as NFS, HTTPD, MYSQLD ...
> I use several perl scripts that I created, and they are called at certain
> times of the day by the crontab of 2 users: "root" and "user1".
> 
> I'm tempted to use HeartBeat to start/stop service CROND, so only the
> PRIMARY runs the scripts. However, I'm afraid that stopping the CROND in the
> SECONDARY will stop some important services, such as rotating log files. Is
> this safe?
> 
> Is there any way for me to start/stop ONLY the "root crontab" and the "user1
> crontab" with heartbeat?

(just an example!)

assume you have a cronjob
/etc/cron.d/who-is-primary
which contains
* * * * * /usr/local/bin/do-something.sh
where
--- /usr/local/bin/do-something.sh contains ---
#!/bin/bash
source /usr/local/bin/only-on-primary.sh

# do something...
echo $HOSTNAME is primary...
-----------------------------------------------
and
------ only-on-primary.sh ---------------------
# only an example, you may want to change to grep only for
# grep -q '^ 0: .* st:Primary'
if ! grep -q '^ 0: cs:Connected st:Primary/Secondary ld:Consistent' /proc/drbd;
then
	exit 0
fi
-----------------------------------------------

similarly, if you have something that you want to be executed only on
the secondary, and only if it is a _consistent_ _uptodate_ copy
(e.g. when you want to snapshot and drive a backup from the secondary),
grep for '^0 : cs:Connected st:Secondary/Primary ld:Consistent'

hth,

-- 
: Lars Ellenberg                            Tel +43-1-8178292-0  :
: LINBIT Information Technologies GmbH      Fax +43-1-8178292-82 :
: Vivenotgasse 48, A-1120 Vienna/Europe    http://www.linbit.com :
__
please use the "List-Reply" function of your email client.



More information about the drbd-user mailing list