Active Vserver Failover
To perform active vserver failover without user intervention from one host to another you may use heartbeat. To do this, you must first have a mechanism to actively replicate your veserver filesystem and configuration from one host to another. This mechanism must be able to provide a consistent filesystem view to either host on demand (but not neccessarily at the same time). In other words you may use something like NFS, a clustered filesystem like OCFS2 or GFS, or a network replicated block device like drbd, but you cannot use something like rsync, scp or ftp.
Once you have an active replication method, you will likely need to organize your vserver files to be on the same device/filesystem so that you only need one replicated device/filesystem and do not need a separate one just for your vserver configuration files. One way to do this would be to use a /vservers mount point and to have a subdirectory for each vserver in there: /vservers/<server-name>. Since you will want to put both the /var and /etc sections of your vserver in the vserver's subdirectory and soft link to them, it will probably end up looking something like this:
/etc/vservers/<server-name> -> /vservers/<server-name>/etc /var/lib/vservers/<server-name> -> /vservers/<server-name>/var
With this arrangement you could replicate the entire /vservers directory to all hosts and you will than be able to run the vserver anywhere the /vservers directory is replicated.
Finally, you will need a mechanism to start and stop your vservers on the appropriate hosts. This is where heartbeat comes in. If you do not have a permanently mounted filesystem on each node (because you are using a non-shared block device such as drbd 7,) you will need to configure heartbeat to first provide the /vservers file system on the node which is going to be the active host. Once you have configured your filesystem for failover you can configure the vservers themselves for failover. If you want to control more than one vserver with heartbeat, you may use the following vserver ocf agent to do so. Be sure to specify a colocation constraint between the filesystem and your vservers. You will also need to specify an oderering constraint to be sure that the filesystem is mounted before the vservers are started. Here is a sample ocf vserver configuration for a vserver named foo and an ocf provider named bar:
<primitive id="vserver_foo" class="ocf" type="VServer" provider="bar" restart_type="restart"> <instance_attributes id="vserver_foo_ia"> <attributes> <nvpair id="vserver_foo_name" name="vserver" value="foo"/> </attributes> </instance_attributes> </primitive>
The ocf provider is simply a fancy term for the directory name under /usr/lib/ocf/resource.d/ where you place your ocf agent. The ocf agents distributed with heartbeat are in the heartbeat subdirectory and therefor the provider for them is heartbeat.