2007-06-02 00:10:22 +10:00
#!/bin/sh
# script to manage nfs in a clustered environment
2009-11-19 15:00:17 +11:00
. $CTDB_BASE/functions
2007-06-06 12:08:42 +10:00
2009-11-19 15:00:17 +11:00
service_name="nfs"
2011-08-11 09:39:25 +10:00
service_start ()
{
startstop_nfs stop
startstop_nfs start
set_proc "sys/net/ipv4/tcp_tw_recycle" 1
2010-12-16 08:57:46 +11:00
touch "$service_state_dir/update-trigger"
2011-08-11 09:39:25 +10:00
}
service_stop ()
{
startstop_nfs stop
}
2011-08-11 13:55:02 +10:00
service_reconfigure ()
{
startstop_nfs restart
2011-05-23 16:00:05 +10:00
# if the ips have been reallocated, we must restart the lockmanager
# across all nodes and ping all statd listeners
[ -x $CTDB_BASE/statd-callout ] && {
$CTDB_BASE/statd-callout notify &
} >/dev/null 2>&1
2011-08-11 13:55:02 +10:00
}
2008-02-11 09:35:37 +11:00
2009-11-19 15:00:17 +11:00
loadconfig
2010-12-03 15:26:22 -08:00
[ "$NFS_SERVER_MODE" != "GANESHA" ] || exit 0
2010-12-16 08:57:46 +11:00
ctdb_setup_service_state_dir
2009-11-19 15:00:17 +11:00
ctdb_start_stop_service
2008-02-11 09:35:37 +11:00
2010-11-18 13:23:40 +11:00
is_ctdb_managed_service || exit 0
2010-12-16 09:45:28 +11:00
ctdb_service_check_reconfigure
2009-12-01 17:43:47 +11:00
case "$1" in
2010-08-30 18:13:28 +10:00
init)
# read statd from persistent database
;;
2007-06-02 00:10:22 +10:00
startup)
2009-11-19 15:00:17 +11:00
ctdb_service_start
2007-06-02 16:44:15 +10:00
;;
shutdown)
2009-11-19 15:00:17 +11:00
ctdb_service_stop
2007-07-06 10:54:42 +10:00
;;
takeip)
2009-11-19 15:00:17 +11:00
ctdb_service_set_reconfigure
2007-06-02 00:10:22 +10:00
;;
releaseip)
2009-11-19 15:00:17 +11:00
ctdb_service_set_reconfigure
2007-06-02 00:10:22 +10:00
;;
2007-06-06 12:08:42 +10:00
monitor)
2010-12-17 16:25:04 +11:00
# Check that directories for shares actually exist.
2011-08-11 07:13:28 +10:00
[ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
exportfs | grep -v '^#' | grep '^/' |
sed -e 's/[[:space:]]\+[^[:space:]]*$//' |
ctdb_check_directories
} || exit $?
2010-08-26 14:59:59 +10:00
update_tickles 2049
2008-01-21 12:46:11 +11:00
# check that statd responds to rpc requests
2009-09-15 19:33:53 +10:00
# if statd is not running we try to restart it
2011-01-06 15:42:45 +11:00
# we only do this IF we have a rpc.statd command.
# For platforms where rpc.statd does not exist, we skip
2011-01-11 16:17:06 +11:00
# the check completely
2010-12-17 16:25:04 +11:00
p="rpc.statd"
which $p >/dev/null 2>/dev/null && \
nfs_check_rpc_service "statd" \
2011-01-14 09:40:11 +11:00
-ge 6 "verbose unhealthy" \
-eq 4 "verbose restart" \
-eq 2 "restart:bs"
2008-07-08 09:58:10 +10:00
2007-06-06 12:08:42 +10:00
# check that NFS responds to rpc requests
2010-12-17 16:25:04 +11:00
if [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" != "yes" ] ; then
nfs_check_rpc_service "knfsd" \
2011-01-14 09:40:11 +11:00
-ge 6 "verbose unhealthy" \
-eq 4 "verbose restart" \
-eq 2 "restart:bs"
2010-11-17 13:50:56 +11:00
fi
2010-12-17 16:25:04 +11:00
# check that lockd responds to rpc requests
nfs_check_rpc_service "lockd" \
-ge 15 "verbose restart unhealthy" \
-eq 10 "restart:bs"
# mountd is sometimes not started correctly on RHEL5
nfs_check_rpc_service "mountd" \
-ge 10 "verbose restart:b unhealthy" \
-eq 5 "restart:b"
# rquotad is sometimes not started correctly on RHEL5
# not a critical service so we dont flag the node as unhealthy
nfs_check_rpc_service "rquotad" \
-gt 0 "verbose restart:b"
2010-08-30 18:13:28 +10:00
2011-01-21 10:56:56 +11:00
# once every 600 seconds, update the statd state database for which
2010-08-30 18:13:28 +10:00
# clients need notifications
2010-12-16 08:57:46 +11:00
LAST_UPDATE=`stat --printf="%Y" "$service_state_dir/update-trigger"`
2010-08-30 18:13:28 +10:00
CURRENT_TIME=`date +"%s"`
2011-01-21 10:56:56 +11:00
[ $CURRENT_TIME -ge $(($LAST_UPDATE + 600)) ] && {
2010-12-16 08:57:46 +11:00
touch "$service_state_dir/update-trigger"
2010-08-30 18:13:28 +10:00
$CTDB_BASE/statd-callout updatelocal &
$CTDB_BASE/statd-callout updateremote &
}
2008-07-10 08:05:34 +10:00
;;
2007-06-06 12:08:42 +10:00
2009-12-01 17:43:47 +11:00
*)
ctdb_standard_event_handler "$@"
2009-11-19 15:00:17 +11:00
;;
2007-06-02 00:10:22 +10:00
esac
exit 0