Setup a Linux Highly Availability NFS servers

Posted by Planet Malaysia on November 3, 2008

advertisement

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: 10.10.10.11

Hostname: ServerNFS02
IP Address: 10.10.10.12

Linux HA Virtual Hostname: servernfs01
IP Address 10.10.10.10

NFS Client Hostname NFSclient01
IP Address: 10.10.10.13

Require RPM:
nfs-utils
util-linux
heartbeat
portmap

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:
#/etc/ha.d/ha.cf
logfile /var/log/ha-log
logfacility local0
node servernfs01
node servernfs02
keepalive 2
warntime 30
deadtime 60
initdead 120
udpport 694
ucast eth0 10.10.10.11
ucast eth0 10.10.10.12
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
servernfs01 10.10.10.10\
Filesystem::/dev/sdb1::/data::ext3 \
service

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

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

usage(){
#—————————————————————————–
# Spit out usage message
#

cat < USAGE:

$(basename $0) start
$(basename $0) stop
MSG
exit
}

#----------------------------------------------------------------------------
# Main
#

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

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

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

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

Virtual IP Address Information:
eth0:0 Link encap:Ethernet HWaddr 00:50:56:BA:7B:CC
inet addr:10.10.10.10 Bcast:10.10.225.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
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
/data 10.10.10.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync)

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 10.10.10.10:/data /data
2. Type mount and you should see /data mounted on NFS.
10.10.10.10:/data on /data type nfs (rw,addr=10.10.10.10)
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 – 10.10.10.10(please 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 10.10.10.10 on ServerNFS02.

Congratulations! You’re done!

Possibly Related Posts:


Comments

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 www.planetmy.com