Setting Up A Highly Available NFS Server - Page 3
6 Configure DRBD
Now we load the DRBD kernel module on both server1 and server2. We need to do this only now because afterwards it will be loaded by the DRBD init script.
Let's configure DRBD:
drbdadm up all
The last command should show something like this (on both server1 and server2):
You see that both NFS servers say that they are secondary and that the data is inconsistant. This is because no initial sync has been made yet.
I want to make server1 the primary NFS server and server2 the "hot-standby", If server1 fails, server2 takes over, and if server1 comes back then all data that has changed in the meantime is mirrored back from server2 to server1 so that data is always consistent.
This next step has to be done only on server1!
drbdadm -- --do-what-I-say primary all
Now we start the initial sync between server1 and server2 so that the data on both servers becomes consistent. On server1, we do this:
drbdadm -- connect all
The initial sync is going to take a few hours (depending on the size of /dev/sda8 (/dev/hda8...)) so please be patient.
You can see the progress of the initial sync like this on server1 or server2:
The output should look like this:
When the initial sync is finished, the output should look like this:
7 Some Further NFS Configuration
NFS stores some important information (e.g. information about file locks, etc.) in /var/lib/nfs. Now what happens if server1 goes down? server2 takes over, but its information in /var/lib/nfs will be different from the information in server1's /var/lib/nfs directory. Therefore we do some tweaking so that these details will be stored on our /data partition (/dev/sda8 or /dev/hda8...) which is mirrored by DRBD between server1 and server2. So if server1 goes down server2 can use the NFS details of server1.
mount -t ext3 /dev/drbd0 /data
rm -fr /var/lib/nfs/