diff --git a/heartbeat/EvmsSCC.in b/heartbeat/EvmsSCC.in index 6aaa3b0cc..c68391af0 100644 --- a/heartbeat/EvmsSCC.in +++ b/heartbeat/EvmsSCC.in @@ -1,190 +1,198 @@ #!/bin/sh # # Support: linux-ha@lists.linux-ha.org # License: GNU General Public License (GPL) # # EvmsSCC # Description: Runs evms_activate in a heartbeat cluster to activate a # EVMS shared cluster container in the cluster. # Original Author: Jo De Baer (jdebaer@novell.com) # Original Release: 06 Nov 2006 # -# usage: ./EvmsSCC {start|stop|status|monitor|validate-all|meta-data} +# usage: ./EvmsSCC {start|stop|status|monitor|meta-data} +# +# The goal of this resource agent is to provoke the creation of device file +# in /dev/emvs which correspond to EVMS2 volumes that reside in a EVMS2 shared +# cluster container. As such it should be run as a clone resource in the +# cluster. Logic inside the resource agent will make sure that "evms_activate" +# is run on only one node in the cluster, both at cluster startup time as well +# as when a node joins the cluster. +# +# Typically, resources that need to mount EVMS2 volumes should run after this +# resource agent has finished it's run. As such those resources should be made +# "dependent" on this resource agent by the cluster administrator. An example +# of resources that should depend on this resource agent are Filesystem resource +# agent that mount OCFS2 volumes that reside on EVMS2 volumes in a shared +# EVMS2 cluster container. +# +# For this resource agent to do it's job correctly, evmsd must be running on +# the node where the agent is started. Usually evmsd is started by the cluster +# software via a respawn statement in /etc/ha.d/ha.cf. If you encounter timing +# issues where evmsd is not yet started but where the cluster already starts +# the EvmsSCC clone, then you should comment out the evmsd respawn statement +# in /etc/ha.d/ha.cf and start evmsd on each node in the cluster via a separate +# clone resource agent. The EvmsSCC resource agent cloneset should then be made +# dependent to this evmsd cloneset. This will guarantee that emvsd is running +# before EvmsSCC is started, on each node in the cluster. # ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs ####################################################################### + # Utilities used by this script CUT=/usr/bin/cut EVMSACTIVATE=/sbin/evms_activate check_util () { if [ ! -x "$1" ] ; then ocf_log err "Setup problem: Couldn't find utility $1" exit $OCF_ERR_GENERIC fi } usage() { cat <<-EOT - usage: $0 {start|stop|status|monitor|validate-all|meta-data} + usage: $0 {start|stop|status|monitor|meta-data} EOT } meta_data() { cat < 1.0 Resource script for EVMS shared cluster container. It runs evms_activate on one node in the cluster. EVMS SCC resource agent - END } EvmsSCC_status() { # At the moment we don't support monitoring EVMS activations. We just return "not running" to cope with the pre-start monitor call. - rc=$OCF_NOT_RUNNING - return $rc + return $OCF_NOT_RUNNING } EvmsSCC_notify() { local n_type="$OCF_RESKEY_CRM_meta_notify_type" local n_op="$OCF_RESKEY_CRM_meta_notify_operation" local n_active="$OCF_RESKEY_CRM_meta_notify_active_uname" local n_stop="$OCF_RESKEY_CRM_meta_notify_stop_uname" local n_start="$OCF_RESKEY_CRM_meta_notify_start_uname" case "$n_type" in pre) case "$n_op" in - start) - #in comment: we prefer evms_activate to run on a starting node whenever possible - #n_active="$n_active $n_start" - - ocf_log debug "EvmsSCC: Notify: Starting node(s): $n_start." + start) ocf_log debug "EvmsSCC: Notify: Starting node(s): $n_start." EvmsSCC_start_notify_common ;; esac ;; esac - return 0 + return $OCF_SUCCESS } EvmsSCC_start() { - - local evmsd_started=no - while [ "$evmsd_started" = "no" ] ; do - if pgrep evmsd ; then - evmsd_started=yes - else - sleep 1 - fi - done - local n_type="$OCF_RESKEY_CRM_meta_notify_type" local n_op="$OCF_RESKEY_CRM_meta_notify_operation" local n_active="$OCF_RESKEY_CRM_meta_notify_active_uname" local n_stop="$OCF_RESKEY_CRM_meta_notify_stop_uname" local n_start="$OCF_RESKEY_CRM_meta_notify_start_uname" - #in comment : see above - #n_active="$n_active $n_start" - ocf_log debug "EvmsSCC: Start: starting node(s): $n_start." EvmsSCC_start_notify_common - return 0 + return $OCF_SUCCESS +} + +EvmsSCC_stop() +{ + return $OCF_SUCCESS } EvmsSCC_start_notify_common() { local n_myself=${HA_CURHOST:-$(uname -n | tr A-Z a-z)} ocf_log debug "EvmsSCC: Start_Notify: I am node $n_myself." - #sanity test n_active="$n_active $n_start" case " $n_active " in *" $n_myself "*) ;; *) ocf_log err "EvmsSCC: $n_myself (local) not on active list!" return $OCF_ERR_GENERIC ;; esac - #pick a node from the starting list + #pick the first node from the starting list #when the cluster boots this will be one of the many booting nodes - #when a node later joins the cluster, this will be the joinging node + #when a node later joins the cluster, this will be the joining node local n_first=$(echo $n_start | cut -d ' ' -f 1) ocf_log debug "EvmsSCC: Start_Notify: First node in starting list is $n_first." if [ "$n_myself" = "$n_first" ] ; then ocf_log debug "EvmsSCC: Start_Notify: I am running evms_activate." evms_activate fi - return 0 + return $OCF_SUCCESS } # Check the arguments passed to this script if [ $# -ne 1 ] then usage exit $OCF_ERR_ARGS fi OP=$1 case $OP in meta-data) meta_data exit $OCF_SUCCESS ;; usage) usage exit $OCF_SUCCESS ;; esac check_util $CUT check_util $EVMSACTIVATE case $OP in - start) EvmsSCC_start + start) EvmsSCC_start ;; notify) EvmsSCC_notify ;; - stop) + stop) EvmsSCC_stop ;; status|monitor) EvmsSCC_status ;; - validate-all) - ;; *) usage exit $OCF_ERR_UNIMPLEMENTED ;; esac exit $? diff --git a/heartbeat/LVM.in b/heartbeat/LVM.in index 4095a507e..5099e7ffb 100644 --- a/heartbeat/LVM.in +++ b/heartbeat/LVM.in @@ -1,335 +1,341 @@ #!/bin/sh # # # LVM # # Description: Manages an LVM volume as an HA resource # # # Author: Alan Robertson # Support: linux-ha@lists.linux-ha.org # License: GNU General Public License (GPL) # Copyright: (C) 2002 - 2005 International Business Machines, Inc. # # This code significantly inspired by the LVM resource # in FailSafe by Lars Marowsky-Bree # # # An example usage in /etc/ha.d/haresources: # node1 10.0.0.170 ServeRAID::1::1 LVM::myvolname # # See usage() function below for more details... # # OCF parameters are as below: # OCF_RESKEY_volgrpname # ####################################################################### # Initialization: . @hb_libdir@/ocf-shellfuncs ####################################################################### AWK=@AWK@ usage() { methods=`LVM_methods` methods=`echo $methods | tr ' ' '|'` cat <<-! usage: $0 $methods $0 manages an Linux Volume Manager volume (LVM) as an HA resource The 'start' operation brings the given volume online The 'stop' operation takes the given volume offline The 'status' operation reports whether the volume is available The 'monitor' operation reports whether the volume seems present The 'validate-all' operation checks whether the OCF parameters are valid The 'methods' operation reports on the methods $0 supports ! exit $OCF_ERR_GENERIC } meta_data() { cat < 1.0 Resource script for LVM. It manages an Linux Volume Manager volume (LVM) as an HA resource. LVM resource agent The name of volume group. Volume group name END } # # methods: What methods/operations do we support? # LVM_methods() { cat <<-! start stop status monitor methods validate-all usage ! } # # Return LVM status (silently) # LVM_status() { if [ "$LVM_MAJOR" -eq "1" ] then vgdisplay $1 | grep -i 'Status.*available' >/dev/null return $? else vgdisplay -v $1 | grep -i 'Status[ \t]*available' >/dev/null return $? fi } # # Report on LVM volume status to stdout... # LVM_report_status() { if [ "$LVM_MAJOR" -eq "1" ] then VGOUT=`vgdisplay $1 2>&1` echo "$VGOUT" | grep -i 'Status.*available' >/dev/null rc=$? else VGOUT=`vgdisplay -v $1 2>&1` echo "$VGOUT" | grep -i 'Status[ \t]*available' >/dev/null rc=$? fi if [ $rc -eq 0 ] then : Volume $1 is available else ocf_log debug "LVM Volume $1 is not available (stopped)" return $OCF_NOT_RUNNING fi if echo "$VGOUT" | grep -i 'Access.*read/write' >/dev/null then ocf_log debug "Volume $1 is available read/write (running)" else ocf_log debug "Volume $1 is available read-only (running)" fi return $OCF_SUCCESS } # # Monitor the volume - does it really seem to be working? # # LVM_monitor() { if LVM_status $1 then : OK else ocf_log info "LVM Volume $1 is offline" return $OCF_NOT_RUNNING fi ocf_run vgck $1 return $? } # # Enable LVM volume # LVM_start() { + # TODO: This MUST run vgimport as well + ocf_log info "Activating volume group $1" if [ "$LVM_MAJOR" -eq "1" ] then ocf_run vgscan $1 else ocf_run vgscan fi + # TODO: For v2, this MUST use --refresh ocf_run vgchange -a y $1 || return $OCF_ERR_GENERIC if LVM_status $1 then : OK Volume $1 activated just fine! return $OCF_SUCCESS else ocf_log err "LVM: $1 did not activate correctly" return $OCF_ERR_GENERIC fi } # # Disable the LVM volume # LVM_stop() { ocf_log info "Deactivating volume group $1" ocf_run vgchange -a n $1 || return 1 if LVM_status $1 then ocf_log err "LVM: $1 did not stop correctly" return $OCF_ERR_GENERIC fi + + # TODO: This MUST run vgexport as well + return $OCF_SUCCESS } # # Check whether the OCF instance parameters are valid # LVM_validate_all() { # Off-the-shelf tests... vgck "$VOLUME" >/dev/nulll 2>&1 if [ $? -ne 0 ]; then ocf_log err "Volume group [$VOLUME] does not exist or contains error!" exit $OCF_ERR_GENERIC fi # Double-check if [ "$LVM_MAJOR" -eq "1" ] then vgdisplay "$VOLUME" >/dev/null 2>&1 else vgdisplay -v "$VOLUME" >/dev/null 2>&1 fi if [ $? -ne 0 ]; then ocf_log err "Volume group [$VOLUME] does not exist or contains error!" exit $OCF_ERR_GENERIC fi return $OCF_SUCCESS } # # 'main' starts here... # if ( [ $# -ne 1 ] ) then usage exit $OCF_ERR_ARGS fi case $1 in meta-data) meta_data exit $OCF_SUCCESS;; methods) LVM_methods exit $?;; usage) usage exit $OCF_SUCCESS;; *) ;; esac if [ -z "$OCF_RESKEY_volgrpname" ] then # echo "You must identify the volume group name!" ocf_log err "You must identify the volume group name!" # usage exit $OCF_ERR_ARGS fi # Get the LVM version number, for this to work we assume(thanks to panjiam): # # LVM1 outputs like this # # # vgchange --version # vgchange: Logical Volume Manager 1.0.3 # Heinz Mauelshagen, Sistina Software 19/02/2002 (IOP 10) # # LVM2 and higher versions output in this format # # # vgchange --version # LVM version: 2.00.15 (2004-04-19) # Library version: 1.00.09-ioctl (2004-03-31) # Driver version: 4.1.0 LVM_VERSION=`vgchange --version 2>&1 | \ $AWK '/Logical Volume Manager/ {print $5"\n"; exit; } /LVM version:/ {printf $3"\n"; exit;}'` rc=$? if ( [ $rc -ne 0 ] || [ -z "$LVM_VERSION" ] ) then ocf_log err "LVM: $1 could not determine LVM version. Try 'vgchange --version' manually and modify $0 ?" exit $OCF_ERR_GENERIC fi LVM_MAJOR="${LVM_VERSION%%.*}" VOLUME=$OCF_RESKEY_volgrpname # What kind of method was invoked? case "$1" in start) LVM_start $VOLUME exit $?;; stop) LVM_stop $VOLUME exit $?;; status) LVM_report_status $VOLUME exit $?;; monitor) LVM_monitor $VOLUME exit $?;; validate-all) LVM_validate_all ;; *) usage exit $OCF_ERR_AEGS;; esac