RND GROUP LIMITED HomeCapabilitiesAbout usContact us

How to install and configure DRBD for file system replication

January 18th, 2007

The following will configure DRBD in a primary/secondary configuration.

 

  1. Install the required packages from the CentOS Extras repository
    1. yum groupinstall drbd-heartbeat
    2. yum install kernel-module-drbd-`uname –r`
  2. Create the drbd devices in /dev (if they don’t already exist)
    1. for i in $(seq 0 15) ; do mknod /dev/drbd$i b 147 $i ; done
  3. Prepare the respective partition(s) (choose the default partition type)
  4. Configure the /etc/drbd.conf (below is an example)
  5. On the master execute the following
    1. drbdadm adjust [resource name] (i.e. drbdadm adjust r0)
    2. drbdsetup [drbd block device] primary –do-what-I-say (i.e. drbdsetup /dev/drbd0 primary –do-what-I-say)
  6. You should see in /proc/drbd that the devices are syncing, wait until they have finished syncing before progressing
    1. cat /proc/drbd
  7. You should now be able to make your respective file system on them (in our example we used ext3)
    1. mkfs.[file system type] [drbd block device] (i.e. mkfs.ext3 /dev/drbd0)
  8. Now your DRBD device should be ready to use

 

Example Configuration

 

#

# drbd.conf

#

 

resource r0 {

  protocol C;

  incon-degr-cmd “echo ‘!DRBD! pri on incon-degr’ | wall ; sleep 60 ; halt -f”;

 

  startup {

    degr-wfc-timeout 120;    # 2 minutes.

  }

 

  disk {

    on-io-error   detach;

  }

 

  net {

  }

 

  syncer {

    rate 10M;

    group 1;

    al-extents 257;

  }

 

  on vm-drbd1 {

    device    /dev/drbd0;

    disk      /dev/sdb1;

    address   192.168.2.107:7788;

    meta-disk internal;

  }

 

  on vm-drbd2 {

    device    /dev/drbd0;

    disk      /dev/sdb1;

    address   192.168.2.108:7788;

    meta-disk internal;

  }

}

 

Assumptions

 

  • The configuration is going to be configured on a CentOS 4.4 or greater CentOS 4 server
  • There is Ethernet connectivity between all devices within the cluster

 

Notes

 

  • http://lists.centos.org/pipermail/centos-announce/2005-November/012446.html
  • Ensure if you have a firewall configured its configured to allow the respective TCP traffic through
  • Currently under DRBD you are only able to mount the file system on the primary server.  You may how ever on the primary server export the file system using NFS and mount it on the secondary server (this is outside of the scope of this document)
  • Once you have configured your DRBD device you should look at the HA tools to automate the fail over facility (this is outside of the scope of this document)
  • It is very important to ensure that ntp is running on all nodes within the cluster
  • While DRBD works if you intend to use this within a mission critical environment and the budget for the project permits we suggest you review some commercially available HA file systems