Page MenuHomeClusterLabs Projects

No OneTemporary

diff --git a/cman/init.d/cman b/cman/init.d/cman
index 4778fa89d..d375acc31 100644
--- a/cman/init.d/cman
+++ b/cman/init.d/cman
@@ -1,704 +1,699 @@
#!/bin/bash
#
# cman - Cluster Manager init script
#
# chkconfig: - 21 79
# description: Starts and stops cman
#
#
### BEGIN INIT INFO
# Provides: cman
# Required-Start: $network $time
# Required-Stop: $network $time
# Default-Start:
# Default-Stop:
# Short-Description: Starts and stops cman
# Description: Starts and stops the Cluster Manager set of daemons
### END INIT INFO
. /etc/init.d/functions
-if [ -f /etc/sysconfig/cman ]; then
- . /etc/sysconfig/cman
- echo "/etc/sysconfig/cman has been deprecated in favour of /etc/sysconfig/cluster"
- echo "Please consider switching to the new file"
-fi
-
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
+[ -f /etc/sysconfig/cman ] && . /etc/sysconfig/cman
[ -z "$CCSD_OPTS" ] && CCSD_OPTS=
# CMAN_CLUSTER_TIMEOUT -- amount of time to wait for joinging a cluster
# before giving up. If CMAN_CLUSTER_TIMEOUT is positive, then we will
# wait CMAN_CLUSTER_TIMEOUT seconds before giving up and failing when
# a cluster is not joined. If CMAN_CLUSTER_TIMEOUT is zero, then
# wait indefinately for a cluster join. If CMAN_CLUSTER_TIMEOUT is
# negative, do not check to see that the cluster has been joined
[ -z "$CMAN_CLUSTER_TIMEOUT" ] && CMAN_CLUSTER_TIMEOUT=120
# CMAN_QUORUM_TIMEOUT -- amount of time to wait for a quorate cluster on
# startup quorum is needed by many other applications, so we may as
# well wait here. If CMAN_QUORUM_TIMEOUT is less than 1, quorum will
# be ignored.
[ -z "$CMAN_QUORUM_TIMEOUT" ] && CMAN_QUORUM_TIMEOUT=0
# CMAN_SHUTDOWN_TIMEOUT -- amount of time to wait for cman to become a
# cluster member before calling cman_tool leave during shutdown.
# The default is 60 seconds
[ -z "$CMAN_SHUTDOWN_TIMEOUT" ] && CMAN_SHUTDOWN_TIMEOUT=60
# FENCED_START_TIMEOUT -- amount of time to wait for starting fenced
# before giving up. If FENCED_START_TIMEOUT is positive, then we will
# wait FENCED_START_TIMEOUT seconds before giving up and failing when
# fenced does not start. If FENCED_START_TIMEOUT is zero, then
# wait indefinately for fenced to start.
[ -z "$FENCED_START_TIMEOUT" ] && FENCED_START_TIMEOUT=300
# NET_RMEM_DEFAULT -- minimum value for rmem_default. If this is set
# higher elsewhere it will not be reduced here.
# These two values are only really needed for the DLM when using sctp
# but do no harm.
[ -z "$NET_RMEM_DEFAULT" ] && NET_RMEM_DEFAULT=4194304
# NET_RMEM_MAX -- minimum value for rmem_max. If this is set
# higher elsewhere it will not be reduced here.
[ -z "$NET_RMEM_MAX" ] && NET_RMEM_MAX=4194304
# FENCED_MEMBER_DELAY -- amount of time to delay fence_tool join to allow
# all nodes in cluster.conf to become cluster members. In seconds.
[ -z "$FENCED_MEMBER_DELAY" ] && FENCED_MEMBER_DELAY=45
# FENCE_JOIN -- boolean value used to control whether or not this node
# should join the fence domain. If FENCE_JOIN is set to "no", then
# the script will not attempt to the fence domain. If FENCE_JOIN is
# set to "yes", then the script will attempt to join the fence domain.
# If FENCE_JOIN is set to any other value, the default behavior is
# to join the fence domain (equivalent to "yes").
[ -z "$FENCE_JOIN" ] && FENCE_JOIN="yes"
[ -z "$LOCK_FILE" ] && LOCK_FILE="/var/lock/subsys/cman"
[ -n "$CLUSTERNAME" ] && cman_join_opts="-c $CLUSTERNAME"
[ -n "$NODENAME" ] && cman_join_opts+=" -n $NODENAME"
# CONFIG_LOADER -- select default config parser.
# This can be:
# xmlconfig - read directly from cluster.conf and use ricci as default config
# propagation method. (default)
# ldapconfig - read configuration from an ldap server.
# Requires: LDAP_URL or/and LDAP_BASEDN envvar to be set.
# LDAP_BINDDN and LDAP_BINDPWD have to be either both set or both unset.
# corosync_parser - use internal corosync config file parser.
# openaisparser - use internal openais config file parser.
# ccsconfig - read configuration from ccsd daemon. This method is deprecated
# and available only if building the code with --enable_legacy_code.
[ -n "$CONFIG_LOADER" ] && cman_join_opts+=" -C $CONFIG_LOADER"
load_modules()
{
errmsg=$( /sbin/modprobe configfs 2>&1 ) || return 1
errmsg=$( /sbin/modprobe dlm 2>&1 ) || return 1
errmsg=$( /sbin/modprobe lock_dlm 2>&1 ) || return 1
return 0
}
start_configfs()
{
# configfs
awk '{ print $2 }' /etc/mtab | grep "/sys/kernel/config" &> /dev/null \
&& awk '{ print $3 }' /etc/mtab | grep "configfs" &> /dev/null
if [ $? -ne 0 ]
then
errmsg=$( /bin/mount -t configfs none /sys/kernel/config 2>&1 )
return $?
fi
return 0
}
start_ccsd()
{
# ccsd
status ccsd &> /dev/null
if [ $? -ne 0 ]
then
errmsg=$(/sbin/ccsd $CCSD_OPTS 2>&1)
rtrn=$?
return $rtrn
fi
return 0
}
start_cman()
{
# cman
/sbin/cman_tool status &> /dev/null
if [ $? -ne 0 ]
then
case "$CONFIG_LOADER" in
ldapconfig)
if [ -n "$LDAP_URL" ] || [ -n "$LDAP_BASEDN" ]; then
if [ -n "$LDAP_BINDDN" ]; then
if [ -z "$LDAP_BINDPWD" ]; then
errmsg="ldadconfig has been select but LDAP_BINDPWD is not set"
return 1
fi
fi
if [ -n "$LDAP_BINDPWD" ]; then
if [ -z "$LDAP_BINDDN" ]; then
errmsg="ldadconfig has been select but LDAP_BINDDN is not set"
return 1
fi
fi
else
errmsg="ldadconfig has been select but neither LDAP_URL or LDAP_BASEDN have been set"
return 1
fi
;;
ccsconfig)
if [ -x /sbin/ccsd ]; then
echo -n " Starting ccsd... "
start_ccsd
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
errmsg="Unable to start ccsd"
return 1
fi
else
errmsg="ccsconfig has been selected but ccsd does not appear to be installed or executable"
return 1
fi
;;
*)
# nothing to do for now
;;
esac
errmsg=$( /sbin/cman_tool -t $CMAN_CLUSTER_TIMEOUT -w join \
$cman_join_opts 2>&1 ) || return 1
if [ $CMAN_QUORUM_TIMEOUT -gt 0 ]
then
errmsg=$( /sbin/cman_tool -t $CMAN_QUORUM_TIMEOUT \
-q wait 2>&1 ) || return 1
fi
fi
return 0
}
start_qdiskd()
{
declare current_runlevel
current_runlevel=$(/sbin/runlevel 2>/dev/null | awk '{ print $2 }' 2>/dev/null)
#
# Start qdiskd before fenced to resolve bug #436381. This only
# happens if qdiskd is configured to run in the runlevel we are in
#
/sbin/chkconfig --levels "$current_runlevel" qdiskd 2>/dev/null
if [ $? -ne 0 ]; then
# qdiskd doesn't start at this runlevel.
return 0
fi
echo -n " Starting qdiskd... "
/sbin/service qdiskd start &> /dev/null
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
return 0
}
start_daemons()
{
status groupd &> /dev/null
if [ $? -ne 0 ]; then
errmsg=$( /sbin/groupd 2>&1 ) || return 1
fi
status fenced &> /dev/null
if [ $? -ne 0 ]; then
errmsg=$( /sbin/fenced 2>&1 ) || return 1
fi
status dlm_controld &> /dev/null
if [ $? -ne 0 ]; then
errmsg=$( /sbin/dlm_controld 2>&1 ) || return 1
fi
status gfs_controld &> /dev/null
if [ $? -ne 0 ]; then
errmsg=$( /sbin/gfs_controld 2>&1 ) || return 1
fi
return 0
}
start_fence()
{
/usr/sbin/cman_tool status | grep Flags | grep 2node &> /dev/null
if [ $? -ne 0 ]
then
errmsg=$( /sbin/fence_tool -w -t $FENCED_START_TIMEOUT join \
> /dev/null 2>&1 ) || return 1
else
errmsg=$( /sbin/fence_tool -w -t $FENCED_START_TIMEOUT \
-m $FENCED_MEMBER_DELAY join \
> /dev/null 2>&1 ) || return 1
fi
return 0
}
start_fence_xvmd()
{
status fence_xvmd &> /dev/null
if [ $? -ne 0 ]; then
errmsg=$( /sbin/fence_xvmd $FENCE_XVMD_OPTS 2>&1 ) || return 1
fi
return 0
}
xend_bridged_net_enabled() {
# Not a xen kernel
test -d /proc/xen || return 1
current_runlevel=$(/sbin/runlevel 2>/dev/null | awk '{ print $2 }' 2>/dev/null)
if [ -z "$current_runlevel" ]; then
errmsg='Unable to determine the current runlevel'
return 1
fi
/sbin/chkconfig --levels "$current_runlevel" xend 2>/dev/null
if [ $? -ne 0 ]; then
# xend doesn't start at this runlevel.
return 1
fi
if [ ! -f /etc/xen/xend-config.sxp ]; then
# xend isn't configured to use bridged networking.
return 1
fi
egrep "^[[:blank:]]*\([[:blank:]]*network-script[[:blank:]]+(')?[[:blank:]]*network-bridge([[:blank:]]*\)|[[:blank:]]+)" /etc/xen/xend-config.sxp >&/dev/null
if [ $? -ne 0 ]; then
# xend isn't configured to use bridged networking.
return 1
fi
return 0
}
xend_bridged_net_start() {
if [ ! -x /etc/xen/scripts/network-bridge ]; then
if [ -f /etc/xen/scripts/network-bridge ]; then
errmsg='The xend bridged network script cannot be run'
else
errmsg='The xend bridged network script is missing'
fi
return 1
fi
/sbin/modprobe netbk >& /dev/null
/sbin/modprobe netloop >& /dev/null
bridge_parms=`egrep -m 1 "^[[:blank:]]*\([[:blank:]]*network-script[[:blank:]]+(')?[[:blank:]]*network-bridge([[:blank:]]*\)|[[:blank:]]+)" /etc/xen/xend-config.sxp| sed -r "s/^[[:blank:]]*\([[:blank:]]*network-script[[:blank:]]+'?[[:blank:]]*network-bridge[[:blank:]]*//; s/'?[[:blank:]]*\).*//"`
errmsg=$(/etc/xen/scripts/network-bridge start $bridge_parms 2>&1) || return 1
return 0
}
fence_xvmd_enabled()
{
#
# Check the value of FENCE_JOIN.
# If FENCE_JOIN is set to "no", then we should disable fence_xvm.
#
if [ "$FENCE_JOIN" == "no" ]; then
return 1
fi
#
# Check for the 'xm' binary. If it's not here, we are not
# running on a machine capable of running xvmd.
#
which xm &> /dev/null || return 1
#
# Check for presence of /cluster/fence_xvmd in cluster.conf
# (If -X is specified, it doesn't matter if it's in cluster.conf;
# we'll start it anyway since ccsd is not required)
#
/sbin/cman_tool status &> /dev/null
if [ $? -eq 0 ]
then
if [ "$FENCE_XVMD_OPTS" = "${FENCE_XVMD_OPTS/-X/}" ]; then
ccs_tool query /cluster/fence_xvmd || return 1
fi
fi
return 0
}
set_networking_params()
{
if [ ! -f /proc/sys/net/core/rmem_default ]
then
return 0;
fi
value="$(cat /proc/sys/net/core/rmem_default)"
if [ $value -le $NET_RMEM_DEFAULT ]
then
echo $NET_RMEM_DEFAULT > /proc/sys/net/core/rmem_default
fi
value="$(cat /proc/sys/net/core/rmem_max)"
if [ $value -le $NET_RMEM_MAX ]
then
echo $NET_RMEM_MAX > /proc/sys/net/core/rmem_max
fi
}
fence_join_enabled()
{
#
# Check the value of FENCE_JOIN.
# If FENCE_JOIN is set to "no", we will not attempt to join
# the fence domain. If FENCE_JOIN is set to any other value,
# we will attempt to join the fence domain (default).
#
if [ "$FENCE_JOIN" == "no" ]; then
return 1
else
return 0
fi
}
start()
{
echo "Starting cluster: "
xend_bridged_net_enabled
if [ $? -eq 0 ]
then
echo -n " Enabling workaround for Xend bridged networking... "
xend_bridged_net_start
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed: $errmsg"
return 1
fi
fi
echo -n " Loading modules... "
ulimit -c unlimited
load_modules
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
echo -n " Mounting configfs... "
start_configfs
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
echo -n " Setting network parameters... "
set_networking_params
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
echo -n " Starting cman... "
start_cman
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
start_qdiskd
echo -n " Starting daemons... "
start_daemons
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
if fence_join_enabled; then
echo -n " Starting fencing... "
start_fence
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
fi
if fence_xvmd_enabled; then
echo -n " Starting virtual machine fencing host... "
start_fence_xvmd
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
fi
return 0
}
stop_configfs()
{
awk '{ print $2 }' /etc/mtab | grep "/sys/kernel/config" &> /dev/null\
&& awk '{ print $3 }' /etc/mtab | grep "configfs" &> /dev/null
if [ $? -eq 0 ] && [ -z "$(ls -1 /sys/kernel/config)" ]
then
errmsg=$( /bin/umount /sys/kernel/config 2>&1 )
if [ $? -ne 0 ]
then
echo -n $errmsg " "
fi
fi
return 0
}
stop_ccsd()
{
for sec in $(seq 1 10)
do
if /sbin/pidof ccsd &> /dev/null
then
# get the pid of ccsd from /var/run/cluster/ccsd.pid
# and break if the file is not there
[ -r /var/run/cluster/ccsd.pid ] || break
pid=$(cat /var/run/cluster/ccsd.pid)
/usr/bin/kill $pid &> /dev/null || break
sleep 1
else
return 0
fi
done
return 1
}
stop_cman()
{
/sbin/cman_tool status &> /dev/null
if [ $? -eq 0 ]
then
errmsg=$( /sbin/cman_tool -t $CMAN_SHUTDOWN_TIMEOUT \
-w leave $1 2>&1 ) || return 1
fi
return 0 # all ok
}
stop_daemons()
{
if pid=$(/sbin/pidof gfs_controld 2>&1); then
errmsg=$(/usr/bin/kill $pid 2>&1) || return 1
fi
if pid=$(/sbin/pidof dlm_controld 2>&1); then
errmsg=$(/usr/bin/kill $pid 2>&1) || return 1
fi
if pid=$(/sbin/pidof fenced 2>&1); then
errmsg=$(/usr/bin/kill $pid 2>&1) || return 1
fi
if pid=$(/sbin/pidof groupd 2>&1); then
errmsg=$(/usr/bin/kill $pid 2>&1) || return 1
fi
return 0 # all ok
}
stop_fence()
{
if /sbin/pidof fenced &> /dev/null
then
/sbin/fence_tool -w leave > /dev/null 2>&1
rtrn=$?
sleep 1 # A bit of time for fenced to exit
return $rtrn
fi
return 0 # all ok
}
stop_fence_xvmd()
{
if /sbin/pidof fence_xvmd &> /dev/null
then
pkill -TERM fence_xvmd
sleep 1 # A bit of time for fenced to exit
fi
[ -z "`pidof fence_xvmd`" ]
return $?
}
stop()
{
echo "Stopping cluster: "
if fence_xvmd_enabled; then
echo -n " Stopping virtual machine fencing host... "
stop_fence_xvmd
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
fi
if fence_join_enabled; then
echo -n " Stopping fencing... "
stop_fence
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
fi
echo -n " Stopping cman... "
if [ $1 ]; then
stop_cman $1
else
stop_cman
fi
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
# stop_daemons
# [ $? -ne 0 ] && return 1
echo -n " Stopping ccsd... "
stop_ccsd
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
echo -n " Unmounting configfs... "
stop_configfs
if [ $? -eq 0 ]
then
echo "done"
else
echo "failed"
return 1
fi
return 0
}
cmanstatus()
{
errmsg=$( status ccsd 2>&1) || return 1
errmsg=$( status groupd 2>&1) || return 1
errmsg=$( status fenced 2>&1) || return 1
errmsg=$( status dlm_controld 2>&1) || return 1
errmsg=$( status gfs_controld 2>&1) || return 1
fence_xvmd_enabled || return 0
errmsg=$( status fence_xvmd 2>&1) || return 1
return 0
}
rtrn=1
# See how we were called.
case "$1" in
start)
start
rtrn=$?
[ $rtrn = 0 ] && touch $LOCK_FILE
if [ $rtrn -ne 0 ]
then
echo $errmsg
failure "failed to start cman"
echo
else
success "start"
echo
fi
;;
stop)
if [ $2 ]; then
stop
else
stop remove
fi
rtrn=$?
[ $rtrn = 0 ] && rm -f $LOCK_FILE
if [ $rtrn -ne 0 ]
then
echo $errmsg
failure "failed to stop cman"
echo
else
success "shutdown"
echo
fi
;;
restart|reload)
$0 stop restart
$0 start
rtrn=$?
;;
status)
cmanstatus
rtrn=$?
if [ $rtrn -ne 0 ] ; then
echo $errmsg
else
echo "cman is running."
fi
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|status}"
;;
esac
exit $rtrn
diff --git a/cman/init.d/qdiskd b/cman/init.d/qdiskd
index 62bd33f56..d77057c82 100644
--- a/cman/init.d/qdiskd
+++ b/cman/init.d/qdiskd
@@ -1,87 +1,88 @@
#!/bin/bash
#
# qdiskd quorum disk daemon
#
# chkconfig: - 22 78
# description: Starts and stops the quorum disk daemon
### BEGIN INIT INFO
# Provides: qdiskd
# Required-Start: cman
# Required-Stop: cman
# Default-Start:
# Default-Stop:
# Short-Description: start/stop quorum disk daemon
# Description: start/stop quorum disk daemon
### END INIT INFO
. /etc/init.d/functions
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
+[ -f /etc/sysconfig/qdiskd ] && . /etc/sysconfig/qdiskd
LOCK_FILE="/var/lock/subsys/qdiskd"
rtrn=1
retries=0
# See how we were called.
case "$1" in
start)
echo -n "Starting the Quorum Disk Daemon:"
$0 status >/dev/null
if [ $? -eq 0 ]; then
echo_success
echo
exit 0
fi
qdiskd -Q
rtrn=$?
if [ $rtrn = 0 ]; then
touch $LOCK_FILE
echo_success
echo
else
echo_failure
echo
fi
;;
stop)
echo -n "Stopping the Quorum Disk Daemon:"
killproc qdiskd
while [ -n "`pidof qdiskd`" ] && [ $retries -lt 5 ]; do
sleep 1
killproc qdiskd
((retries++))
done
if [ -z "`pidof qdiskd`" ]; then
echo_success
echo
rtrn=0
rm -f $LOCK_FILE
else
echo_failure
echo
rtrn=1
fi
;;
restart|reload)
$0 stop || exit $?
$0 start
rtrn=$?
;;
status)
status qdiskd
rtrn=$?
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|status}"
;;
esac
exit $rtrn
diff --git a/fence/agents/scsi/scsi_reserve b/fence/agents/scsi/scsi_reserve
index a6918d84b..6aeccc623 100644
--- a/fence/agents/scsi/scsi_reserve
+++ b/fence/agents/scsi/scsi_reserve
@@ -1,266 +1,261 @@
#!/bin/bash
#
# scsi_reserve persistent reservation service for lvm
#
# chkconfig: - 25 75
# description: start/stop persistent reservation service for lvm
### BEGIN INIT INFO
# Provides: scsi_reserve
# Required-Start: cman
# Required-Stop: cman
# Default-Start:
# Default-Stop:
# Short-Description: start/stop persistent reservation service for lvm
# Description: start/stop persistent reservation service for lvm
### END INIT INFO
. /etc/init.d/functions
# read in config file if it exists
#
-if [ -f /etc/sysconfig/scsi_reserve ] ; then
- . /etc/sysconfig/scsi_reserve
- echo "/etc/sysconfig/scsi_reserve has been deprecated in favour of /etc/sysconfig/cluster"
- echo "Please consider switching to the new file"
-fi
-
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
+[ -f /etc/sysconfig/scsi_reserve ] && . /etc/sysconfig/scsi_reserve
# check that cman is running
#
if ! cman_tool status &> /dev/null ; then
logger -t scsi_reserve \
"[error] cman does not appear to be running"
exit 1
fi
# check if cluster is configured for fence_scsi
#
if ! fence_scsi_test -t fence ; then
logger -t scsi_reserve \
"[error] cluster not configured for scsi reservations"
exit 1
fi
# check for sg_persist command provided by sg3_utils package
#
if ! sg_persist -V &> /dev/null ; then
logger -t scsi_reserve \
"[error] unable to exec sg_persist"
exit 1
fi
# get physical volumes (devices) that are part of cluster volumes
#
scsi_devices=$( vgs --config 'global { locking_type = 0 }' \
--noheadings -o vg_attr,pv_name 2> /dev/null \
| awk ' $1 ~ /.*c$/ { print $2 } ' )
if [ -z "$scsi_devices" ] ; then
logger -t scsi_reserve \
"[error] did not find devices in cluster volumes"
exit 1
fi
# get the cluster id from cman
#
cluster_id=$( cman_tool status | grep -i "Cluster ID" \
| awk -F": " '{ print $2 }' )
if [ -z "$cluster_id" ] ; then
logger -s -t scsi_reserve \
"[error] unable to determine cluster id"
exit 1
fi
# get the node id from cman
#
node_id=$( cman_tool status | grep -i "Node ID" \
| awk -F": " '{ print $2 }' )
if [ -z "$node_id" ] ; then
logger -t scsi_reserve \
"[error] unable to determine node id"
exit 1
fi
# generate unique key using cluster_id and node_id
#
key=$( printf "%x%.4x" $cluster_id $node_id )
if [ -z "$key" ] ; then
logger -t scsi_reserve \
"[error] unable to generate key"
exit 1
fi
################################################################################
case $1 in
start)
error=0
count=0
echo -n "Starting scsi_reserve:"
for dev in $scsi_devices
do
# check if our key is already resgistered with this device
#
if sg_persist -n -d $dev -i -k | grep -qiE "^[[:space:]]*0x$key" ; then
logger -t scsi_reserve \
"[info] already registered with $dev (key=0x$key)"
continue
fi
# create the scsi registration
#
if ! sg_persist -n -d $dev -o -I -S $key &> /dev/null ; then
logger -t scsi_reserve \
"[error] unable to register device $dev (key=0x$key)"
: $[ count = $count + 1 ]
error=1
else
logger -t scsi_reserve \
"[info] registered with device $dev (key=0x$key)"
fi
# check to see if reservation already exists
#
if sg_persist -n -d $dev -i -r | grep -qiE "^[[:space:]]*Key=0x" ; then
logger -t scsi_reserve \
"[info] reservation already exists on $dev"
continue
fi
# create the scsi reservation
#
if ! sg_persist -n -d $dev -o -R -K $key -T 5 &> /dev/null ; then
logger -t scsi_reserver \
"[error] unable to create reservation on $dev (key=0x$key)"
: $[ count = $count + 1 ]
error=1
fi
done
# leave fence domain if any errors occured during registration
#
if [ $error -eq 0 ] ; then
success
else
logger -t scsi_reserve \
"[info] $count errors during registration"
logger -t scsi_reserve \
"[info] leaving the fence domain"
fence_tool leave
failure
fi
touch /var/lock/subsys/scsi_reserve
echo
;; # end of start
stop)
error=0
count=0
echo -n "Stopping scsi_reserve:"
for dev in $scsi_devices
do
# get list of keys registered with this device
#
key_list=$( sg_persist -n -d $dev -i -k | grep -iE "^[[:space:]]*0x" )
# check that our key is registered with this device
#
if ! sg_persist -d $dev -i -k | grep -qiE "^[[:space:]]*0x$key" ; then
logger -t scsi_reserve \
"[info] not registered with $dev (key=0x$key)"
continue
fi
# check if our key is the reservation holder
#
if sg_persist -n -d $dev -i -r 2>/dev/null | grep -qiE "$key" ; then
if echo "$key_list" | grep -qivE "$key" ; then
logger -t scsi_reserve \
"[error] unable to remove registration on $dev (key=0x$key)"
: $[ count = $count + 1 ]
error=1
continue
fi
fi
# remove registration for this device
#
if ! sg_persist -n -d $dev -o -G -K $key -S 0 &> /dev/null ; then
logger -t scsi_reserve \
"[error] failed to remove registration on $dev (key=0x$key)"
: $[ count = $count + 1 ]
error=1
else
logger -t scsi_reserve \
"[info] removed registration on $dev (key=0x$key)"
fi
done
# report success or failure
#
if [ $error -eq 0 ] ; then
success
else
logger -t scsi_reserve \
"[info] $count errors occured during unregistration"
failure
fi
rm -f /var/lock/subsys/scsi_reserve
echo
;; # end of stop
status)
error=0
for dev in $scsi_devices
do
if sg_persist -n -d $dev -i -k | grep -qiE "$key" ; then
devices[${#devices[@]}]=$dev
fi
done
if [ -z "$devices" ] ; then
echo "No registered devices found."
else
echo "Found ${#devices[@]} registered device(s):"
for i in "${devices[@]}"
do
echo $i
done
fi
;; # end of status
restart|reload)
$0 stop
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit $error
diff --git a/gfs/init.d/gfs b/gfs/init.d/gfs
index 8116db1bc..e212a0462 100644
--- a/gfs/init.d/gfs
+++ b/gfs/init.d/gfs
@@ -1,96 +1,97 @@
#!/bin/bash
#
# gfs mount/unmount helper
#
# chkconfig: - 26 74
# description: mount/unmount gfs filesystems configured in /etc/fstab
### BEGIN INIT INFO
# Provides: gfs
# Required-Start: $network cman
# Required-Stop: $network cman
# Default-Start:
# Default-Stop:
# Short-Description: mount/unmount gfs filesystems configured in /etc/fstab
# Description: mount/unmount gfs filesystems configured in /etc/fstab
### END INIT INFO
. /etc/init.d/functions
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
+[ -f /etc/sysconfig/gfs ] && . /etc/sysconfig/gfs
#
# This script's behavior is modeled closely after the netfs script.
#
GFSFSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "gfs" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
GFSMTAB=$(LC_ALL=C awk '!/^#/ && $3 == "gfs" && $2 != "/" { print $2 }' /proc/mounts)
# See how we were called.
case "$1" in
start)
if [ -n "$GFSFSTAB" ]
then
action $"Mounting GFS filesystems: " mount -a -t gfs
fi
touch /var/lock/subsys/gfs
;;
stop)
if [ -n "$GFSMTAB" ]
then
sig=
retry=6
remaining=`LC_ALL=C awk '!/^#/ && $3 == "gfs" && $2 != "/" {print $2}' /proc/mounts`
while [ -n "$remaining" -a "$retry" -gt 0 ]
do
action $"Unmounting GFS filesystems: " umount -a -t gfs
if [ $retry -eq 0 ]
then
action $"Unmounting GFS filesystems (lazy): " umount -l -a -t gfs
break
fi
sleep 2
remaining=`LC_ALL=C awk '!/^#/ && $3 == "gfs" && $2 != "/" {print $2}' /proc/mounts`
[ -z "$remaining" ] && break
/sbin/fuser -k -m $sig $remaining >/dev/null
sleep 10
retry=$(($retry - 1))
sig=-9
done
fi
modprobe -r gfs
rm -f /var/lock/subsys/gfs
;;
status)
if [ -f /proc/mounts ]
then
[ -n "$GFSFSTAB" ] && {
echo $"Configured GFS mountpoints: "
for fs in $GFSFSTAB; do echo $fs ; done
}
[ -n "$GFSMTAB" ] && {
echo $"Active GFS mountpoints: "
for fs in $GFSMTAB; do echo $fs ; done
}
else
echo "/proc filesystem unavailable"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
diff --git a/gfs2/init.d/gfs2 b/gfs2/init.d/gfs2
index 146d78978..cbe37fd61 100644
--- a/gfs2/init.d/gfs2
+++ b/gfs2/init.d/gfs2
@@ -1,95 +1,96 @@
#!/bin/bash
#
# gfs2 mount/unmount helper
#
# chkconfig: - 26 74
# description: mount/unmount gfs2 filesystems configured in /etc/fstab
### BEGIN INIT INFO
# Provides: gfs2
# Required-Start: $network cman
# Required-Stop: $network cman
# Default-Start:
# Default-Stop:
# Short-Description: mount/unmount gfs2 filesystems configured in /etc/fstab
# Description: mount/unmount gfs2 filesystems configured in /etc/fstab
### END INIT INFO
. /etc/init.d/functions
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
+[ -f /etc/sysconfig/gfs2 ] && . /etc/sysconfig/gfs2
#
# This script's behavior is modeled closely after the netfs script.
#
GFS2FSTAB=$(LC_ALL=C awk '!/^#/ && $3 == "gfs2" && $4 !~ /noauto/ { print $2 }' /etc/fstab)
GFS2MTAB=$(LC_ALL=C awk '!/^#/ && $3 == "gfs2" && $2 != "/" { print $2 }' /proc/mounts)
# See how we were called.
case "$1" in
start)
if [ -n "$GFS2FSTAB" ]
then
action $"Mounting GFS2 filesystems: " mount -a -t gfs2
fi
touch /var/lock/subsys/gfs2
;;
stop)
if [ -n "$GFS2MTAB" ]
then
sig=
retry=6
remaining=`LC_ALL=C awk '!/^#/ && $3 == "gfs2" && $2 != "/" {print $2}' /proc/mounts`
while [ -n "$remaining" -a "$retry" -gt 0 ]
do
action $"Unmounting GFS2 filesystems: " umount -a -t gfs2
if [ $retry -eq 0 ]
then
action $"Unmounting GFS2 filesystems (lazy): " umount -l -a -t gfs2
break
fi
sleep 2
remaining=`LC_ALL=C awk '!/^#/ && $3 == "gfs2" && $2 != "/" {print $2}' /proc/mounts`
[ -z "$remaining" ] && break
/sbin/fuser -k -m $sig $remaining &> /dev/null
sleep 10
retry=$(($retry - 1))
sig=-9
done
fi
rm -f /var/lock/subsys/gfs2
;;
status)
if [ -f /proc/mounts ]
then
[ -n "$GFS2FSTAB" ] && {
echo $"Configured GFS2 mountpoints: "
for fs in $GFS2FSTAB; do echo $fs ; done
}
[ -n "$GFS2MTAB" ] && {
echo $"Active GFS2 mountpoints: "
for fs in $GFS2MTAB; do echo $fs ; done
}
else
echo "/proc filesystem unavailable"
fi
;;
restart)
$0 stop
$0 start
;;
reload)
$0 start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
diff --git a/rgmanager/init.d/rgmanager b/rgmanager/init.d/rgmanager
index d307c1715..361a65e3f 100644
--- a/rgmanager/init.d/rgmanager
+++ b/rgmanager/init.d/rgmanager
@@ -1,141 +1,142 @@
#!/bin/sh
#
# chkconfig: - 99 01
# description: Starts and stops Red Hat Service (resource group) Manager
### BEGIN INIT INFO
# Provides: rgmanager
# Required-Start: cman
# Required-Stop: cman
# Default-Start:
# Default-Stop:
# Short-Description: Starts and stops Red Hat Service (resource group) Manager
# Description: Starts and stops Red Hat Service (resource group) Manager
### END INIT INFO
# Source function library
. /etc/init.d/functions
# Grab cluster start config if it exists
[ -f /etc/sysconfig/cluster ] && . /etc/sysconfig/cluster
+[ -f /etc/sysconfig/rgmanager ] && . /etc/sysconfig/rgmanager
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
ID="Cluster Service Manager"
RGMGRD="clurgmgrd"
LOG_ERR=3
LOG_WARNING=4
LOG_NOTICE=5
LOG_INFO=6
#
# log_and_print <level> <message>
#
log_and_print()
{
if [ -z "$1" -o -z "$2" ]; then
return 1;
fi
clulog -p $$ -n "rgmanager" -s $1 "$2"
echo $2
return 0;
}
#
# Bring down the cluster on a node.
#
stop_cluster()
{
kill -TERM `pidof $RGMGRD`
while [ 0 ]; do
if [ -n "`pidof $RGMGRD`" ]; then
echo -n $"Waiting for services to stop: "
while [ -n "`pidof $RGMGRD`" ]; do
sleep 1
done
echo_success
echo
else
echo $"Services are stopped."
fi
# Ensure all NFS rmtab daemons are dead.
killall $RMTABD &> /dev/null
rm -f /var/run/$RGMGRD.pid
return 0
done
}
case $1 in
start)
echo -n $"Starting $ID: "
daemon $RGMGRD $RGMGR_OPTS
ret=$?
echo
# To be consistent...
if [ $ret -eq 0 ]; then
touch /var/lock/subsys/rgmanager
fi
exit $ret
;;
restart)
$0 status &> /dev/null
if [ $? -ne 1 ]; then
$0 stop
fi
$0 start
;;
condrestart)
$0 status $> /dev/null
if [ $? -eq 0 ]; then
$0 stop
$0 start
fi
;;
reload)
clulog -p $LOG_NOTICE "Reloading Resource Configuration."
echo -n $"Reloading Resource Configuration: "
killproc $RGMGRD -HUP
rv=$?
echo
exit $rv
;;
status)
status $RGMGRD
exit $?
;;
stop)
if [ -n "`pidof $RGMGRD`" ]; then
log_and_print $LOG_NOTICE "Shutting down $ID..."
stop_cluster
fi
rm -f /var/lock/subsys/rgmanager
log_and_print $LOG_NOTICE "$ID is stopped."
;;
*)
echo "usage: $0 {start|restart|condrestart|reload|status|stop}"
exit 1
;;
esac
exit 0

File Metadata

Mime Type
text/x-diff
Expires
Sat, Nov 23, 11:06 AM (1 d, 13 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1018623
Default Alt Text
(32 KB)

Event Timeline