Chapter 32. High-Availability Clusters and Service Failover
A single server fails as a unit: its power, its kernel, its network card, and its disks all share one fate. High availability separates the service from any one host by keeping a second host ready, deciding quickly and safely which host owns the service, and moving a stable identity - a virtual address, a server name, a consistent data copy - when the owner fails. The decision machinery matters as much as the spare hardware. A cluster that moves a filesystem to a second node while the first node is still writing to it has not improved availability; it has manufactured corruption.
This chapter builds that machinery on Debian 13. Corosync provides membership and quorum, with a QDevice witness so a two-node cluster can survive one node's isolation without ever allowing two quorate sides. Pacemaker orders and places resources, fencing is examined and its absence is treated as a design decision with consequences, and a complete active-passive NFS service over DRBD is built, failed over, partitioned, and verified from an independent client. The second half turns to load balancing and address ownership: HAProxy as an application-aware proxy, Keepalived and VRRP for virtual-IP failover, LVS and IPVS for kernel-level load balancing with redundant directors, and a design walkthrough for clustered Samba with CTDB. Chapter 31 built the replicated block device this cluster consumes; Chapter 21 covered the NFS and SMB protocols themselves.
The examples use five Debian 13 guests on two isolated practice networks:
| Role | Host | Service address | Cluster address | Notes |
|---|---|---|---|---|
| Cluster node 1 | ha1 |
192.168.232.11/24 on eth1 |
192.168.233.11/24 on eth2 |
Pacemaker, Corosync, DRBD, NFS; also HAProxy, Keepalived, LVS director in later sections |
| Cluster node 2 | ha2 |
192.168.232.12/24 on eth1 |
192.168.233.12/24 on eth2 |
same cluster stack; failover target and second director |
| Independent NFS and web client | haclient |
192.168.232.13/24 on eth1 |
- | mounts the NFS virtual address; also runs a test web backend |
| QDevice witness and web backend | lbclient |
192.168.232.14/24 on eth1 |
- | runs corosync-qnetd; also runs a test web backend |
| Load-balancing client | lbcli |
192.168.232.15/24 on eth1 |
- | independent client for the HAProxy and LVS exercises |
Each guest also has a management address on a separate network. The practice
networks are isolated libvirt networks, the data disks on ha1 and ha2 are
small disposable virtio devices (/dev/vdb), and the virtual addresses used
by the exercises are 192.168.232.100 (Pacemaker), 192.168.232.150
(Keepalived), and 192.168.232.160 through 192.168.232.162 (LVS). Because all
five guests run on one hypervisor, the lab demonstrates the cluster mechanisms,
not physical redundancy; a production pair needs nodes in separate failure
domains, which section 32.1.4 defines. The practice guests also run
without time synchronization, so timestamps in the captures disagree -
across hosts, and across the moments at which the captures were taken.
A Last updated time on one host can even precede a Last change time
recorded by the other. A production cluster synchronizes time as
Chapter 10 describes; the captures in this
chapter appear exactly as the guests printed them.
Figure 32.1. The five practice hosts and two isolated networks. Corosync
membership (UDP 5405) and DRBD replication (TCP 7789) share the dedicated
cluster network on eth2; clients, the witness service, and every virtual
address live on the service network. Management SSH uses a third network that
no exercise touches.
Commands entered in john's ordinary shell begin with $; commands entered
in a root shell begin with #. The prompt marker is not typed. Almost every
command in this chapter needs root privileges and is shown from john's
shell as $ sudo command; the practice account has passwordless sudo to keep
the examples short, and the commands are unchanged on a host where sudo asks
for a password. If you enter a root shell with sudo -i, leave it with
exit, and remember that root's ~ is not /home/john.
Keep the practice files in a named workspace on every host that needs them:
$ mkdir -p ~/debian-handbook/ha
The command normally prints nothing. The cluster nodes use this workspace for
the cluster configuration script and the CIB backup; the two web backends use
it for a small test server. The examples never use /tmp as a workspace, and
cleanup stays bounded to the files the exercises create.
The practice interfaces are assumed configured. On ha1, an
/etc/network/interfaces.d/eth1 file containing the following puts the node
on the service network:
auto eth1
iface eth1 inet static
address 192.168.232.11
netmask 255.255.255.0
An /etc/network/interfaces.d/eth2 file adds the cluster network:
auto eth2
iface eth2 inet static
address 192.168.233.11
netmask 255.255.255.0
On ha2 the same two files carry 192.168.232.12 and 192.168.233.12. The
client and witness hosts need only the eth1 file with their own addresses.
Interface configuration itself is covered in
Chapter 17. Every exercise identifies the
target host before each command block; the same command on a different host is
a separate block, and values that differ per node are called out where the
files are introduced.
In this section
- 32.1. Choosing a High-Availability Design
- 32.2. Application State and Failover Correctness
- 32.3. Membership and Quorum with Corosync
- 32.4. Fencing and Exclusive Resource Ownership
- 32.5. Managing Resources with Pacemaker
- 32.6. Walkthrough: Active-Passive NFS with DRBD and Pacemaker
- 32.7. Walkthrough: Clustered SMB with Samba and CTDB
- 32.8. Load Balancing with HAProxy
- 32.9. Virtual-IP Failover with Keepalived
- 32.10. Kernel Load Balancing with LVS and IPVS
- 32.11. Redundant LVS Directors and Failover Verification
- 32.12. Cluster Maintenance and Failure Diagnosis