Setup a Linux Highly Availability NFS servers

Posted by Planet Malaysia on November 3, 2008


In this tutorial I will describe how to set up a Linux Highly Availability(HA) NFS servers using SuSE Linux Enterprise Server 10 SP2. In order to make Linux HA NFS failover work, you’re require “sm-notify” utility, basically sm-notify will send out Network Status Monitor(NSM) reboot notifications.

Here are the steps to prepare automated NFS failover.

Server setup details:
Hostname: ServerNFS01
IP Address:

Hostname: ServerNFS02
IP Address:

Linux HA Virtual Hostname: servernfs01
IP Address

NFS Client Hostname NFSclient01
IP Address:

Require RPM:

The /data directory is a Linux HA share drive sitting on /dev/sdb1(ext3) and contains NFS share drive.

Create a new partition using fdisk
# fdisk /dev/sdb

Format /dev/sdb1 as ext3
# mkfs.ext3 /dev/sdb1

Create new folder /data
# mkdir /data

Linux HA configuration file:
logfile /var/log/ha-log
logfacility local0
node servernfs01
node servernfs02
keepalive 2
warntime 30
deadtime 60
initdead 120
udpport 694
ucast eth0
ucast eth0
auto_failback off
respawn hacluster /usr/lib/heartbeat/ipfail
watchdog /dev/watchdog

# /etc/ha.d/authkeys
auth 2
2 sha1 NFS_test!

# /etc/ha.d/haresources
Filesystem::/dev/sdb1::/data::ext3 \

# cat /etc/ha.d/resource.d/service

# Script START here
# service – Linux HA stop and start script

# Spit out usage message

cat < USAGE:

$(basename $0) start
$(basename $0) stop

# Main

if [ "$(id -u)" != 0 ]; then
echo "Error: Must be root to run this program."

if [ "$#" != 1 ];then

case $1 in
echo -n Starting NFS . . .
#Restarting NFS server
/etc/init.d/nfsserver restart
#Virtual IP
/sbin/sm-notify -v

echo -n Stopping NFS . . .
#Stopping NFS server
/etc/init.d/nfsserver stop
#Virtual IP
/sbin/sm-notify -v
# Script END here

Virtual IP Address Information:
eth0:0 Link encap:Ethernet HWaddr 00:50:56:BA:7B:CC
inet addr: Bcast: Mask:
Interrupt:177 Base address:0x1424

Move existing NFS server files to Linux HA share drive
# mv /var/lib/nfs /data
# mv /etc/exports /data

Create a symbolic link for NFS server
# ln -s /data/nfs /var/lib/nfs
# ln -s /data/exports /etc/exports

# cat /etc/exports

For ServerNFS01 & ServerNFS02, you’re require
# chkconfig nfsserver off
# chkconfig portmap on
# chkconfig nfsboot off
# chkconfig nfs off
# chkconfig heartbeat on

Please make sure you have NFS services ON for your NFS client machine – NFSclient01
# chkconfig nfs on

Let’s start TESTING ….
1. Login to NFSclient01 and type mkdir /data ; mount -t nfs /data
2. Type mount and you should see /data mounted on NFS. on /data type nfs (rw,addr=
3. Power Off ServerNFS01 immediately.
4. Linux HA will take over by ServerNFS02.
3. Type ifconfig on ServerNFS02 and you should able to see virtual IP address – wait for a while to see it running).
4. Type /etc/init.d/nfsserver status and you should see NFS server running on node2.
5. Go back to NFSclient01, type ls -l /data or mount and you should see as usual which is mounted on virtual IP address on ServerNFS02.

Congratulations! You’re done!

Possibly Related Posts:


One Response to “Setup a Linux Highly Availability NFS servers”

  1. Wing Loon on November 3rd, 2008 7:03 pm

    Always wanted to setup this. Now, I can refer to this. Thanks, :)

Leave a Reply

Planet Malaysia

  • Follow us on Twitter

  • web