DRBD on Ubuntu Dapper Drake and Gentoo

I'm currently building a Linux-HA cluster with a DRBD filesystem and wanted to check out how DRBD would work accross different distributions. To test DRDB I used an Ububtu and a Gentoo host and two loop devices of 256MB each (by default, DRBD uses 128MB for itself). Ubuntu Dapper has DRBD 0.7.15 on Kernel 2.6.15-25-386, while on Gentoo I got 0.7.18 with Kernel 2.6.15-gentoo-r1.

Install the DRBD module on the Ubuntu host

The build failed first because the Kernel headers are not listed as a build dependency in the source package and I did not have them installed. Once the Kernel headers and other build dependencies (bison and flex) installed I simply called the Debian module-assistant:

sudo apt-get install linux-headers-2.6.15-25-386
sudo apt-get install drbd0.7-module-source
sudo m-a a-i drbd0.7-module-source

This builds the drbd module kernel/drivers/block/drbd.ko against the current running kernel (if it doesn't find an already built module).

A default configuration file is installed as /etc/drbd.conf

The Linux-HA resource you will most probably need when configuring DRBD for a Linux-HA cluster gets installed as /etc/ha.d/resource.d/drbddisk.

Load the module

sudo update-modules
sudo modprobe drbd

Install the DRBD module on the Gentoo host

emerge -av sys-cluster/drbd

This installs the DRBD module /lib/modules/2.6.15-gentoo-r1/kernel/drivers/block/drbd.ko

A default configuration file is installed into /usr/share/doc/drbd-0.7.18/drbd.conf.gz

The Linux-HA resource you will most probably need when configuring DRBD for a Linux-HA cluster gets installed as /etc/ha.d/resource.d/drbddisk.

Load the module

sudo update-modules
sudo modprobe drbd

Configuration

As I did not feel like the hosts rebooting on failure tests I changed the incon-degr-cmd to send an e-mail instead of the default halt -f:

incon-degr-cmd "echo '!DRBD! pri on incon-degr' | mail user@example.com ; sleep 60";

Create the devices

dd if=/dev/zero of=/var/tmp/drdb0 bs=1k count=262144
# losetup -f
losetup /dev/loop0 /var/tmp/drdb0

# on both nodes
/etc/init.d/drbd start 

The DRBD device is in state Inconsistent when DRBD is started on both nodes:

cat /proc/drbd
version: 0.7.15 (api:77/proto:74)
SVN Revision: 2020 build by root@right, 2006-06-22 22:33:02
0: cs:Connected st:Secondary/Secondary ld:Inconsistent
   ns:0 nr:0 dw:0 dr:0 al:0 bm:16 lo:0 pe:0 ua:0 ap:0
1: cs:Unconfigured

Force it to begin synchronizing the devices:

drbdadm -- --do-what-I-say primary all 

version: 0.7.18 (api:78/proto:74)
SVN Revision: 2176 build by root@left, 2006-06-22 22:47:22
0: cs:SyncSource st:Primary/Secondary ld:Consistent
   ns:127944 nr:0 dw:0 dr:128136 al:0 bm:7 lo:0 pe:49 ua:48 ap:0
       [===================>] sync'ed:100.0% (3320/131072)K
       finish: 0:00:00 speed: 13,148 (10,644) K/sec
On left
   mke2fs -j /dev/drbd0
   mkdir /mnt/drbd0
   mount /dev/drbd0 /mnt/drbd0/
   # write some file to /mnt/drbd0/, create md5sum

Note that the filesystem can only be mounted on one of the two host.

Switch over to the other node

On left
    umount /mnt/drbd0 && drbdadm secondary all
On right
   drbdadm primary all
   mount /dev/drbd0 /mnt/drbd0/
   # check the file, verify md5sum
mike – Thu, 2006 – 06 – 29 19:31