[DRBD-cvs] r1686 - in trunk: scripts user
svn at svn.drbd.org
svn at svn.drbd.org
Thu Dec 23 12:06:47 CET 2004
Author: phil
Date: 2004-12-23 12:06:45 +0100 (Thu, 23 Dec 2004)
New Revision: 1686
Added:
trunk/scripts/outdate-peer.sh
Modified:
trunk/scripts/drbd.conf
trunk/user/drbdmeta.c
Log:
Implemented the last missing piece for the outdate-peer
mechanism. -- Really cool!
Modified: trunk/scripts/drbd.conf
===================================================================
--- trunk/scripts/drbd.conf 2004-12-22 10:15:02 UTC (rev 1685)
+++ trunk/scripts/drbd.conf 2004-12-23 11:06:45 UTC (rev 1686)
@@ -129,7 +129,7 @@
# Commands to run in case we loose connection. Use this script in
# in conjunction with the on-disconnect=suspend_io configuration.
- # outdate-peer "/usr/lib/drbd/outdate-peer.sh";
+ outdate-peer "/usr/lib/drbd/outdate-peer.sh on amd 192.168.22.11 192.168.23.11 on alf 192.168.22.12 192.168.23.12";
}
startup {
Added: trunk/scripts/outdate-peer.sh
===================================================================
--- trunk/scripts/outdate-peer.sh 2004-12-22 10:15:02 UTC (rev 1685)
+++ trunk/scripts/outdate-peer.sh 2004-12-23 11:06:45 UTC (rev 1686)
@@ -0,0 +1,118 @@
+#!/bin/bash
+#
+# outdate-peer.sh
+# This file is part of drbd by Philipp Reisner / Lars Ellenberg.
+#
+
+#
+# It is expected that your clustermanager of choice brings its own
+# implementation of this ... E.g. Heartbeat's variant should be able
+# to use all of Heartbeat's communication pathes, including the
+# serial connections.
+#
+
+# This script requires, that there is a password less ssh-key for
+# root. You should not use such keys on a bigger scale. Only use
+# it with the "from" option!
+#
+# How to setup SSH:
+#
+# 1. ssh-keygen -t dsa (as root, on the first machine)
+# no passphrase!
+#
+# 2. go to the second machine, edit the file .ssh/authorized_keys2
+# Start a line with from="10.9.9.181,10.99.99.1" [content of id_dsa.pub]
+# Put the IPs of you first machine here, also the id_dsa.pub
+# is from the first machine All needs to be in a single line.
+#
+# 3. ssh from the first machine to the second one, do this for all
+# IP addresses of the second machine. When doing this the first
+# time it asks you if it should ad the fingerprint to the list
+# of known hosts: Say yes here.
+#
+# 4. To this a second time for each IP address, now it should not ask
+# any questions...
+#
+# Repeate this 4 steps for the other direction, BTW, you can not
+# copy the file over, since you have two distrinct keys.. and also
+# the IP addresses in the from="" part are different.
+#
+
+TIMEOUT=6
+
+for P in "$@"; do
+ if [ "$EXP_PEER_IP" = "1" ]; then
+ PEER_IP="$PEER_IP $P"
+ fi;
+ if [ "$EXP_OWN_IP" = "1" ]; then
+ OWN_IP="$OWN_IP $P"
+ fi;
+ if [ "$EXP_HOST_NAME" = "1" ]; then
+ if [ "$P" != `uname -n` ]; then
+ EXP_PEER_IP=1
+ else
+ EXP_OWN_IP=1
+ fi
+ EXP_HOST_NAME=0
+ fi
+ if [ "$P" = "on" ]; then
+ EXP_HOST_NAME=1
+ EXP_PEER_IP=0
+ EXP_OWN_IP=0
+ fi
+done
+
+if [ -z "$PEER_IP" -o -z "$OWN_IP" ]; then
+ echo "USAGE: outdate-peer.sh on host1 IP IP ... on host2 IP IP ..."
+ exit 10
+fi
+
+for IP in $PEER_IP; do
+ ssh $IP drbdadm outdate r0 &
+ SSH_PID="$SSH_PID $!"
+done
+
+
+SSH_CMDS_RUNNING=1
+while [ "$SSH_CMDS_RUNNING" = "1" ] ; do
+ sleep 1
+ SSH_CMDS_RUNNING=0
+ for P in $SSH_PID; do
+ if [ -d /proc/$P ]; then SSH_CMDS_RUNNING=1; fi
+ done
+done
+
+RV=5
+for P in $SSH_PID; do
+ if [ -d /proc/$P ]; then
+ kill $P
+ wait $P
+ else
+ wait $P
+ EXIT_CODE=$?
+
+ # exit codes of drbdmeata outdate:
+ # 5 -> is inconsistent
+ # 0 -> is outdated
+ # 20 -> outdate failed because peer is primary.
+ # Unfortunately 20 can have other reasons too....
+
+ if [ $EXIT_CODE -eq 5 ]; then RV=3; else
+ if [ $EXIT_CODE -eq 27 ]; then RV=6; else
+ if [ $EXIT_CODE -eq 0 ]; then RV=4; else
+ echo "do not know about this exit code"
+ fi
+ fi
+ fi
+ fi
+done
+
+# We return to DRBD - kernel driver:
+#
+# 6 -> peer is primary (and UpToDate)
+# 5 -> peer is down / unreachable.
+# 4 -> peer is outdated
+# 3 -> peer is inconsistent
+
+exit $RV
+
Property changes on: trunk/scripts/outdate-peer.sh
___________________________________________________________________
Name: svn:executable
+ *
Modified: trunk/user/drbdmeta.c
===================================================================
--- trunk/user/drbdmeta.c 2004-12-22 10:15:02 UTC (rev 1685)
+++ trunk/user/drbdmeta.c 2004-12-23 11:06:45 UTC (rev 1686)
@@ -1340,7 +1340,7 @@
if ( !(cfg->md.gc[Flags] & MDF_Consistent) ) {
fprintf(stderr, "Device is inconsistent.\n");
- exit(10);
+ exit(5);
}
cfg->md.gc[Flags] &= ~MDF_WasUpToDate;
More information about the drbd-cvs
mailing list