DRBD on Centos
Installation
Centos 7
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm yum -y install drbd84-utils kmod-drbd84
Centos 6
rpm --import http://elrepo.org/RPM-GPG-KEY-elrepo.org rpm -Uvh http://elrepo.org/elrepo-release-6-5.el6.elrepo.noarch.rpm rpm -Uvh http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm --import 'http://keys.gnupg.net:11371/pks/lookup?search=0x0608B895&op=get' yum -y install drbd84-utils kmod-drbd84
Configuration
create /etc/drbd.d/drbd1.res
resource repdata { protocol C; startup { wfc-timeout 60; degr-wfc-timeout 120; } disk { c-fill-target 1M; c-max-rate 1M; resync-rate 1M; on-io-error detach; } # or panic, ... # set a shared password net { cram-hmac-alg "sha1"; shared-secret "ent0Sru!3zMi2fwf12fi"; } #the names server1 and server2 must be the fqdn of the servers - case sensitive! on server1 { device /dev/drbd0; # this is the dev that you are going to create the mirror on # it could be a partition or a logical drive disk /dev/vda3; #this is the ip address of server1 and the port used for replication # make sure you permit this port through iptables! address 10.254.253.52:7788; meta-disk internal; } on server2 { device /dev/drbd0; disk /dev/vda3; #this is the ip address of server2 and the port used for replication address 10.254.253.53:7788; meta-disk internal; } }
fdisk /dev/vda and create the correct partitions needed
drbdadm create-md repdata
You should get the message:
New drbd meta data block successfully created.
If you get an error message that includes:
Device size would be truncated, which would corrupt data and result in 'access beyond end of device' errors. You need to either * use external meta data (recommended) * shrink that filesystem first * zero out the device (destroy the filesystem) Operation refused.
The partition is probably already formatted. Clear the formatting with :
dd if=/dev/zero of=/dev/XXXX bs=1M count=128
Replace XXXX above with the correct device, such as vda2 or mapper/vg_drbd1-lv_opt
start drbd on both nodes (service drbd start)
service drbd start cat /proc/drbd
As you can see , both nodes are secondary, which is normal. we need to decide which node will act as a primary now (node1) : that will initiate the first ‘full sync’ between the two nodes :
drbdadm -- --overwrite-data-of-peer primary repdata
Monitor the status:
watch -n 1 cat /proc/drbd
we can now format /dev/drbd0 and mount it on node1 :
mkfs.ext3 /dev/drbd0 ; mkdir /repdata ; mount /dev/drbd0 /repdata
Outdated/DUnknown
If you cat /proc/drbd and get:
0: cs:WFConnection ro:Secondary/Unknown ds:Outdated/DUnknown C r-----
On the primary node, execute
drbdadm connect all
and if needed, on the secondary node, execute
drbdadm -- --discard-my-data connect all
References
- http://wiki.centos.org/HowTos/Ha-Drbd
- http://www.mavinerc.com/home/2012/04/26/howto-drbd-drbdadm-create-md-fails/
SNMP
http://lists.linbit.com/pipermail/drbd-user/2007-November/007780.html