DRBD (Distributed Replicated Block Device) provides synchronous, block-level replication between two Linux servers, making it a foundational technology for high-availability storage clusters. Often described as “RAID 1 over the network,” DRBD mirrors every write to both nodes in real time, so either node can take over if the other fails. On RHEL 8, DRBD is available through the ELRepo repository and integrates cleanly with Pacemaker/Corosync clusters. This tutorial covers installing DRBD, writing a resource configuration, initializing metadata, promoting a node to primary, and monitoring replication state.
Prerequisites
- Two RHEL 8 servers (e.g.,
node1andnode2) with identical spare block devices (e.g.,/dev/sdb) - Static IP addresses on both nodes; ensure they can reach each other by hostname
- ELRepo repository enabled:
dnf install -y https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm - Root or
sudoaccess on both nodes - Firewall ports open between nodes: TCP 7788 (DRBD default)
Step 1 — Install DRBD Packages
Install the DRBD kernel module and user-space utilities from ELRepo on both nodes. The kmod-drbd90 package provides the kernel module and drbd90-utils provides drbdadm, drbdsetup, and related tools.
# Run on both node1 and node2
dnf install -y kmod-drbd90 drbd90-utils
# Load the module immediately without rebooting
modprobe drbd
# Confirm the module is loaded
lsmod | grep drbd
Open the replication port on both nodes:
firewall-cmd --permanent --add-port=7788/tcp
firewall-cmd --reload
Step 2 — Write the Resource Configuration File
DRBD resources are defined in .res files placed in /etc/drbd.d/. Create /etc/drbd.d/mydevice.res on both nodes with identical content. Replace the IP addresses and disk paths to match your environment.
# /etc/drbd.d/mydevice.res
resource mydevice {
protocol C; # Synchronous replication
disk {
on-io-error detach;
}
on node1 {
disk /dev/sdb;
device /dev/drbd0;
address 192.168.1.10:7788;
meta-disk internal;
}
on node2 {
disk /dev/sdb;
device /dev/drbd0;
address 192.168.1.11:7788;
meta-disk internal;
}
}
Protocol C means writes are acknowledged only after both nodes confirm the data is on disk, giving the strongest consistency guarantee.
Step 3 — Initialize Metadata and Bring the Resource Up
Create DRBD metadata on the disk on both nodes, then bring the resource into the connected state. The create-md command writes a metadata area at the end of the device.
# Run on both nodes
drbdadm create-md mydevice
# Bring up the resource on both nodes
drbdadm up mydevice
# Check the connection state
drbdadm status mydevice
At this point, both nodes will be in the Secondary role and the disk state will be Inconsistent on both. That is expected — the initial sync has not yet started.
Step 4 — Force Primary and Start Initial Synchronization
Designate one node as the initial primary. The --force flag is required only for the very first promotion when both nodes are Inconsistent. Run this on node1 only.
# On node1 only
drbdadm primary --force mydevice
# Watch synchronization progress
watch -n 2 'drbdadm status mydevice'
Synchronization speed depends on disk and network bandwidth. A 100 GB device over a 1 Gbps link typically completes in a few minutes. The disk state will transition from Inconsistent → Inconsistent/Inconsistent → UpToDate/UpToDate as the sync completes.
Step 5 — Create a Filesystem and Mount on the Primary
Once the initial sync is complete and both disk states show UpToDate, create a filesystem on the DRBD device on node1. Only the current primary may mount the device in single-primary mode.
# On node1 (the primary)
mkfs.xfs /dev/drbd0
mkdir -p /mnt/drbd_data
mount /dev/drbd0 /mnt/drbd_data
df -h /mnt/drbd_data
For a manual failover to node2, unmount and demote node1, then promote node2:
# On node1
umount /mnt/drbd_data
drbdadm secondary mydevice
# On node2
drbdadm primary mydevice
mount /dev/drbd0 /mnt/drbd_data
Step 6 — Monitor Replication Status
DRBD provides several ways to inspect the replication state. Use these commands regularly, and integrate DRBD status checks into your monitoring system.
# Detailed text status
drbdadm status mydevice
# Live kernel statistics (refresh every 2 seconds)
watch -n 2 cat /proc/drbd
# Show connection and disk state for all resources
drbdsetup status --verbose --statistics
Key fields to watch: peer-disk-state (should be UpToDate), connection-state (should be Connected), and replication-state (should be Established with no SyncSource/SyncTarget activity outside of initial sync or re-sync events).
Conclusion
You have installed DRBD on a two-node RHEL 8 cluster, written a resource configuration file, initialized metadata, completed an initial full synchronization, and created a filesystem on the replicated device. You also know how to perform a manual failover and how to monitor replication health through drbdadm status and /proc/drbd. For production use, pair DRBD with Pacemaker and Corosync to automate failover and resource management. Always test failover scenarios in a staging environment before relying on them in production.
Next steps: How to Configure Pacemaker and Corosync for High Availability on RHEL 8, How to Manage LVM with Shared Storage on RHEL 8, and How to Configure iSCSI Target and Initiator on RHEL 8.