DRBD Installation

From Wiki
Jump to: navigation, search


Installation

To set up DRBD services follow these steps. This needs to be done on both nodes.

  • Uncomment the system extras section in /etc/yum.repos.d/yum.system.repo
  • Install DRBD packages.
yum -y install drbd83.x86_64 kmod-drbd83.x86_64

DRBD Configuration

DRBD can be used to replicate any block device. In this case we will be replicating /dev/sdb1 and using /dev/sda6 as the meta device.

Edit /etc/drbd.conf

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

global { usage-count no; }
resource repdata {
  protocol C;
  startup {
        wfc-timeout 0;
        degr-wfc-timeout     120;
  }
  disk { on-io-error detach; } # or panic, ...
  net { 
        cram-hmac-alg "sha1";
        shared-secret "NoawEcKibr7";
        after-sb-0pri discard-zero-changes;
        after-sb-1pri discard-secondary;
        after-sb-2pri disconnect;
  } # don't forget to choose a secret for auth !
  syncer { rate 30M; }
  on drbdtest1.watters.ws {
    device /dev/drbd0;
    disk /dev/sdb1;
    address 192.168.0.1:7788;
    meta-disk /dev/sda6[0];
  }
  on drbdtest2.watters.ws {
    device /dev/drbd0;
    disk /dev/sdb1;
    address 192.168.0.2:7788;
    meta-disk /dev/sda6[0];
  }
}
  • scp /etc/drbd.conf over to the secondary node.
scp /etc/drbd.conf 192.168.0.2:/etc/
  • Initialize DRBD metadata on both nodes.
drbdadm create-md repdata
Note: You may need to zero out the meta device using dd in order to do this. BE CAREFUL WITH THIS COMMAND.
dd if=/dev/zero of=/dev/sda6 bs=1M count=10
  • Start DRBD service on both nodes.
/etc/init.d/drbd start
  • Set one of the servers to be the primary device
drbdsetup /dev/drbd0 primary -o
  • Check the status.
/etc/init.d/drbd status

LVM Configuration

  • Set /etc/lvm/lvm.conf to only look at the DRBD device by adding a filter.
filter = [ "a|drbd.*|", "r|.*|" ]
  • create and rescan devices
pvcreate /dev/drbd0
pvscan

Firewall Update

DRBD uses port 7788 to keep data synchronized and for link detection. Add the following rule to /etc/sysconfig/iptables and restart iptables.

-A RH-Firewall-1-INPUT -i eth1 -m state --state NEW -m tcp -p tcp --dport 7788 -j ACCEPT

The interface should be set to whatever the DRBD private IP is on.

External Links

http://www.drbd.org/users-guide/s-lvm-drbd-as-pv.html