4. drbd.conf Sample Configuration

4.1. drbd.conf

In the previous section, we went over using drbdsteup. drbd also allows you to setup everything in a drbd.conf file. By correctly configuring this file and using the init.d/drbd script you can easily make drbd come up correctly when a machine boots up.

4.2. Sample drbd.conf setup

In this configuration, we have 2 machines named thost1 and thost2. The IP address for thost1 is 10.1.1.31, and the IP address for thost2 is 10.1.1.32. We want to create a mirror between /dev/hda7 on thost1, and /dev/hda7 on machine thost2. Here is a sample /etc/drbd.conf file to accomplish this:

resource drbd0 {
  protocol=B
  fsck-cmd=fsck.ext2 -p -y

  on thost1 {
    device=/dev/nb0
    disk=/dev/hda7
    address=10.1.1.31
    port=7789
  }

  on thost2 {
    device=/dev/nb0
    disk=/dev/hda7
    address=10.1.1.32
    port=7789
  }
}        

After you create the drbd.conf file, go to thost1, and run the following command:

$ /etc/rc.d/init.d/drbd start

Do the same thing on thost2

$ /etc/rc.d/init.d/drbd start

At this point, you should have a mirror between the 2 devices. You can verify this by looking at /proc/drbd

$ cat /proc/drbd

Now you can make a filesystem on the device, and mount it on machine thost1.

$ mkfs /dev/nb0
$ mount /dev/nb0 /mnt/disk

At this point, you have now created a mirror using drbd. Congrats. To move ahead with creating a highly available failover system, look into the the scripts subdirectory and integrate with the heartbeat software available at linux-ha.org