DRBD (Distributed Replicated Block Device) is a Linux-based software component that facilitates the replacement of shared storage systems by networked mirroring. DRBD makes it possible to maintain consistency of data among multiple systems in a network. DRBD also ensures high availability (HA) for Linux applications


  1. Download DRBD and Install the DRBD Packages

Preferred methods to download the DRBD packages are,

Method 1 : Download the latest DRBD packages from DRBD project’s sponsor company link http://oss.linbit.com/drbd/ and compile it from the source.

Method 2 : Enable EPEL repository on RHEL7, CentOS7 .

We prefer method 2, which enables the EPEL repository. So install the EPEL Repository on both nodes.

[root@node1 ~]# rpm -ivh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm

Import the Public Key on both nodes.

[root@node1 ~]# rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org


Install the DRBD 8.4 packages on both nodes

[root@node1 ~]# yum -y install drbd84-utils kmod-drbd84

Note : If you get any error as public key is not installed on any nodes, import all the public keys available in the directory /etc/pki/rpm-gpg/ as below and repeat the installation again.

rpm –import /etc/pki/rpm-gpg/*

Ensure drbd kernel module is loaded or not using the below command,

lsmod | grep -i drbd

If it is not loaded, find the drbd.ko module using find command and install it.

find / -name drbd.ko


insmod /usr/lib/modules/3.10.0-514.16.1.el7.x86_64/weak-updates/drbd84/drbd.ko

Configuring DRBD in Linux

DRBD configuration file is /etc/drbd.conf. Normally, this configuration file is a skeleton with the following contents:

include “/etc/drbd.d/global_common.conf”;

include “/etc/drbd.d/*.res”;

By convention, /etc/drbd.d/global_common.conf contains the global and common sections of the DRBD configuration, whereas the “.res” files contain one resource section each.

Lets Create a DRBD resource file “drbd.res”. We recommend to always create a unique name to identify the resource purpose. It should be end with “.res” file extension.

vi /etc/drbd.d/drbd.res

Copy the below simple configuration content into the file drbd.res.

resource drbd {

protocol C;

on node1 {

device /dev/drbd0;

disk /dev/sdb;


meta-disk internal;


on node2 {

device /dev/drbd0;

disk /dev/sdb;


meta-disk internal;




Resource drbd – To define the resource name “drbd”

on node1 – To define first node name and its options within the statement.

device /dev/drbd0 – To define the logical device name used for the block device. (Should be common on both nodes)

disk /dev/sdb – To define the dedicated local disk used for replication (Not mandatory to be the same on both nodes)

address – To define the dedicated network to be used for the replication and resource uses TCP port 7788.

meta-disk internal – Defined to use internal Meta data.

Copy the DRBD resource file to other nodes.

[root@node1 ~] scp /etc/drbd.d/drbd.res node2:/etc/drbd.d/

  1. Initialize the meta data storage on each nodes

[root@node1 ~] drbdadm create-md drbd

[root@node2 ~] drbdadm create-md drbd

Above commands will give an output like below.

  –==  Thank you for participating in the global usage survey  ==–

The node1’s response is:

you are the 10680th user to install this version

initializing activity log

NOT initializing bitmap

Writing meta data…

New drbd meta data block successfully created.


  1. Starting and Enabling the DRBD Daemon.

On both nodes start simultaneously one after another..

[root@node1 ~]# systemctl start drbd

[root@node1 ~]# systemctl enable drbd

  1. Enabling the DRBD Primary node

Lets define the DRBD Primary node as first node “node1”.

[root@node1 ~]# drbdadm up drbd

[root@node1 ~] drbdadm primary drbd


[root@node1 ~] drbdadm primary drbd –force

Use “–force” if you get any error to make the node primary forcefully.

[root@node1 ~]# watch cat /proc/drbd

version: 8.4.6 (api:1/proto:86-101)

GIT-hash: 833d830e0152d1e457fa7856e71e11248ccf3f70 build by phil@Build64R7, 2015-04-10 05:13:52


1: cs:SyncSource ro:Primary/Secondary ds:UpToDate/Inconsistent C r—–

ns:2872 nr:0 dw:0 dr:3784 al:0 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:1045636

[>………………..] sync’ed:  0.4% (1045636/1048508)K

finish: 0:10:53 speed: 1,436 (1,436) K/sec

Checking the DRBD Status

[root@node1 ~]# cat /proc/drbd

version: 8.4.7-1 (api:1/proto:86-101)

GIT-hash: 3a6a769340ef93b1ba2792c6461250790795db49 build by phil@Build64R7, 2016-01-12 14:29:40

0: cs:Connected ro:Primary/Secondary ds:UpToDate/UpToDate C r—–

ns:1048508 nr:0 dw:0 dr:1049236 al:8 bm:0 lo:0 pe:0 ua:0 ap:0 ep:1 wo:f oos:0

[root@node1 ~]# drbd-overview

0:drbd/0  Connected Primary/Secondary UpToDate/UpToDate

  1. Create and mount the Filesystem of DRBD device

Create a file system, mount the volume and write some data on first node “node1”

[root@node1 ~]# mkfs.ext3 /dev/drbd0

[root@node1 ~]# mount /dev/drbd0 /mnt

[root@node1 ~]# touch /mnt/testfile

[root@node1 ~]# ll /mnt/

total 16

drwx—— 2 root root 16384 Jul  8 20:29 lost+found

-rw-r–r– 1 root root     0 Jul  8 20:31 testfile

  1. Testing the DRBD configurations

Lets test the configuration by changing primary mode “node1” to second node “node2” to check the data replication works or not.

Unmount the volume drbd0 on First node “node1”.

[root@node1 ~]# umount /mnt

Change the primary mode to secondary mode on first node “node1”

[root@node1 ~] drbdadm secondary drbd

Change the secondary mode to primary mode on second node “node2”

[root@node2 ~] drbdadm primary drbd

Mount the volume and check the data available or not.

[root@node2 ~] mount /dev/drbd0 /mnt

[root@node2 ~] ll /mnt

total 16

drwx—— 2 root root 16384 Jul  8 20:29 lost+found

-rw-r–r– 1 root root     0 Jul  8 20:31 testfile