2007-06-01 18:10:22 +04:00
#!/bin/sh
# script to manage nfs in a clustered environment
2013-01-03 08:26:12 +04:00
[ -n "$CTDB_BASE" ] || \
export CTDB_BASE=$(cd -P $(dirname "$0") ; dirname "$PWD")
2009-11-19 07:00:17 +03:00
. $CTDB_BASE/functions
2007-06-06 06:08:42 +04:00
2009-11-19 07:00:17 +03:00
service_name="nfs"
2011-08-11 03:39:25 +04:00
service_start ()
{
startstop_nfs stop
startstop_nfs start
set_proc "sys/net/ipv4/tcp_tw_recycle" 1
}
service_stop ()
{
startstop_nfs stop
}
2011-08-11 07:55:02 +04:00
service_reconfigure ()
{
2011-05-23 10:00:05 +04: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 07:55:02 +04:00
}
2008-02-11 01:35:37 +03:00
2009-11-19 07:00:17 +03:00
loadconfig
2012-05-16 11:24:21 +04:00
[ "$NFS_SERVER_MODE" != "ganesha" ] || exit 0
2010-12-04 02:26:22 +03:00
2010-12-16 00:57:46 +03:00
ctdb_setup_service_state_dir
2011-08-16 07:28:40 +04:00
statd_update_trigger="$service_state_dir/update-trigger"
# We want this file to always exist. The corner case is when
# auto-start/stop is switched off, NFS is added as a managed service
# some time after ctdbd is started and someone else starts the NFS
# service for us. In this case this file might not otherwise exist
# when we get to a monitor event.
touch "$statd_update_trigger"
2009-11-19 07:00:17 +03:00
ctdb_start_stop_service
2008-02-11 01:35:37 +03:00
2010-11-18 05:23:40 +03:00
is_ctdb_managed_service || exit 0
2010-12-16 01:45:28 +03:00
ctdb_service_check_reconfigure
2009-12-01 09:43:47 +03:00
case "$1" in
2010-08-30 12:13:28 +04:00
init)
# read statd from persistent database
;;
2007-06-01 18:10:22 +04:00
startup)
2009-11-19 07:00:17 +03:00
ctdb_service_start
2007-06-02 10:44:15 +04:00
;;
shutdown)
2009-11-19 07:00:17 +03:00
ctdb_service_stop
2007-07-06 04:54:42 +04:00
;;
takeip)
2009-11-19 07:00:17 +03:00
ctdb_service_set_reconfigure
2007-06-01 18:10:22 +04:00
;;
releaseip)
2009-11-19 07:00:17 +03:00
ctdb_service_set_reconfigure
2007-06-01 18:10:22 +04:00
;;
2007-06-06 06:08:42 +04:00
monitor)
2010-12-17 08:25:04 +03:00
# Check that directories for shares actually exist.
2011-08-11 01:13:28 +04:00
[ "$CTDB_NFS_SKIP_SHARE_CHECK" = "yes" ] || {
2011-04-13 06:37:42 +04:00
exportfs -v | grep '^/' |
sed -r -e 's@[[:space:]]+[^[:space:]()]+\([^[:space:]()]+\)$@@' |
2011-08-17 11:42:07 +04:00
sort -u |
2011-04-13 06:37:42 +04:00
ctdb_check_directories
2011-08-11 01:13:28 +04:00
} || exit $?
2010-08-26 08:59:59 +04:00
update_tickles 2049
2008-01-21 04:46:11 +03:00
# check that statd responds to rpc requests
2013-04-22 23:54:12 +04:00
nfs_check_rpc_service "statd" \
-ge 6 "verbose unhealthy" \
-eq 4 "verbose restart" \
-eq 2 "restart:bs"
2008-07-08 03:58:10 +04:00
2007-06-06 06:08:42 +04:00
# check that NFS responds to rpc requests
2010-12-17 08:25:04 +03:00
if [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" != "yes" ] ; then
nfs_check_rpc_service "knfsd" \
2011-01-14 01:40:11 +03:00
-ge 6 "verbose unhealthy" \
-eq 4 "verbose restart" \
-eq 2 "restart:bs"
2010-11-17 05:50:56 +03:00
fi
2010-12-17 08:25:04 +03:00
# check that lockd responds to rpc requests
nfs_check_rpc_service "lockd" \
2012-05-16 07:29:58 +04:00
-ge 15 "verbose restart:b unhealthy" \
2010-12-17 08:25:04 +03:00
-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 12:13:28 +04:00
2011-01-21 02:56:56 +03:00
# once every 600 seconds, update the statd state database for which
2010-08-30 12:13:28 +04:00
# clients need notifications
2011-08-16 07:28:40 +04:00
LAST_UPDATE=`stat --printf="%Y" "$statd_update_trigger"`
2010-08-30 12:13:28 +04:00
CURRENT_TIME=`date +"%s"`
2011-01-21 02:56:56 +03:00
[ $CURRENT_TIME -ge $(($LAST_UPDATE + 600)) ] && {
2011-08-16 07:28:40 +04:00
touch "$statd_update_trigger"
2010-08-30 12:13:28 +04:00
$CTDB_BASE/statd-callout updatelocal &
$CTDB_BASE/statd-callout updateremote &
}
2008-07-10 02:05:34 +04:00
;;
2007-06-06 06:08:42 +04:00
2009-12-01 09:43:47 +03:00
*)
ctdb_standard_event_handler "$@"
2009-11-19 07:00:17 +03:00
;;
2007-06-01 18:10:22 +04:00
esac
exit 0