DRBD with LVM: Quick installation guide

This is a quick installation guide, based on the official manual by Linbit. It contains nothing new and is more a note than a real guide. I need the commands from time to time, so I thought it might be a good idea to collect all the commands being necessary to get a basic DRBD setup up and running.

I assume that you have two equal Debian 5 machines. Each of them should be equipped with at least two network interfaces.

a) Install the required packages on each machine (replace the kernel and architecture if needed).

apt-get install drbd8-utils drbd8-modules-2.6.26-2-686 lvm2

b) Now configure DRBD with the config file below. Please remember to replace the device, hostname and IP with your setup (drbda and drbdb are the hostnames here).

vim /etc/drbd.conf

global {
usage-count yes;
}

common {
protocol C;
}

resource r0 {
on drbda {
device    /dev/drbd1;
disk      /dev/sda3;
address   192.168.2.35:7789;
meta-disk internal;
}

on drbdb {
device    /dev/drbd1;
disk      /dev/sda3;
address   192.168.2.36:7789;
meta-disk internal;

}
}

c) Initialize the meta data storage.

drbdadm create-md r0

d) Get everything ready (attach device, load resynchronization parameter into the device and connect the DRBD device with the other node):

drbdadm attach r0
drbdadm syncer r0
drbdadm connect r0

Please note that the three commands above are equal to:

drbdadm up r0

e) Check if the DRBD device does now exist and make the first node the primary one. Only use this command on one node.

drbda:/etc# ls -lah /dev/drbd1
brw-rw---- 1 root disk 147, 1 2011-04-17 22:11 /dev/drbd1

drbdadm -- --overwrite-data-of-peer primary r0

f) Watch DRBD doing all the hard work for you:

cat /proc/drbd