DRBD – Distributed Replicated Block Device is a distributed replicate storage system for Linux. Most of our Shared Hosting been setup with this technology, where it been setup with TWO physical servers, one as a primary and another one is secondary. In case, there’s an issue with the primary storage, secondary will take over and all VMs can be operated or running as per normal with no worries about longer down time for recovery.
LAN or private network is needed for this setup, the data replication will be going thru it.
For example, both INQA05 and INQA06, been setup with following LAN IP addresses.
Host A : INQA05.small-dns.com – 10.10.10.53
Host B : INQA06.small-dns.com – 10.10.10.54
Please make sure, to modify the hosts file for both servers and it contain
10.10.10.53 INQA05.small-dns.com
10.10.10.54 INQA06.small-dns.com
ping from both servers to the FQDN that been added in the hosts file, to make sure the IP address return is correct.
[root@INQA06 ~]# ping INQA05.small-dns.com
PING INQA05.small-dns.com (10.10.10.53) 56(84) bytes of data.
64 bytes from INQA05.small-dns.com (10.10.10.53): icmp_seq=1 ttl=64 time=0.189 ms
64 bytes from INQA05.small-dns.com (10.10.10.53): icmp_seq=2 ttl=64 time=0.116 ms
^C
--- INQA05.small-dns.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1000ms
rtt min/avg/max/mdev = 0.116/0.152/0.189/0.038 ms
Installation of DRBD
[root@INQA06 ~]# yum install libxslt-devel kernel-devel docbook-style-xsl -y
[root@INQA06 ~]# mkdir -p /ips1/drbd
[root@INQA06 ~]# cd /ips1/drbd
[root@INQA06 ~]# wget http://www.linbit.com/downloads/drbd/9.0/drbd-9.0.9-1.tar.gz
[root@INQA06 ~]# tar xvf drbd-9.0.9-1.tar.gz
[root@INQA06 ~]# cd drbd-9.0.9-1
[root@INQA06 ~]# make
[root@INQA06 ~]# make install
[root@INQA06 ~]# cd /ips1/drbd
[root@INQA06 ~]# wget http://www.linbit.com/downloads/drbd/utils/drbd-utils-9.1.0.tar.gz
[root@INQA06 ~]# tar xvf drbd-utils-9.1.0.tar.gz
[root@INQA06 ~]# ./configure --prefix=/usr --localstatedir=/var --sysconfdir=/etc
[root@INQA06 ~]# make
[root@INQA06 ~]# make install
[root@INQA06 ~]# modprobe drbd
Initialize meta disk for the DRBD. For this tutorial, we will setup the DRBD on sda1 for both servers.
[root@INQA06 ~]# dd if=/dev/zero of=/dev/sda1 bs=1M count=256
Edit the main config of DRBD
[root@INQA06 ~]# /usr/bin/perl -pi -e "s/usage-count yes/usage-count no/g" /etc/drbd.d/global_common.conf
Now, we will start to setup the drbd00 that contain replication of sda1
[root@INQA06 ~]# cd /etc/drbd.d
[root@INQA06 ~]# vi drbd00.res
Here is the example of config drbd00
resource drbd00 {
protocol C;
startup {
wfc-timeout 0;
degr-wfc-timeout 120;
}
disk {
on-io-error detach;
no-disk-flushes;
no-md-flushes;
resync-rate 3000M; # 10000 x 0.3 https://docs.linbit.com/doc/users-guide-90/s-configure-sync-rate/
}
on INQA05 {
device /dev/drbd00;
disk /dev/sda1;
address 10.10.10.53:7788;
meta-disk internal;
}
on INQA06 {
device /dev/drbd00;
disk /dev/sda1;
address 10.10.10.54:7788;
meta-disk internal;
}
}
Create the drbd00 disk with following command
[root@INQA06 ~]# drbdadm create-md drbd00
Restart the DRBD service
[root@INQA06 ~]# service drbd restart
Check the status for the replication with
[root@INQA06 ~]# drbdadm status
The output should as below, once the replication or sync started
drbd00 role:Secondary
disk:UpToDate
INQA-05 role:Secondary
replication:SyncSource peer-disk:Inconsistent done:0.32
On the primary server,
[root@INQA06 ~]# drbdadm primary drbd00 --force
Once the replication or sync completed, format the drbd00 disk then mount it. For example below, we will mount it to /sandwich/vm-disk/drbd00
[root@INQA06 ~]# mkfs.ext4 /dev/drbd0
[root@INQA06 ~]# mount /dev/drbd0 /sandwich/vm-disk/drbd00