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>
Tue, 24 Aug 2010 00:21:39 +0000 (10:21 +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 395728376bf7fca8408832546f0eaf56173d0851..00cceb3ef113c47e0cf7d0d64205e6ed45d4cb0b 100755 (executable)
@@ -75,12 +75,14 @@ case "$1" in
                echo "ERROR: STATD is not responding. Trying to restart it. [rpc.statd $RPCSTATDOPTS]"
        }
 
-       # check that NFS is running
-       service nfs status 2>/dev/null >/dev/null || {
-               echo NFS is not running. Trying to restart NFS.
-               ctdb_service_stop
-               ctdb_service_start
+       # check that NFS responds to rpc requests
+       [ "$CTDB_NFS_SKIP_KNFSD_ALIVE_CHECK" = "yes" ] || {
+           (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 e0d07354039bdee8192c7fc0d297f002198beb0f..05c5ed7ad75b61134c52a7b9b39a4560b496a05a 100755 (executable)
@@ -328,6 +328,9 @@ startstop_nfs() {
                stop)
                        service nfsserver stop > /dev/null 2>&1
                        ;;
+               restart)
+                       service nfsserver restart
+                       ;;
                esac
                ;;
        rhel)
@@ -340,6 +343,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
                ;;
        *)