[Linux-HA] Help : DRBD,
Heartbeat (Active-Active Node configuration)
Eddie C
edlinuxguru at gmail.com
Fri Jun 1 11:39:31 MDT 2007
I did this using heartbeat V2. I am attaching a screen shot.
1. drbd (lsb) clone (clone max 2) (clone node max 1)
2. drbd_state (lsb) clone (clone max 2) (clone node max 1)
3. ocfs2 (lsb) clone (clone max 2) (clone node max 1)
I made this 'fake service' called drbd_state to turn a node from
UpToDate -- Secondary to UpToDate -- Primary . I have the feeling
there must be some config file setting to do this. If the drdb start
script would block until the system is UpToDate--Primary my middle
script would not be needed.
Used ordering to make sure they start in the correct order.
drbd_state
#!/bin/bash
# ToDo: should be able to work with only certain drbd instances. Now
is all or nothing
# chkconfig: 345 24 8
# description: Makes secondary drbd node primary if the data is uptodate
#
# Edward Capriolo
#
### BEGIN INIT INFO
# Provides: drbd_state
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Makes secondary drbd node primary if the data
is uptodate
### END INIT INFO
DEFAULTFILE="/etc/default/drbd"
DRBDADM="/sbin/drbdadm"
PROC_DRBD="/proc/drbd"
MODPROBE="/sbin/modprobe"
RMMOD="/sbin/rmmod"
UDEV_TIMEOUT=10
ADD_MOD_PARAM=""
if [ -f $DEFAULTFILE ]; then
. $DEFAULTFILE
fi
test -f $DRBDADM || exit 5
case "$1" in
start)
echo "Starting DRBD state: "
for RESOURCE in `$DRBDADM sh-resources`; do
# $DRBDADM dstate
my_dstate=`$DRBDADM dstate $RESOURCE | cut -d'/' -f1`
my_cstate=`$DRBDADM cstate $RESOURCE | cut -d'/' -f1`
my_state=`$DRBDADM state $RESOURCE | cut -d'/' -f1`
if [ "$my_dstate" = "UpToDate" ] ; then
echo "State is UpToDate"
if [ "$my_state" = "Secondary" ] ; then
echo "$RESOURCE will be promoted to primary"
$DRBDADM primary $RESOURCE
fi
else
echo "State is $my_dstate. Manual intervention required"
exit 1
fi
done
[ -d /var/lock/subsys ] && touch /var/lock/subsys/drbd_state
# for RedHat
;;
stop)
echo -n "Stopping all DRBD state resources"
[ -f /var/lock/subsys/drbd ] && rm /var/lock/subsys/drbd_state
;;
status)
# NEEDS to be heartbeat friendly...
# so: put some "OK" in the output.
for RESOURCE in `$DRBDADM sh-resources`; do
# $DRBDADM dstate
my_dstate=`$DRBDADM dstate $RESOURCE | cut -d'/' -f1`
my_cstate=`$DRBDADM cstate $RESOURCE | cut -d'/' -f1`
my_state=`$DRBDADM state $RESOURCE | cut -d'/' -f1`
if [ "$my_dstate" = "UpToDate" ] ; then
echo "State is UpToDate"
if [ "$my_state" = "Primary" ] ; then
echo "$RESOURCE is primary"
exit 0
else
echo >&2 "$RESOURCE is $my_state"
exit 3
fi
else
echo >&2 "State is $my_dstate. Manual
intervention required"
exit 3
fi
done
;;
reload)
echo "."
;;
restart|force-reload)
echo -n "Restarting is a no-op for this script"
echo "."
;;
*)
echo "Usage: /etc/init.d/drbd_state
{start|stop|status|reload|restart|force-reload}"
exit 1
;;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: drbdsetup.JPG
Type: image/jpeg
Size: 58240 bytes
Desc: not available
Url : http://lists.community.tummy.com/pipermail/linux-ha/attachments/20070601/2966b592/drbdsetup-0001.jpe
More information about the Linux-HA
mailing list