[prev in list] [next in list] [prev in thread] [next in thread] 

List:       linux-ha
Subject:    Re: Sample config for shared disks
From:       Alan Robertson <alanr () unix ! sh>
Date:       2003-05-23 12:12:10
[Download RAW message or body]

Luc de Louw wrote:
> Hi all,
> 
> I would kindly ask, if someone could provide me some sample configs and scripts
> to use with IBM's ServeRaid 4L adapter.

OK...

Attached is the latest version of the ServeRAID script.  It is *not* yet in 
any production release of heartbeat.  However, it is the only one that will 
work with the production version of the ServeRAID adapters.

Let's start the discussion with the information in this script and see if 
that helps.  If it doesn't, then let's fix the script's comments.

	Thanks!

-- 
     Alan Robertson <alanr@unix.sh>

"Openness is the foundation and preservative of friendship...  Let me claim 
from you at all times your undisguised opinions." - William Wilberforce

["ServeRAID.in" (text/plain)]

#!/bin/sh
#
# $Id: ServeRAID.in,v 1.17 2003/05/22 13:25:24 alan Exp $
# 
# ServeRAID
#
# Description:	Enables/Disables shared ServeRAID merge groups
#
# Author:	Alan Robertson, Renzo Alejandro Granados
#
# Support:	linux-ha-dev@lists.tummy.com
#
# License:	GNU Lesser General Public License (LGPL)
#
# Copyright:	(C) 2002 International Business Machines
#		(C) 2002 Renzo Alejandro Granados
#
# usage: ./ServeRAID <adapter> <MergeGroup#>  (start|stop|status)
#
#<adapter>:	Adapter number of the ServeRAID adapter 
#<MergeGroup#>:	MergeGroup # of the logical drive under consideration.
#
#
# The ServeRAID clustering model is a bit odd, and its terminology needs
# a little explanation
#
#	Logical Volume - a particular SCSI id {target id and LUN} on
#		a particular controller.
#
#	Merge Group - when active on one side or the other of the ServeRAID
#		configuration it corresponds with a logical drive.
#		Merge group numbers are permanently assigned to a particular
#		chunk of storage.  Shared merge groups are in the
#		range of 1 to 8, and are largely arbitrary.
#		Unshared merge groups start at 200.
#		We can only deal with shared merge groups.  When a merge
#		group is activated on one of the controllers, it becomes
#		a logical volume on that system.  NOTE:  The order in
#		which the Merge Groups are activated determines which
#		SCSI Ids they become.  This makes for extra headaches
#		for this script to deal with.  It also means that if
#		you have more than one shared ServeRAID merge group on
#		a particular controller, that the SCSI IDs will not
#		be constant.  This requires mounting by uuid or label.
#
#	One of the ServerRAID controllers has to be configured with
#	SCSI initiator ID 6, and the other with SCSI id 7.
#
#	At this time, the ServeRAID clustering solution only works with
#	RAID 1 setups.  It does NOT support RAID 5.
#
#	Note that this script requires ServeRAID software version 6.10 or
#	later.
#
#	As of this writing (5/22/2003) this version of the software is not
#	yet available.  For everything but the ipssend command, you can
#	grab the ISO image here:
#
#		ftp://ftp.pc.ibm.com/pub/pccbbs/bp_server/01r0539.iso
#
#	For the time being, you will need to grab a "correct" version of
#	the ipssend command here:
#		http://linux-ha.org/download/ipssend.gz
#
#	NOTE: This a temporary URL which will go away once the official
#	version with the corrections is available from IBM.
#
#
# An example usage in /etc/ha.d/haresources: 
#       node1  10.0.0.170 ServeRAID::1::1
#
unset LC_ALL; export LC_ALL
unset LANGUAGE; export LANGUAGE

#	Older ServeRAID utility returns 1 when it succeeds (weird)
#	BUT - the newly released version is more normal...

srsuccess=0

PERL="perl"
SCSI="scsi "

usage() {
  cat <<-! >&1
	usage: $0 <serveraid#> <sharedmergegroup#> (start|stop|status)

	The serveraid# is the number of the ServeRAID adapter
	ServeRAID adapters are numbered starting from 1.

	The shared merge group number is a number between 1 and 8 inclusive.
	It indicates to the controller which logical disk to fail over.

                node1  10.0.0.170 ServeRAID::1::1

	PREREQUISITES:
	You must configure your ServeRAID adapters for clustering for this
	to work.

	To do this, you must use the bootable "ServeRAID Support CD" and right
	click your controller and pick "configure for clustering".  The Linux
	version of the ServeRAID manager does not have the "configure for
	clustering" option.

	You will need at least version 6.10 (~July 2003 release) of the ipssend
	command for this script to work.

	For the time being, you will need to grab a "correct" version of
	the ipssend command here:
	        http://linux-ha.org/download/ipssend.gz

	NOTE: This a temporary URL which will go away once the official
	version becomes available.


	$Id: ServeRAID.in,v 1.17 2003/05/22 13:25:24 alan Exp $
	!
  exit 1
}

prefix=@prefix@
exec_prefix=@exec_prefix@
. @sysconfdir@/ha.d/shellfuncs


ServeRAID_methods() {
  cat <<-!
	start
	stop
	status
	methods
	!
}

ServeRAIDSCSI="/proc/scsi/ips"

 
IPS=ipssend
proc_scsi=/proc/scsi/scsi


parseinst() {
  sr_adapter=error
  sr_mergegroup=error
  hostid=error
  sr_logicaldrivenumber=error
  if
    [ $# -ne 2 ]
  then
    echo "Invalid ServeRAID instance: $*" >&2
    return 1
  fi
  PerlScript='next unless /^Host/; $_ .= <>.<>; print "$1 " if /SERVERAID/ and /Proces/ and /scsi(\d+)/'
  # Get the list of host ids of the ServeRAID host adapters
  hostlist=`$PERL -ne "${PerlScript}" <$proc_scsi`
  # Figure the host id of the desired ServeRAID adapter
  hostid=`echo $hostlist | cut -d' ' -f$1`
  if
    [ ! -f "$ServeRAIDSCSI/$hostid" ]
  then
    echo "No such ServeRAID adapter: $1" >&2
    hostid=error
    return 2
  fi
    
  case $2 in
    [1-8]);;
    *)	echo "Invalid Shared Merge Group Number: $2" >&2
        hostid=error
	return 3;;
  esac
  sr_adapter=$1
  sr_mergegroup=$2
  return 0
}

#
#	Run:  Run a script, and log its output.
#	Note that we know the stupid ipssend command has its return
#	codes reversed - it returns 1 for success, and 0 for failure...
#	We account for that too...
#
run() {
  output=`"$@" 2>&1`
  rc=$?
  output=`echo $output`
  if
    [ $rc -eq $srsuccess ]
  then 
    if
      [ ! -z "$output" ]
    then
      ha_log "info: $output"
    fi
    return 0
  else
    if
      [ ! -z "$output" ]
    then
      ha_log "ERROR: $output"
    else
      ha_log "ERROR: command failed: $*"
    fi
    return 1
  fi
}

SRLogicalDriveConfig() {
  $IPS getconfig $sr_adapter ld
}

MergeGroupToSCSI_ID() {

  PerlScript="while (<>) {
	/logical drive number *([0-9]+)/i && (\$ld=\$1);
	/part of merge group *: *$sr_mergegroup *\$/i && print \$ld - 1, \"\n\";
  }"

  ID=`SRLogicalDriveConfig | $PERL -e "$PerlScript"`
  case $ID in
    [0-9]*)	echo "$ID"; return 0;;
    *)		return 1;;
  esac
}

MergeGroupRaidLevel() {

  PerlScript="while (<>) {
	/RAID level *: *([0-9]+[A-Z]*)/i && (\$ld=\$1);
	/part of merge group *: *$sr_mergegroup *\$/i && print \$ld, \"\n\";
  }"

  Level=`SRLogicalDriveConfig | $PERL -e "$PerlScript"`
  case $Level in
    ?*)	echo "$Level"; return 0;;
    *)		return 1;;
  esac
}

ReleaseSCSI() {
  targetid=`MergeGroupToSCSI_ID`
  echo "${SCSI}remove-single-device $hostid 0 $targetid 0" > $proc_scsi
}

AddSCSI() {
  targetid=`MergeGroupToSCSI_ID`
  echo "${SCSI}add-single-device $hostid 0 $targetid 0" > $proc_scsi
}

#
# start: Enable the given ServeRAID device
#
ServeRAID_start() {
  parseinst "$@" || return $?
  if
    run $IPS UNMERGE $sr_adapter $sr_mergegroup
  then
    if
      #
      # Normally we do a MERGE PARTNER, but if we still own the drive for
      # some reason, then we'll need to do a MERGE OWN instead...
      #
      out=`$IPS MERGE $sr_adapter $sr_mergegroup PARTNER 2>&1`
      if
        [ $? -eq $srsuccess ]
      then
	echo "info: $out"
      else
        run $IPS MERGE $sr_adapter $sr_mergegroup OWN
      fi
    then
      : OK All is well!
      targetid=`MergeGroupToSCSI_ID`
      sr_logicaldrivenumber=`expr $targetid + 1`
      #run $IPS SYNCH $sr_adapter $sr_logicaldrivenumber &
      # This version of the SYNCH command requires the 6.10 or later
      # ServeRAID support CD.
      run $IPS SYNCH $sr_adapter GROUP $sr_mergegroup &
      AddSCSI
    else
      return $?
    fi
  else
    return $?
  fi
  if
    ServeRAID_status "$@"
  then
    return 0
  else
    echo "ERROR: ServeRAID device $1 not active!"
    return 1
  fi
}


#
# stop: Disable the given ServeRAID device
#
ServeRAID_stop() {
  parseinst "$@" || return $?
  ReleaseSCSI
  if
    run $IPS UNMERGE $sr_adapter $sr_mergegroup
  then
    : UNMERGE $sr_adapter $sr_mergegroup worked
  fi
  if
    ServeRAID_status "$@"
  then
    echo "ERROR: ServeRAID device $@ is still active!"
    return 1
  else
    return 0
  fi
}


#
# status: is the given device now available?
#
ServeRAID_status() {
  parseinst "$@" || return $?
  #
  # The output we're looking for
  #	Part of merge group            : 2   
  #
  SRLogicalDriveConfig 		\
  |	grep -i "part of merge group[ 	]*: *$sr_mergegroup *\$" >/dev/null
}

if
  [ $# -eq 1 -a "X$1" = "Xmethods" ]
then
  ServeRAID_methods
  exit $?
fi

if
  [ $# -ne 3 ]
then
  usage
  exit 1
fi

: Right Number of arguments..

# Look for the start, stop, status, or methods calls...
case "$3" in
  stop)
	ServeRAID_stop $1 $2
	exit $?;;
  start)
	ServeRAID_start $1 $2
	exit $?;;
  status) 
	if
	  ServeRAID_status $1 $2
	then
	  echo ServeRAID merge group $1 $2 is running.
	  exit 0
	else
	  echo ServeRAID merge group $1 $2 is stopped.
	  exit 1
	 fi
	exit $?;;

#
# methods: What methods do we support?
#
  methods) 
	ServeRAID_methods
	exit $?;;

*)
    usage
    exit 1;;

esac

exit 1



------------------------------------------------------------------------------
Linux HA Web Site:
  http://linux-ha.org/
Linux HA HOWTO:
  http://metalab.unc.edu/pub/Linux/ALPHA/linux-ha/High-Availability-HOWTO.html
------------------------------------------------------------------------------

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic