On RHEL, "service nfs stop;service nfs start" and "service nfs restart"
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 18 Aug 2010 21:18:22 +0000 (07:18 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Wed, 18 Aug 2010 21:18:22 +0000 (07:18 +1000)
    sometimes (very rarely) fails to restart the service.

    Add a function to restart NFSd on SLES and RHEL-like systems.

    If we detect the system is unhealthy due to kNFSd not running,
    try to restart the service again "service nfs restart" and
    hope for the best.

CQ1019372

config/events.d/60.nfs
config/functions

index d4037926680f14829f180faacbf6c871a268baa0..637efe8cd75e52aae416387e606f8446b090430f 100755 (executable)
@@ -78,7 +78,12 @@ case "$1" in
 
        # check that NFS responds to rpc requests
        [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
-           ctdb_check_rpc "NFS" 100003 3
+           (ctdb_check_rpc "NFS" 100003 3)
+           [ $? = "0" ] || {
+               echo "Trying to restart NFS service"
+               startstop_nfs restart
+               exit 1
+           }
        }
 
        # and that its directories are available
index 69c5ce1cfb1085f519c3580d9129555875ba2508..35b7db2e61a8eda41c08f6929aaa25db461ac29c 100755 (executable)
@@ -366,6 +366,9 @@ startstop_nfs() {
                stop)
                        service nfsserver stop > /dev/null 2>&1
                        ;;
+               restart)
+                       service nfsserver restart
+                       ;;
                esac
                ;;
        rhel)
@@ -378,6 +381,10 @@ startstop_nfs() {
                        service nfs stop > /dev/null 2>&1
                        service nfslock stop > /dev/null 2>&1
                        ;;
+               restart)
+                       service nfslock restart
+                       service nfs restart
+                       ;;
                esac
                ;;
        *)