Obliterate (DRBD fence handler): Difference between revisions

From Alteeve Wiki
Jump to navigation Jump to search
(Created page with '{{header}} This is the Red Hat <span class="code">obliterate</span> script used to let DRBD trigger a cman fenced call when a split brain is detected. This was o…')
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 2: Line 2:


This is the [[Red Hat]] <span class="code">obliterate</span> script used to let [[DRBD]] trigger a [[cman]] [[fenced]] call when a split brain is detected. This was originally found [http://gfs.wikidev.net/DRBD_Cookbook here].
This is the [[Red Hat]] <span class="code">obliterate</span> script used to let [[DRBD]] trigger a [[cman]] [[fenced]] call when a split brain is detected. This was originally found [http://gfs.wikidev.net/DRBD_Cookbook here].
Download the <span class="code">/sbin/[https://alteeve.ca/files/an-cluster/sbin/obliterate obliterate]</span> script, ~2.1[[KiB]].


<source lang="bash">
<source lang="bash">

Latest revision as of 03:21, 5 May 2013

 AN!Wiki :: Obliterate (DRBD fence handler)

This is the Red Hat obliterate script used to let DRBD trigger a cman fenced call when a split brain is detected. This was originally found here.

Download the /sbin/obliterate script, ~2.1KiB.

#!/bin/bash
# ###########################################################
# DRBD 0.8.2.1 -> linux-cluster super-simple fencing wrapper
#
# Copyright Red Hat, 2007
#
# Licensed under the GNU General Public License version 2
# which is incorporated herein by reference:
#
#   http://www.gnu.org/licenses/gpl-2.0.html
# 
# At your option, you may choose to license this software 
# under any later version of the GNU General Public License. 
#
# This software is distributed in the hopes that it will be
# useful, but without warranty of any kind.
#
# Kills the other node in a 2-node cluster.  Only works with
# 2-node clusters (FIXME?)
#
# ###########################################################
#
# Author: Lon Hohberger <lhh[a]redhat.com> 
#
# Special thanks to fabioc on freenode
#

PATH="/bin:/sbin:/usr/bin:/usr/sbin"

NODECOUNT=0
LOCAL_ID=$(cman_tool status 2>/dev/null | grep '^Node ID:' | awk '{print $3}')
REMOTE_ID=""
REMOTE=""

if [ -z "$LOCAL_ID" ]; then 
	echo "Could not determine local node ID!"
	exit 1
fi

# Shoot the other guy.
while read nid nodename; do
	if [ "$nid" = "0" ]; then 
		continue
	fi

	((NODECOUNT++))

	if [ "$nid" != "$LOCAL_ID" ]; then
		REMOTE_ID=$nid
		REMOTE=$nodename
	fi
done < <(cman_tool nodes 2>/dev/null | grep -v '^Node' | awk '{print $1,$6}')

if [ $NODECOUNT -ne 2 ]; then
	echo "Only works with 2 node clusters"
	exit 1
fi

if [ -z "$REMOTE_ID" ] || [ -z "$REMOTE" ]; then
	echo "Could not determine remote node"
	exit 1
fi

echo "Local node ID: $LOCAL_ID"
echo "Remote node ID: $REMOTE_ID"
echo "Remote node: $REMOTE "

#
# This could be cleaner by calling cman_tool kill -n <node>, but then we have
# to poll/wait for fence status, and I don't feel like writing that right
# now.  Note that GFS *will* wait for this to occur, so if you're using GFS
# on DRBD, you still don't get access. ;)
#
fence_node $REMOTE

if [ $? -eq 0 ]; then
	#
	# Reference:
	# http://osdir.com/ml/linux.kernel.drbd.devel/2006-11/msg00005.html
	#
	# 7 = node got blown away.  
	#
	exit 7
fi

#
# Fencing failed?!
#
exit 1

 

Any questions, feedback, advice, complaints or meanderings are welcome.
Alteeve's Niche! Enterprise Support:
Alteeve Support
Community Support
© Alteeve's Niche! Inc. 1997-2024   Anvil! "Intelligent Availability®" Platform
legal stuff: All info is provided "As-Is". Do not use anything here unless you are willing and able to take responsibility for your own actions.