|High Available NFS using DRBD and Heartbeat|
Page 1 of 3NFS is a widely used network filesystem protocol allowing the client to access files over the network as if they are locally stored. To avoid the NFS share to become a SPOF (Single Point Of Failure) you can create a high available NFS share using DRBD and Heartbeat.
First we install the necessary packages on two servers:
yum install ntp ntp-date drbd83 kmod-drbd83 heartbeat nfs-utils nfs-utils-lib portmapand create the partition tables layout for the nfs-shares which has to be identical in size on both servers. I would advice you to create the nfs-share as a LVM partition. LVM allows you to dynamically resize the partition or file system. It can resize volume groups and physical volumes can be added or deleted.
First prepare the drive (in this example /dev/sdb):
fdisk /dev/sdbAnd type
nto create a new partition, followed by
pto create a primairy partition,
1for the partition number, twice an enter for using the drives total capacity and
wfor writing the partition table to the drive
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabelNow create the LVM Physical Volume (VM) on this partition:
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
The number of cylinders for this disk is set to 182401.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
(e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): -l
Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes
255 heads, 63 sectors/track, 182401 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
Command (m for help): n
p primary partition (1-4)
Partition number (1-4): 1
First cylinder (1-182401, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-182401, default 182401):
Using default value 182401
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
pvcreate /dev/sdb1Next create the LVM Volume Group (VG), vg0 with a physical extend size (PE) of 32Mb
vgcreate –s 32M vg0 /dev/sdb1Followed by the creation of the Logical Volume (LV) lv0 on the group vg0 with the max available capacity. To determine the max capacity use:
vgdisplay vg0 | grep "Total PE"and create the LV according to the returned value:
lvcreate –L 49152 –n lv0 vg0next format this volume as ext3 filesystem
mkfs.ext3 /dev/vg0/lv0Do not mount this filesystem at this point!