next up previous
Next: Moving Data Up: HA and heartbeat Previous: resources

Mounting partitions

Since there are many configuration files, spool files and other data files for the system, we had to find a solution that allowed the system to mount them when drbd came up. If we mirrored the drives at boot time, the secondary system wouldn't boot, since the secondary's mirrored partition can't be mounted in read/write mode until it's time to take over from the primary. Typically you mount a single drive or partition, and mirror that with drbd.

In this setup we needed things like /var/lib, /var/spool, /var/opt and /home to be mirrored on both systems. However in order to boot parts of those partitions have to be available at boot time. Our solution was to create one mount point, and then bind mount the various data and configuration file directories imediately afterwards. To do this we needed to create a custom resource.d script for HA. Scripts that you intend to run when the system becomes active are put in /etc/ha.d/resources.d and run by HA when that system takes over. A second requirement is that all scripts in /etc/ha.d/resources.d/ require two arguments ``start'' and ``stop''. For lack of a creative name, we called it remount and it looks like this:

#!/bin/sh
#
# $Id: remount
#
# This script is a test resource for introducing remount.
#
# usage: $0 {start|stop|restart}
# usage: $0 remount {start|stop|restart}
#
#

. /etc/ha.d/shellfuncs

VARLIB=/var/lib/heartbeat
VLFILE=$VARLIB/rsctmp/Remount
prefix=/bin

case "$1" in
start)
    $prefix/mount -bind /mnt/home /home
    $prefix/mount -bind /mnt/srv /srv
    $prefix/mount -bind /mnt/lib/dhcp /var/lib/dhcp
    $prefix/mount -bind /mnt/lib/httpd /var/lib/httpd
    $prefix/mount -bind /mnt/lib/imap /var/lib/imap
    $prefix/mount -bind /mnt/lib/ldap /var/lib/ldap
    $prefix/mount -bind /mnt/lib/mailgraph /var/lib/mailgraph
    $prefix/mount -bind /mnt/named /var/named
    $prefix/mount -bind /mnt/lib/pgsql /var/lib/pgsql
    $prefix/mount -bind /mnt/lib/samba /var/lib/samba
    $prefix/mount -bind /mnt/lib/sieve /var/lib/sieve
    $prefix/mount -bind /mnt/lib/wwwrun /var/lib/wwwrun
    $prefix/mount -bind /mnt/opt /var/opt
    $prefix/mount -bind /mnt/spool /var/spool
    ;;
stop)
    $prefix/umount /home
    $prefix/umount /srv
    $prefix/umount /var/lib/dhcp
    $prefix/umount /var/lib/httpd
    $prefix/umount /var/lib/imap
    $prefix/umount /var/lib/ldap
    $prefix/umount /var/named
    $prefix/umount /var/lib/mailgraph
    $prefix/umount /var/lib/pgsql
    $prefix/umount /var/lib/samba
    $prefix/umount /var/lib/sieve
    $prefix/umount /var/lib/wwwrun
    $prefix/umount /var/opt
    $prefix/umount /var/spool
    ;;
restart)
     #
     # Stop the service and regardless of whether it was
     #
     # running or not, start it again.
     $0 stop
     $0 start
     ;;
*)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    ;;
esac
exit $?



next up previous
Next: Moving Data Up: HA and heartbeat Previous: resources