Jun 192011
 

As I’ve been written on my previous post about Maildir Replication using ChironFS in postfix, I will explain step by step it can also be done by using drbd and ocfs2.

Compiling & Installing

note: if your Linux distribution is shipped with a kernel older than 2.6.33 you have to install a kernel module package and packages for the user land code. If your distribution contains a Linux-2.6.33 kernel or newer you only need to install the user land code.

In my case i have my linux distribution older than 2.6.33, so i will also compile drbd kernel module.

Download drbd source and create Binary RPMS packages

$ wget http://oss.linbit.com/drbd/8.3/drbd-8.3.10.tar.gz
$ tar xvzf drbd-8.3.10.tar.gz
$ cd drbd-8.3.10
$ ./configure --enable-spec --with-km
$ cp ../drbd*.tar.gz `rpm -E %_sourcedir`
$ rpmbuild -bb drbd.spec
$ rpmbuild -bb drbd-km.spec
$ sudo rpm -ivh /path/to/RPMS/drbd-*

I’ll be using loop files for this setup since I don’t have access to raw partitions. but if you have raw block device available you can subtitute this part:

resource r0 {
	meta-disk internal;
	device /dev/drbd0;
	disk /dev/loop0;

Into:

resource r0 {
	meta-disk internal;
	device /dev/drbd0;
	disk /dev/sdxx;

sdxx can be sda1, sdb1 sdb2 or what ever your raw disk device called

# dd if=/dev/zero of=/drbd-postfix.img bs=1M count=5000
# losetup /dev/loop0 /drbd-postfix.img

Place this DRBD resource file in /etc/drbd.d/r0.res. Be sure to adjust the server names and IP addresses for your servers.

resource r0 {
	meta-disk internal;
	device /dev/drbd0;
	disk /dev/loop0;

	syncer { rate 1000M; }
        net {
                allow-two-primaries;
                after-sb-0pri discard-zero-changes;
                after-sb-1pri discard-secondary;
                after-sb-2pri disconnect;
        }
	startup { become-primary-on both; }

	on postfix1 { address 192.168.200.18:7789; }
	on postfix2 { address 192.168.200.114:7789; }
}

Continue reading »