This post is no longer up-to-date. See this one.

When you’re clustering machines, a distributed remote block device (DRBD) comes in handy. It’s basically RAID1 over a network. I used Ubuntu Server 9.10 to create a test drbd setup.

First install drbd:

aptitude -P install drbd8-utils

Then put this config, with modifcations, on both nodes:

global {
  usage-count no;
}
common {
  protocol C;
 
  handlers {
    split-brain "/usr/lib/drbd/notify-split-brain.sh wiebe@halfgaar.net";
  }
 
  syncer {
    # The default is supposed to be maximum speed, but it was dead slow without this directive
    rate 500k;
    csums-alg md5;
  }
 
  disk {
    on-io-error detach;
  }
 
  net {
    data-integrity-alg md5;
  }
}
resource r0 {
  meta-disk internal;
  disk      /dev/sda2;
  device    /dev/drbd1;
 
  on storage00 {
    address   192.168.1.50:7789;
  }
  on storage01 {
    address   192.168.1.51:7789;
  }
}

Then on both nodes:

  • drbdadm create-md r0
  • drbdadm up r0

Then on the primary node, execute this to start the sync:

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

Data from the current node will now be used as base.

You can also make a drbd device with data on one of the underlying devices, but I didn’t try that, so go to the drbd website for docs on that.