Highly redundant FS server with DRBD

I got to work on a pretty cool piece of hardware lately in order to setup a highly redundant FS server. This is on Centos 5.x, you will need to grab the following packages from CentOS+: drbd83, kmod-drbd83, make sure you exactly match your kernel revision, you can grab the RPMS from the official mirror And also the OCFS2 from Oracle, this is available here for the kernel modules and here for the tools. Again, make sure this matches your kernel. You can now load this up: modprobe -v drbd.

Before preparing your config, please make sure you have two disk slices matching in blocks/cylinders, otherwise this will not work. In this example we use two local machines 192.168.6.66 and 6.67. You must now prepare the configuration file, edit /etc/drbd.conf (which should be empty):

#
# please have a a look at the example configuration file in
# /usr/share/doc/drbd83/drbd.conf
#

global { usage-count yes; }

# you may want to lower the rate, if you're not using a dedicated GBit link 
# between both peers; 20M worked well on EC2
common { syncer { rate 100M; } }

resource res0 {
  protocol C;
  startup {
    wfc-timeout 20;
    degr-wfc-timeout 10;
    # we will keep this commented until tested successfully:
    # become-primary-on both; 
  }
  net {
    # the encryption part can be omitted when using a dedicated link for DRBD only:
    cram-hmac-alg sha1;
    shared-secret ubersecret;

    allow-two-primaries;
    after-sb-0pri discard-zero-changes;
    after-sb-1pri discard-secondary;
    after-sb-2pri disconnect;
  }
  on tic.example.com {
    device /dev/drbd1;
    disk /dev/sdb1;
    address 192.168.6.66:7789;
    meta-disk internal;
  }
  on tac.example.com {
    device /dev/drbd1;
    disk /dev/sdb1;
    address 192.168.6.67:7789;
    meta-disk internal;
  }
  disk {
    fencing dont-care;
  }
}

Copy that config over to the second machine then create it, you will need to type that command on BOTH boxes: drbdadm create-md res0. It will not work if your hostname does not match your configuration. All going well, it should initialize on both, once done, you can start the service on the two boxes together (do not wait too long): service drbd start. If they both started without a hitch, you are ready to sync up the data. An important consideration is a local network for this setup, all the syncing will go over the network so a dedicated link is a good idea (a simple cable from one box to another on private address is more than adequate unless you plan more boxes which is beyond the topic of this article).

You are now ready to make it sync, choose your master and type the following command: drbdadm — –overwrite-data-of-peer primary res0, all going well, you can watch its progress with: drbd-overview.

Once this is done, you can set the two boxes as masters, which is something I want since I will be using a virtual IP, you can promote the second box as master with: drbdadm primary res0 then you can uncomment on both servers the following line: become-primary-on both;.

That’s all folks! 🙂

A big thanks to this article. And of course, take a look at the official site for more information.

2 thoughts on “Highly redundant FS server with DRBD

  1. Nice article Stephane. I’d link to drbd.org too which has very good overviews and diagrams, and describes how clustering file systems like OCFS2 and GFS etc. are only needed for active-active, while any old file system will work in active-passive.

Comments are closed.