Wednesday, June 3, 2009

NFS Cluster setup - a Quick HowTo

This is a quick HowTo for NFS Cluster setup.

Required setup (NFS Cluster setup - a Quick HowTo):
(This requirement is as per our assumpsion , you can customise it further as per requirement)
Server1: Debain Linux installed with NFS server and client package with one private ip address
Server2:                               --- same ------

One virtual ip address for fail over.

/data/share partition will be mirrored by DRBD.

Proposed partitions for each NFS servers.

/dev/md0 -- 500 MB /boot (primary, ext3, Bootable flag: on)
/dev/md1 -- 10000 MB / (logical, ext3)
/dev/md2 - Double of RAM swap (logical)
/dev/md3 -- 200 MB un mounted (logical, ext3) (will contain DRBD's meta data) 
/dev/md4 -- 100 GB un mounted (logical, ext3) (will contain the /data/sharedirectory)


Steps (NFS Cluster setup - a Quick HowTo):

After Linux installation 

1. Check all partitions are ok and /dev/md3 and /dev/md4 are un mounted.(Tag - NFS Cluster setup)
2. Install NTP and update time in both servers 
3. Install NF Server - apt-get install nfs-kernel-server. (Tag - NFS Cluster setup)
4. Remove from auto boot 
update-rc.d -f nfs-kernel-server remove (Tag - NFS Cluster setup)
update-rc.d -f nfs-common remove  (Tag - NFS Cluster setup)

5. Edit /etc/exports  (Tag - NFS Cluster setup)
Put /data/share 192.168.1.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync)
6. Install DRBD on both servers (Tag - NFS Cluster setup)
apt-get install kernel-headers-2.6.8-2-386 drbd0.7-module-source drbd0.7-utils
cd /usr/src/  (Tag - NFS Cluster setup)
tar xvfz drbd0.7.tar.gz
cd modules/drbd/drbd
make
make install  (Tag - NFS Cluster setup)

7. Configure on both servers (NFS Cluster setup - a Quick HowTo) (Tag - NFS Cluster setup)

Edit /etc/drbd.conf (Tag - NFS Cluster setup)

resource r0 {

 protocol C;
 incon-degr-cmd "halt -f";

 startup {
    degr-wfc-timeout 120;    # 2 minutes.
  }

  disk {
    on-io-error   detach;
  }

  net {

  }

  syncer {

    rate 10M;

    group 1;

    al-extents 257;
  }

 on server1 {                
   device     /dev/drbd0;       
   disk       /dev/md4;         
   address    192.168.1.xx:7788; 
   meta-disk  /dev/md3[0];      
  }

 on server2 {                
   device    /dev/drbd0;        
   disk      /dev/md4;          
   address   192.168.1.xx:7788; 
   meta-disk /dev/md3[0];       
  }

}



modprobe drbd
drbdadm up all
cat /proc/drbd


11. server1/server2 (NFS Cluster setup - a Quick HowTo): (Tag - NFS Cluster setup)
mkdir /data
server1:
mount -t ext3 /dev/drbd0 /data
mv /var/lib/nfs/ /data/
ln -s /data/nfs/ /var/lib/nfs
mkdir /data/share
umount /data
server2:
rm -fr /var/lib/nfs/
ln -s /data/nfs/ /var/lib/nfs

12. Install and configure Heartbeat (Tag - NFS Cluster setup)
apt-get install heartbeat
edit /etc/heartbeat/ha.cf
logfacility     local0
keepalive 2
#deadtime 30 # USE THIS!!!
deadtime 10
bcast   eth0
node server1 server2

 
edit /etc/heartbeat/haresources   (Tag - NFS Cluster setup)
server1  IPaddr::192.168.1.xx/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/data::ext3 nfs-kernel-server

/etc/heartbeat/authkeys    (Tag - NFS Cluster setup)
auth 3
3 md5 somerandomstring

chmod 600 /etc/heartbeat/authkeys  (Tag - NFS Cluster setup)
/etc/init.d/drbd start
/etc/init.d/heartbeat start

No comments: