Controlling DRBD failover with Redhat Cluster Suite
DRBD can be controlled by Redhat Clustering Services to allow you to build failover services. When building our HA system, we had a number of services that we only needed to run on 1 out of 2 nodes at any one time, but which required the same underlying data available on both nodes.
The perfect solution for this is DRBD. We run DRBD in active/passive mode, so that at any one time the services run on just 1 node, but those services can be failed over to the other node and still have all their filesystem based information available.
Firstly get your DRBD up and running, synchronized between the 2 nodes. Once you
have this you should be able to easily promote each server to master and demote them back to slave. There is a script which comes with the DRBD distro, found in scripts/drbddisk, that is often installed by an rpm package into /etc/ha.d/resource.d
This script is very useful and allows you start, stop and check the status of your drbd filesystem. So it's a perfect candidate to be used as an init script within the Cluster Services.
However there is a bit of a problem. When configuring the cluster services
through congo you cannot specify a parameter to a script. This script however requires
a parameter (the name of the drbd block device to use). The simple solution to this
problem is to write a little wrapper script as follows.
#!/bin/sh
exec /etc/ha.d/resource.d/drbddisk r0 $@
In this case, my underlying DRBD device name is known as r0.
All we do here is call the script (which has been installed in /etc/ha.d/resource.d) with
the parameter r0 and any other parameters that are passed in. The cluster management
infrastructure will call this script with start, stop, or status as a parameter, depending on
what action is needed at that time.