Masato Taruishi
taru****@users*****
2004年 10月 14日 (木) 18:50:46 JST
=================================================================== RCS file: ultrapossum/module/failover/11failover,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ultrapossum/module/failover/11failover 2004/10/13 11:00:07 1.15 +++ ultrapossum/module/failover/11failover 2004/10/14 09:50:46 1.16 @@ -22,6 +22,11 @@ if test "x$cache" = "x"; then +if test "x$PIDTICK" = "x1 2 3 4 5 6 7 8 9 10"; then + PIDTICK="" +fi +PIDTICK=$(ultrapossum_getconf PIDTICK "1 2 3 4 5 6 7 8 9 10 10 10 10 10 10 10") + # Virtual IP VIRTUAL=$(ultrapossum_getconf VIRTUAL $VIRTUAL) @@ -131,13 +136,13 @@ if test "x$ULTRAPOSSUM_MODULE_FAILOVER" = "xinstalled"; then wait_master_service() { - $MODULEDIR/server/pid wait $SLAPD_PIDFILE + $MODULEDIR/server/pid -t "$PIDTICK" wait $SLAPD_PIDFILE echo -n " `basename $SLAPD`" if test "x$SLURPDSLAVES" != "x"; then - $MODULEDIR/server/pid wait $SLURPD_PIDFILE + $MODULEDIR/server/pid -t "$PIDTICK" wait $SLURPD_PIDFILE echo -n " `basename $SLURPD`" fi - $MODULEDIR/server/pid wait $MONPIDFILE + $MODULEDIR/server/pid -t "$PIDTICK" wait $MONPIDFILE echo -n " mon" } @@ -177,7 +182,7 @@ fi fi /etc/init.d/heartbeat start | grep ERROR 1>&2 && exit 1 - $MODULEDIR/server/pid wait $HAPIDFILE + $MODULEDIR/server/pid -t "$PIDTICK" wait $HAPIDFILE echo -n "heartbeat" if test "x$HOST" = "x$MASTER"; then if test "x$HEARTBEAT_NICE_FAILBACK" = "x" || test "x$HEARTBEAT_AUTO_FAILBACK" != "xoff"; then @@ -203,14 +208,14 @@ fi /etc/init.d/heartbeat stop | grep ERROR 1>&2 && exit 1 if test "x$HOST" = "x$MASTER"; then - $MODULEDIR/server/pid stop $HAPIDFILE + $MODULEDIR/server/pid -t "$PIDTICK" stop $HAPIDFILE if test `ldapmaster_status` = "running"; then echo -n " W: master running even though heartbeat stop " 1>&2 ldapmaster_stop else if test "`$MODULEDIR/server/pid status $MONPIDFILE`" = "running"; then echo -n " W: mon running even though heartbeat stop " 1>&2 - $MODULEDIR/server/pid stop $MONPIDFILE + $MODULEDIR/server/pid -t "$PIDTICK" stop $MONPIDFILE fi echo -n "mon" if test "$slurpd_running" = "1"; then @@ -241,7 +246,7 @@ install -d $SLURPDRPLDIR $SHAREDIR/envexec $SLURPD -d $SLURPD_DEBUGLEVEL -f $ULTRAPOSSUM_MASTER_SLAPD_CONF -t $SLURPDRPLDIR $SLURPD_EXTRA_ARGS & echo $! > $SLURPD_PIDFILE - $MODULEDIR/server/pid wait $SLURPD_PIDFILE + $MODULEDIR/server/pid -t "$PIDTICK" wait $SLURPD_PIDFILE echo -n " `basename $SLURPD`" } =================================================================== RCS file: ultrapossum/module/failover/11recovery,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- ultrapossum/module/failover/11recovery 2004/10/12 06:10:38 1.1 +++ ultrapossum/module/failover/11recovery 2004/10/14 09:50:46 1.2 @@ -28,6 +28,8 @@ set -ex fi +# Adding an entry while the replication is stopped + $MODULEDIR/server/startup slurp_stop cat >$TMPFILE <<EOF @@ -35,25 +37,55 @@ objectClass: top objectClass: organizationalUnit ou: add + EOF ldapadd -x -h $LDAPMASTER -D $ROOTDN -w $ROOTPW -f $TMPFILE +# Now taking over starting + date $MODULEDIR/server/startup stop +# Checki whether the previous addition is availble + +for host in $SLAVES +do + ( for i in $PIDTICK + do + echo "Checking for $host..." + ldapsearch -x -w $ROOTPW -LLL -D $ROOTDN -h $host -b $TESTSUFFIX ou=add | diff -c $TMPFILE - && exit 0 + sleep $i + done + exit 1 + ) || exit 1 +done + +# Simple recovery OK. + +# Now deleting the entry on the backup server + ( - for i in 1 2 3 4 5 6 7 8 9 10 10 - do - if ldapsearch -x -w $ROOTPW -LLL -D $ROOTDN -h $BACKUP -b $TESTSUFFIX ou=add | diff -c $TMPFILE -; then - exit 0 - fi - sleep $i - done - exit 1 + for i in $PIDTICK + do + if ldapdelete -x -h $BACKUP -D $ROOTDN -w $ROOTPW ou=add,$TESTSUFFIX; then + exit 0 + fi + sleep $i + done + exit 1 ) || exit 1 -date + +# Failback $MODULEDIR/server/startup start + + +# Now we check for the slurpd.status file handling + +if ldapsearch -x -w $ROOTPW -LLL -D $ROOTDN -h $BACKUP -b $TESTSUFFIX ou=add | grep ou=add; then + echo "E: ou=add,$TESTSUFFIX should be deleted on $BACKUP" 1>&2 + exit $NG +fi exit $OK =================================================================== RCS file: ultrapossum/module/failover/recovery,v retrieving revision 1.11 retrieving revision 1.12 diff -u -r1.11 -r1.12 --- ultrapossum/module/failover/recovery 2004/10/14 02:12:25 1.11 +++ ultrapossum/module/failover/recovery 2004/10/14 09:50:46 1.12 @@ -89,7 +89,19 @@ } +status() { + echo "$SLURPDSTATUSFILE:" 1>&2 + cat $SLURPDSTATUSFILE + echo "$ANOTHER_SLURPDSTATUSFILE:" 1>&2 + cat $ANOTHER_SLURPDSTATUSFILE + if test -f "$WORK_SLURPDSTATUSFILE"; then + echo "$WORK_SLURPDSTATUSFILE:" 1>&2 + cat $WORK_SLURPDSTATUSFILE + fi +} + check_replog +status if test -d "$WORKDIR"; then if test "`$MODULEDIR/server/startup status`" = "stopped"; then $MODULEDIR/server/startup slave_start @@ -99,11 +111,15 @@ $SHAREDIR/envexec $SLURPD -d $SLURPD_DEBUGLEVEL -o -f $CONFDIR/recovery.conf -r $WORK_SLURPDREPLOGFILE -t $WORKDIR > $WORKDIR/slurpd.log 2>&1 echo "done" 1>&2 grep request $WORKDIR/slurpd.log | grep done | tail -1 1>&2 + status echo -n "Updating $HOST replogs... " 1>&2 - /bin/cp /dev/null $REPLOGFILE - /bin/cp $WORK_SLURPDREPLOGFILE $SLURPDREPLOGFILE - /bin/cp $ANOTHER_SLURPDSTATUSFILE $WORK_SLURPDSTATUSFILE + /bin/grep -v $HOST $ANOTHER_SLURPDSTATUSFILE > $WORK_SLURPDSTATUSFILE.$$ || true + /bin/cat $WORK_SLURPDSTATUSFILE >> $WORK_SLURPDSTATUSFILE.$$ + /bin/mv $WORK_SLURPDSTATUSFILE.$$ $ANOTHER_SLURPDSTATUSFILE + /bin/cp /dev/null $REPLOGFILE + /bin/cp $WORK_SLURPDREPLOGFILE $SLURPDREPLOGFILE echo "done" 1>&2 + status echo "Log: $WORKDIR" 1>&2 fi