Achieving high availability on Linux requires eliminating single points of failure at every layer. The combination of Heartbeat for cluster resource management and DRBD for real-time block device replication provides an affordable HA solution for web servers and databases without requiring shared storage hardware.
Setting Up the HA Cluster
DRBD acts as a network RAID-1, replicating block devices between two servers in real time. Configure a DRBD resource for each data partition that needs replication, such as the web document root or database data directory. DRBD operates in primary/secondary mode, where only the primary node mounts and uses the replicated device while the secondary keeps an identical copy.
Heartbeat monitors the health of cluster nodes and manages resource failover. Configure Heartbeat with a shared virtual IP address that clients connect to, and define resource groups that include the DRBD promotion, filesystem mount, and service startup. When the primary node fails, Heartbeat promotes the secondary DRBD device, mounts the filesystem, starts the services, and activates the virtual IP.
Test your failover thoroughly by simulating various failure scenarios: network cable disconnection, service crashes, and full node power loss. Measure the failover time and ensure it meets your recovery time objective. Monitor the DRBD synchronization state continuously, as a secondary node that has fallen behind will require longer recovery during an actual failover.