2
# script to manage nfs in a clustered environment
7
[ "$CTDB_MANAGES_NFS" = "yes" ] || exit 0
8
[ -z "$STATD_SHARED_DIRECTORY" ] && exit 0
13
PATH=/usr/bin:/bin:/usr/sbin:/sbin:$PATH
19
/bin/mkdir -p $CTDB_BASE/state/nfs
20
/bin/mkdir -p $CTDB_BASE/state/statd/ip
21
/bin/mkdir -p $STATD_SHARED_DIRECTORY
23
/bin/rm -f $CTDB_BASE/state/statd/statd.restart >/dev/null 2>/dev/null
25
# make sure nfs is stopped before we start it, or it may get a bind error
38
echo $ip >> $CTDB_BASE/state/statd/restart
40
# having a list of what IPs we have allows statd to do the right
41
# thing via $CTDB_BASE/statd-callout
42
touch $CTDB_BASE/state/statd/ip/$ip
51
echo $ip >> $CTDB_BASE/state/statd/restart
52
/bin/rm -f $CTDB_BASE/state/statd/ip/$ip
57
# if no IPs have changed then don't need to restart statd
58
[ -f $CTDB_BASE/state/statd/restart ] || exit 0;
60
# always restart the lockmanager so that we start with a clusterwide
61
# graceperiod when ip addresses has changed
62
[ -x $CTDB_BASE/statd-callout ] && {
63
$CTDB_BASE/statd-callout notify &
66
/bin/rm -f $CTDB_BASE/state/statd/restart
70
# check that statd responds to rpc requests
71
# if statd is not running we try to restart it once and wait
72
# for the next monitoring event to verify if it is running or not
73
# if it still fails we fail and mark the node as UNHEALTHY
74
if [ -f $CTDB_BASE/state/statd/statd.restart ]; then
75
# statd was restarted, see if it came up ok
76
rpcinfo -u localhost 100024 1 > /dev/null || {
77
echo "ERROR: Failed to restart STATD"
80
echo "STATD successfully restarted."
81
/bin/rm -f $CTDB_BASE/state/statd/statd.restart
83
rpcinfo -u localhost 100024 1 > /dev/null || {
85
[ -n "$STATD_HOSTNAME" ] && RPCSTATDOPTS="$RPCSTATDOPTS -n $STATD_HOSTNAME"
86
[ -n "$STATD_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -p $STATD_PORT"
87
[ -n "$STATD_OUTGOING_PORT" ] && RPCSTATDOPTS="$RPCSTATDOPTS -o $STATD_OUTGOING_PORT"
88
rpc.statd $RPCSTATDOPTS
89
echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
90
touch $CTDB_BASE/state/statd/statd.restart
95
# check that NFS responds to rpc requests
96
ctdb_check_rpc "NFS" 100003 3
98
# and that its directories are available
99
nfs_dirs=$(grep -v '^#' < /etc/exports | awk {'print $1;'})
100
ctdb_check_directories "nfs" $nfs_dirs
102
# check that lockd responds to rpc requests
103
ctdb_check_rpc "lockd" 100021 1
104
ctdb_check_directories "statd" $STATD_SHARED_DIRECTORY
106
# mount needs special handling since it is sometimes not started
108
rpcinfo -u localhost 100005 1 > /dev/null || {
109
echo "ERROR: MOUNTD is not running. Trying to restart it."
111
[ -n "$MOUNTD_PORT" ] && RPCMOUNTDOPTS="$RPCMOUNTDOPTS -p $MOUNTD_PORT"
112
killall -q -9 rpc.mountd
113
rpc.mountd $RPCMOUNTDOPTS &