DEV Community

Cover image for Build a High-Availability Cluster with DRBD & Keepalived
Alyssa Valdezz for EPY Host

Posted on

Build a High-Availability Cluster with DRBD & Keepalived

When architecting for zero downtime, application-layer replication often introduces race conditions and split-brain scenarios. A cleaner, more resilient pattern for two-node active-passive failover is kernel-level block replication using DRBD combined with Keepalived for VRRP IP migration.

[ Clients ]


[ Floating Public VIP: 203.0.113.100 ]

├──► (Active) Node1 (Primary) ──[DRBD Sync Protocol C]──► Node2 (Secondary)
│ Disk: /dev/drbd0 ──── (Private Network) ───► Disk: Raw Standby

└──► (Failover) Node2 Promoted to Primary & Takes VIP on Node1 Crash

Key Architectural Steps:

  1. Raw Storage Wipe: Clean raw partitions (/dev/nvme1n1) on both nodes using wipefs.
  2. DRBD Protocol C Config: Define global resources in /etc/drbd.d/data.res specifying synchronous network writes over internal private IPs.
  3. Keepalived Event Scripts: Write /etc/keepalived/master.sh and backup.sh bash hooks that invoke drbdadm primary and mount /dev/drbd0 dynamically during failover state changes.

Full Technical Guide:
Read our complete configuration, initialization steps, and failover validation test suite:
🔗 https://www.epyhost.com/tutorials/howto/build-ha-cluster-drbd-keepalived/

Top comments (0)