32.6. Walkthrough: Active-Passive NFS with DRBD and Pacemaker
The walkthrough assembles everything so far into one service: an NFSv4 export of a DRBD-replicated filesystem, served by whichever node holds the promotion, advertised on a floating address, verified by a client that mounts nothing but the address.
32.6.1. Requirements, Failure Domains, Two Service Nodes, a Witness, and Independent Clients
The service needs:
- Two cluster nodes (
ha1,ha2) with the packages of section 32.3.3 installed, the cluster formed, and one small disposable data disk each (/dev/vdb, 1 GB in the practice lab). - One witness (
lbclient) runningcorosync-qnetd, already configured by the cluster init in section 32.3.3. - One independent client (
haclient) that reaches the service only through the virtual address 192.168.232.100, withnfs-commoninstalled. - Two separated networks as in Figure 32.1: client traffic on
eth1, membership and replication oneth2.
The failure-domain reasoning is the point of the cast list. The witness holds no data and can be small, but it must not fail with either node - it runs on a third host. The client must not be a cluster member, because a verification tool that shares fate with the thing it verifies verifies nothing. And the data disks are per-node devices, so the DRBD copies sit in separate node domains by construction; only the practice environment's single hypervisor keeps them in one physical domain, a simplification section 32.1.4 already flagged.
The DRBD resource itself is deliberately small and disposable. A
production pair would use persistent device paths (/dev/disk/by-id/...)
as Chapter 31 does for its long-lived resource; the practice
disk's virtio name is stable for the lifetime of this walkthrough and
nothing on it survives the chapter.
32.6.2. Preparing Replicated Data and NFS Recovery State with Single-Writer Ownership
Create the DRBD resource exactly as Chapter 31 taught it,
but on the cluster network and with the resource named ha. Write the
following to /etc/drbd.d/ha.res on both nodes - the file is
identical everywhere, which is the invariant every DRBD configuration
keeps - and keep the permissions strict:
resource ha {
protocol C;
startup {
wfc-timeout 15;
degr-wfc-timeout 15;
}
disk {
on-io-error detach;
resync-rate 100M;
}
net {
cram-hmac-alg sha256;
shared-secret "handbook-ha-secret";
after-sb-0pri discard-zero-changes;
after-sb-1pri discard-secondary;
after-sb-2pri disconnect;
}
on ha1 {
device /dev/drbd0;
disk /dev/vdb;
address 192.168.233.11:7789;
meta-disk internal;
}
on ha2 {
device /dev/drbd0;
disk /dev/vdb;
address 192.168.233.12:7789;
meta-disk internal;
}
}
$ sudo chmod 600 /etc/drbd.d/ha.res
The command normally prints nothing. Protocol C gives synchronous
replication - the RPO of zero that section 32.1.2 promised - and the
after-sb-* options are the split-brain resolution policies
Chapter 31 examined; here they say: after a split brain with
one primary, the secondary's divergent blocks are discarded, which is
safe only because the cluster's fencing and quorum prevent the situation
in the first place.
drbdadm use |
Description |
|---|---|
create-md ha |
Write DRBD metadata to the backing device |
up ha |
Attach, connect, and bring the resource up |
primary --force ha |
Promote, allowing the initial full sync |
secondary ha |
Demote to the read-only standby role |
status ha |
Print role, disk, connection, and sync state |
down ha |
Detach and disconnect the resource |
On ha1, as john, create the metadata (the practice disk carried
signatures from earlier chapters, hence --force):
$ sudo drbdadm create-md --force ha
md_offset 1073737728
al_offset 1073704960
bm_offset 1073672192
Found some data
==> This might destroy existing data! <==
initializing activity log
Writing meta data...
New drbd meta data block successfully created.
The standard error stream carries the interactive confirmation that
--force answers, together with the bitmap-initialization line; the block
above shows standard output alone. On ha2, as john, the same command
prints the same standard output. Bring the resource up on both nodes; each command normally
prints nothing:
$ sudo drbdadm up ha
Promote the initial sync source on ha1 only - one writer, everywhere in
this chapter:
$ sudo drbdadm primary --force ha
The command normally prints nothing. Follow the initial synchronization:
$ sudo drbdadm status ha
ha role:Primary
disk:UpToDate
peer role:Secondary
replication:SyncSource peer-disk:Inconsistent done:5.86
Wait until the peer reports UpToDate; the device is not fully protected
until both copies agree. On the 1 GB practice disk this takes seconds; on
real disks it takes as long as the initial full sync of
Chapter 31:
$ sudo drbdadm status ha
ha role:Primary
disk:UpToDate
peer role:Secondary
replication:Established peer-disk:UpToDate
Create the filesystem and seed it with the data the walkthrough will
verify across every failover. On ha1, as john:
$ sudo mkfs.ext4 -q /dev/drbd0
$ sudo mount /dev/drbd0 /srv/ha-data
$ sudo install -d -m 0777 /srv/ha-data/records
Each command normally prints nothing. The world-writable records
directory exists so the client's writes do not depend on UID mapping
(Chapter 21 covers proper identity
management for real exports). Seed the ledger:
$ printf "cluster-record-one\n" | sudo tee /srv/ha-data/records/ledger.txt
cluster-record-one
$ sudo chmod 0666 /srv/ha-data/records/ledger.txt
The chmod normally prints nothing; it makes the file writable from the
client without squashing games. Confirm what the filesystem holds:
$ df -h /srv/ha-data
Filesystem Size Used Avail Use% Mounted on
/dev/drbd0 990M 284K 922M 1% /srv/ha-data
Now perform the step that makes this a cluster service: give the data to
the cluster manager. A manually-mounted, manually-promoted DRBD primary
and a Pacemaker p_fs resource cannot share authority - whichever acted
last would win, and the cluster's guarantees would be theater. Unmount,
demote, and detach on ha1, as john:
$ sudo umount /srv/ha-data
$ sudo drbdadm secondary ha
$ sudo drbdadm down ha
On ha2, as john:
$ sudo drbdadm secondary ha
$ sudo drbdadm down ha
Each command normally prints nothing. From here on, nothing promotes or
mounts ha by hand; every role change belongs to Pacemaker, and the
single-writer rule the chapter keeps asserting is enforced by the
colocation and ordering constraints that follow.
32.6.3. Fencing, Quorum, Promotion, Filesystem, NFS, Export, and VIP Resource Ordering
Set the cluster's ground rules before adding resources. On ha1, as
john:
$ sudo crm configure property stonith-enabled=false
(unpack_config) warning: Blind faith: not fencing unseen nodes
$ sudo crm configure property no-quorum-policy=stop
(unpack_config) warning: Blind faith: not fencing unseen nodes
$ sudo crm configure rsc_defaults resource-stickiness=100
(unpack_config) warning: Blind faith: not fencing unseen nodes
Each command commits one property; the warning is the unfenced-cluster
statement from section 32.4.4, printed on every CIB change while fencing
is disabled. no-quorum-policy=stop is the quorum half of the safety
design: a partition without quorum stops its resources instead of
ignoring quorum, and section 32.3.5 captured exactly that behavior on
the minority node. The stickiness default is the "failover does not undo
itself" rule from section 32.5.4.
The complete resource stack is a short crmsh script. Write the following
to ~/debian-handbook/ha/crm-nfs.txt on ha1 - it is the reader's
workspace copy of the configuration that the next command loads into the
CIB:
configure
primitive p_drbd ocf:linbit:drbd params drbd_resource=ha op monitor interval=15s role=Promoted op monitor interval=30s role=Unpromoted
clone ms_drbd p_drbd meta promotable=true promoted-max=1 promoted-node-max=1 clone-max=2 clone-node-max=1 notify=true
primitive p_fs Filesystem params device=/dev/drbd0 directory=/srv/ha-data fstype=ext4 op monitor interval=20s
primitive p_vip IPaddr2 params ip=192.168.232.100 cidr_netmask=24 nic=eth1
primitive p_nfs nfsserver params nfs_ip=192.168.232.100 nfs_server_scope=ha-handbook
primitive p_export exportfs params clientspec="192.168.232.0/24" directory="/srv/ha-data" options="rw,sync,no_subtree_check" fsid=1
group g_nfs p_fs p_vip p_nfs p_export
colocation col_g_master inf: g_nfs ms_drbd:Promoted
order ord_promote_g Mandatory: ms_drbd:promote g_nfs:start
commit
quit
Read it against Figure 32.4: the promotable clone first, then the four
group members in data-upward order, then the two constraints that pin the
group to the promotion. The nfsserver and exportfs parameters carry
the service's stable identity - the address it binds, the NFSv4 scope it
presents, the export's fsid - and section 32.6.4 explains each.
With both nodes eligible, either can win the promotion once the DRBD
copies are synchronized. To make the first placement deterministic, put
ha2 in standby while the resource stack starts for the first time. On
ha1, as john:
$ sudo crm node standby ha2
INFO: standby node ha2
Load the script into the cluster:
$ sudo crm -F -f /home/john/debian-handbook/ha/crm-nfs.txt
(unpack_config) warning: Blind faith: not fencing unseen nodes
The -f option reads a crmsh script from a file, and -F forces the
configure commit without an interactive confirmation. The command itself
prints only the standing unfenced-cluster warning; the changes land in
the CIB. Give the cluster a minute to promote DRBD, mount the filesystem,
start the server, and place the address on ha1, then return ha2 to
service:
$ sudo crm node online ha2
INFO: online node ha2
With both nodes online, check the resulting placement:
$ sudo crm -D plain status
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: ha1 (version 3.0.0-3.0.0) - partition with quorum
* Last updated: Wed Nov 25 09:03:37 2026 on ha1
* Last change: Wed Nov 25 09:03:30 2026 by root via root on ha1
* 2 nodes configured
* 6 resource instances configured
Node List:
* Online: [ ha1 ha2 ]
Full List of Resources:
* Clone Set: ms_drbd [p_drbd] (promotable):
* Promoted: [ ha1 ]
* Unpromoted: [ ha2 ]
* Resource Group: g_nfs:
* p_fs (ocf:heartbeat:Filesystem): Started ha1
* p_vip (ocf:heartbeat:IPaddr2): Started ha1
* p_nfs (ocf:heartbeat:nfsserver): Started ha1
* p_export (ocf:heartbeat:exportfs): Started ha1
The group is on ha1 because ha2 was in standby for the first start.
Once both nodes hold an up-to-date copy, either can win the promotion;
the examples keep ha1 active so the failover procedures have a known
source, and section 32.6.5 moves the group deliberately rather than
assuming a particular node. The full configuration as
Pacemaker now stores it, on ha1, as john:
$ sudo crm configure show
node 1: ha1
node 2: ha2 \
attributes standby=off
primitive p_drbd ocf:linbit:drbd \
params drbd_resource=ha \
op monitor interval=15s role=Promoted \
op monitor interval=30s role=Unpromoted
primitive p_export exportfs \
params clientspec="192.168.232.0/24" directory="/srv/ha-data" options="rw,sync,no_subtree_check" fsid=1
primitive p_fs Filesystem \
params device="/dev/drbd0" directory="/srv/ha-data" fstype=ext4 \
op monitor interval=20s
primitive p_nfs nfsserver \
params nfs_ip=192.168.232.100 nfs_server_scope=ha-handbook
primitive p_vip IPaddr2 \
params ip=192.168.232.100 cidr_netmask=24 nic=eth1
group g_nfs p_fs p_vip p_nfs p_export
clone ms_drbd p_drbd \
meta promotable=true promoted-max=1 promoted-node-max=1 clone-max=2 clone-node-max=1 notify=true interleave=true
colocation col_g_master inf: g_nfs ms_drbd:Promoted
order ord_promote_g Mandatory: ms_drbd:promote g_nfs:start
property cib-bootstrap-options: \
have-watchdog=false \
dc-version=3.0.0-3.0.0 \
cluster-infrastructure=corosync \
cluster-name=hacluster \
stonith-enabled=false \
no-quorum-policy=stop
rsc_defaults rsc-options: \
resource-stickiness=100 \
migration-threshold=3 \
priority=0
op_defaults op-options: \
timeout=600
This is the reference against which any later configure show diff should
be read. Note have-watchdog=false - no watchdog-backed fencing, matching
section 32.4.2 - and the migration-threshold and operation timeout that
section 32.5.4 already explained.
32.6.4. Stable Export Identities, NFSv4 State, Locks, Grace Periods, and Client Mount Policy
A client must not be able to tell that the server behind an address ever changed. Three identities make that possible, and all three are visible in the running service.
The export identity is the fsid. NFSv4 clients identify exports by
filesystem identity rather than by path; a fixed fsid=1 in the
exportfs parameters makes the export look the same whichever node
serves it. Check the export table on the current owner. On ha1, as
john:
$ sudo exportfs -v
/srv/ha-data 192.168.232.0/24(sync,wdelay,hide,no_subtree_check,fsid=1,sec=sys,rw,secure,root_squash,no_all_squash)
The export options recorded here - sync, root_squash,
no_subtree_check - are the same ones Chapter 21
set by hand; the cluster resource applies them identically on both nodes
because the parameters live in the CIB, not in two copies of
/etc/exports.
The address identity is the virtual address, visible on the service
interface of the owner. On ha1, as john:
$ ip -4 -br addr show eth1
eth1 UP 192.168.232.11/24 192.168.232.100/24
The server identity is subtler. NFSv4 servers present a server
owner and scope string derived from their hostname; two different
hostnames look to the client like two unrelated servers, and state such
as locks and client IDs is then invalid after a failover. The
nfsserver agent solves this with nfs_server_scope=ha-handbook: it
runs the NFS server inside a UTS namespace whose hostname is that scope
value, so both nodes present the same NFSv4 server identity. The
ss listener and systemd evidence captured on the new owner in
section 32.6.5 shows the same single NFS service on either node.
Locks and open state are the reason all of this care exists. When a server fails, its clients hold state - open files, locks, delegations - that the new server does not know about. NFSv4 handles the transition with a grace period: the new server enters a short window in which it answers no new state-creating operations while former clients reclaim their state. Clients that reclaim get their locks back; clients that were mid-write on a hard mount resume. The practical consequences for an administrator are two: do not panic when the first seconds after a failover reject new opens - that is the grace period working - and never shorten it without measuring the reclaim traffic it serves.
The client's mount policy is set on the client. On haclient, as
john, mount the export through the virtual address only:
$ sudo mount -t nfs -o vers=4.2 192.168.232.100:/srv/ha-data /mnt/ha
The command normally prints nothing. Confirm what the kernel negotiated:
$ mount | grep /mnt/ha
192.168.232.100:/srv/ha-data on /mnt/ha type nfs4 (rw,relatime,vers=4.2,rsize=131072,wsize=131072,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,clientaddr=192.168.232.13,local_lock=none,addr=192.168.232.100)
The hard in the options is the mount policy from section 32.2.3: this
client blocks through an outage rather than erroring out, and the
failover exercises rely on it. A production client that must not block
would mount soft with tuned timeouts and handle errors in the
application instead - a trade, not an upgrade. Persistent mounting via
/etc/fstab with _netdev, and the autofs alternative, are covered in
Chapter 21.
Read the seeded data through the cluster address:
$ cat /mnt/ha/records/ledger.txt
cluster-record-one
The client has now verified exactly one thing - that the seeded record
survived the trip from ha1's DRBD device through its NFS export to a
separate host. That is the baseline every failover test will be compared
against.
32.6.5. Planned Switchover, Node Loss, Replication-Link Partition, and Client Write Verification
Write a record of the client's own through the mounted export, so the
failover verification can distinguish server-seeded data from
client-written data. On haclient, as john:
$ printf "client-write-one\n" >> /mnt/ha/records/ledger.txt
The >> redirect appends to the file instead of the terminal, so the
command normally prints nothing. Confirm the file through the mount:
$ cat /mnt/ha/records/ledger.txt
cluster-record-one
client-write-one
Record the baseline checksum before touching anything else. On
haclient, as john:
$ sha256sum /mnt/ha/records/ledger.txt
edb041613e8e39ea1322eaf6bc20c51bb59ef7b751077ff03d33077f1b8c7798 /mnt/ha/records/ledger.txt
Now switch the service over. A planned switchover begins by removing the
current owner from service, which is exactly what standby means. On ha1,
as john:
$ sudo crm -D plain node standby ha1
INFO: standby node ha1
Standby tells the cluster that ha1 must run nothing; the DRBD clone
demotes, the group stops in reverse order, and the whole stack re-forms
on ha2. Watch it from the new owner. On ha2, as john:
$ sudo crm -D plain status
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: ha1 (version 3.0.0-3.0.0) - partition with quorum
* Last updated: Wed Nov 25 08:42:11 2026 on ha2
* Last change: Wed Nov 25 09:05:07 2026 by root via root on ha1
* 2 nodes configured
* 6 resource instances configured
Node List:
* Node ha1: standby
* Online: [ ha2 ]
Full List of Resources:
* Clone Set: ms_drbd [p_drbd] (promotable):
* Promoted: [ ha2 ]
* Stopped: [ ha1 ]
* Resource Group: g_nfs:
* p_fs (ocf:heartbeat:Filesystem): Started ha2
* p_vip (ocf:heartbeat:IPaddr2): Started ha2
* p_nfs (ocf:heartbeat:nfsserver): Started ha2
* p_export (ocf:heartbeat:exportfs): Started ha2
Everything moved: the promotion is ha2's, the group is Started ha2
throughout, and ha1 is on standby with its clone instance stopped. The
address followed the group. On ha2, as john:
$ ip -4 -br addr show eth1
eth1 UP 192.168.232.12/24 192.168.232.100/24
And the export is byte-for-byte the same statement it was on ha1 -
compare against section 32.6.4:
$ sudo exportfs -v
/srv/ha-data 192.168.232.0/24(sync,wdelay,hide,no_subtree_check,fsid=1,sec=sys,rw,secure,root_squash,no_all_squash)
The listener and the service unit show the mechanism behind that identity.
On ha2, as john:
$ ss -ltnp | grep 2049
LISTEN 0 4096 0.0.0.0:2049 0.0.0.0:*
LISTEN 0 4096 [::]:2049 [::]:*
$ sudo systemctl status nfs-server --no-pager | head -12
● nfs-server.service - NFS server and services
Loaded: loaded (/usr/lib/systemd/system/nfs-server.service; disabled; preset: enabled)
Drop-In: /run/systemd/system/nfs-server.service.d
└─51-resource-agents-unshare-uts.conf
Active: active (exited) since Wed 2026-11-25 08:42:02 UTC; 20s ago
Invocation: c387002e27024ac89816f2bf92515783
Docs: man:rpc.nfsd(8)
man:exportfs(8)
Process: 183195 ExecStartPre=/usr/sbin/exportfs -r (code=exited, status=0/SUCCESS)
Process: 183197 ExecStart=/usr/bin/unshare --uts /bin/sh -c hostname ${NFS_SERVER_SCOPE}; exec "$@" -- /bin/sh -c /usr/sbin/nfsdctl autostart || /usr/sbin/rpc.nfsd (code=exited, status=0/SUCCESS)
Main PID: 183197 (code=exited, status=0/SUCCESS)
Mem peak: 1.8M
This is the nfs_server_scope mechanism from section 32.6.4 made
visible: the resource agent's systemd drop-in runs the NFS server inside a
UTS namespace and sets its hostname to ha-handbook, so the NFSv4 server
identity is the same string no matter which node is serving. The ss
output shows one NFS service bound to all addresses on the owner -
including the virtual address the group placed there.
The whole transition - from the standby command to the group
running on ha2 with the address present - measured sixteen seconds, on
one-vCPU guests with a 1 GB device. Treat that as an observation of the
machinery's speed, not as a service-level number: a production
measurement must count from the moment a client's request stops being
answered, through detection and fencing, to the first answered request,
on the real hardware, with the real workload.
Now verify from the client that did not move. On haclient, as john,
read through the still-mounted NFSv4.2 session:
$ cat /mnt/ha/records/ledger.txt
cluster-record-one
client-write-one
The read returns immediately - it was issued after the service was
confirmed on ha2 - and the data is intact because the hard mount made
this client wait out the transition rather than failing. Then write new
data through the failed-over service:
$ printf "client-write-after-failover\n" >> /mnt/ha/records/ledger.txt
$ cat /mnt/ha/records/ledger.txt
cluster-record-one
client-write-one
client-write-after-failover
$ sha256sum /mnt/ha/records/ledger.txt
b5700a23bc1b1653e76543e0e67481d65766a23089bf301e82665cddeac2b9e7 /mnt/ha/records/ledger.txt
The write reached ha2's DRBD device through its NFS export. Check what
the replication layer thinks of its peer while ha1 is on standby. On
ha2, as john:
$ sudo drbdadm status ha
ha role:Primary
disk:UpToDate
peer connection:Connecting
The surviving primary reports its peer as Connecting because ha1's
clone instance - and with it the DRBD connection - was stopped by the
standby. The status says nothing about the peer's disk, and that is
exactly right: a disconnected peer's data is unknown until the connection
returns. Because ha1 was stopped cleanly by the cluster rather than
dying mid-write, the rejoin that follows the failback below reconnects
without complaint, resynchronizing whatever was written to ha2 while
ha1 was on standby. A standby is a node the cluster stopped on purpose;
the same Connecting status after an unexplained loss would carry no
such comfort.
Fail back deliberately, as promised in section 32.5.4. On ha1, as
john, return the node to service and then request the move:
$ sudo crm node online ha1
INFO: online node ha1
$ sudo crm resource move g_nfs ha1
INFO: Move constraint created for g_nfs to ha1
INFO: Use `crm resource clear g_nfs` to remove this constraint
The online command returns the node to the cluster but does not move
anything - stickiness keeps the group on ha2. The move creates the
location constraint that carries it home. Confirm the result and remove
the constraint so the next unplanned event is not fought by a stale
preference:
$ sudo crm -D plain status
Cluster Summary:
* Stack: corosync (Pacemaker is running)
* Current DC: ha1 (version 3.0.0-3.0.0) - partition with quorum
* Last updated: Wed Nov 25 09:07:35 2026 on ha1
* Last change: Wed Nov 25 09:07:21 2026 by root via root on ha1
* 2 nodes configured
* 6 resource instances configured
Node List:
* Online: [ ha1 ha2 ]
Full List of Resources:
* Clone Set: ms_drbd [p_drbd] (promotable):
* Promoted: [ ha1 ]
* Unpromoted: [ ha2 ]
* Resource Group: g_nfs:
* p_fs (ocf:heartbeat:Filesystem): Started ha1
* p_vip (ocf:heartbeat:IPaddr2): Started ha1
* p_nfs (ocf:heartbeat:nfsserver): Started ha1
* p_export (ocf:heartbeat:exportfs): Started ha1
$ sudo crm resource clear g_nfs
INFO: Removed migration constraints for g_nfs
$ sudo crm -D plain resource status g_nfs
resource g_nfs is running on: ha1
The client saw both transitions. On haclient, as john, read the file
again and count how many times the post-failover line appears:
$ cat /mnt/ha/records/ledger.txt
cluster-record-one
client-write-one
client-write-after-failover
$ grep -c client-write-after-failover /mnt/ha/records/ledger.txt
1
The count is the duplicate-operation check from section 32.2.3, applied for real: two failovers later, every write the client issued exists exactly once. Nothing was lost, and nothing was doubled.
File locking completes the client-side verification. In one terminal on
haclient, as john, take an exclusive lock and hold it:
$ flock /mnt/ha/records/lockfile -c "sleep 30"
The command blocks while holding the lock. In a second terminal, as
john, try to take it without waiting:
$ flock -n /mnt/ha/records/lockfile -c true
| Option | Description |
|---|---|
-x (default) |
Take an exclusive lock |
-n |
Do not wait; fail immediately if the lock is held |
-s |
Take a shared lock |
-c COMMAND |
Run COMMAND with the lock held |
The second command prints nothing and exits with status 1 - the lock is
held through the cluster address by the first terminal, and the file
server refused the second acquisition, which is what a working lock
service looks like. Interrupt the first terminal with Ctrl-C or let the
sleep 30 finish, then confirm the lock is free:
$ flock -n /mnt/ha/records/lockfile -c true
Success prints nothing and exits 0. This exercise acquired a fresh lock after two failovers; it verifies that locking works through the virtual address on the new owner. A reclaim of a lock held across a server loss - the grace-period path of section 32.6.4 - is a separate behavior that this walkthrough's client did not exercise.
The unplanned case exercised in this walkthrough is the communication partition of
section 32.3.5, whose cluster-side outputs are already captured there.
What the partition adds on the client is the hard-mount behavior in its
uncomfortable form. After the partition healed and ha1 had rejoined,
the client's mounted session had gone stale: its read, bounded with
timeout to keep the terminal usable, did not complete within thirty
seconds. On haclient, as john:
$ timeout 30 cat /mnt/ha/records/ledger.txt
timeout runs the command with a deadline; when the deadline expires it
kills the command and exits 124. That is what happened - no output, exit
status 124. A hard mount does not fail; it waits, and the kernel's
reconnection attempts through the stale session had not yet succeeded.
The recovery is to discard the stale mount and remount through the
address:
$ sudo umount -f /mnt/ha || sudo umount -l /mnt/ha
The || runs the lazy unmount only if the forced unmount fails; the
pipeline-like chain is one recovery action with a fallback, and the
command normally prints nothing either way. Remount:
$ sudo mount -t nfs -o vers=4.2 192.168.232.100:/srv/ha-data /mnt/ha
$ cat /mnt/ha/records/ledger.txt
cluster-record-one
client-write-one
client-write-after-failover
The data survived the partition exactly as the cluster arithmetic
predicted: the quorate side served throughout, the minority side wrote
nothing, and the client's only cost was a remount. Two honest caveats
belong with that sentence. First, a wedged NFSv4 mount after a server
transition sometimes needs exactly this forced unmount and remount;
build it into client-side recovery scripts rather than assuming
transparent resumption. Second, the partition experiment cut Corosync
and the QDevice connection but deliberately left the DRBD replication
link (TCP 7789) intact, so no resynchronization or split-brain policy was
exercised. A replication-link-only failure behaves as
Chapter 31 demonstrated: the peers disconnect, the
after-sb-* policies decide how divergent copies reconcile, and the
cluster's fencing is what prevents the two-writer case from arising.
Test that failure mode on the DRBD pair itself before trusting it under
a cluster.
A final note on node loss as such: standby proves the recovery half of the failover sequence, and the partition proves the decision half. An actual power loss adds only the fencing step between them - the cluster must prove the dead node cannot write before promoting the survivor - and that step is the one this unfenced practice cluster skips by design (section 32.4.4).
32.6.6. Checking Data Integrity, Metadata, Lock Recovery, and Measured Service Interruption
The walkthrough has now produced a small, complete evidence set. What it establishes, item by item:
- Data integrity across two failovers. The ledger's three lines are
present and in order after a switchover, a failback, and a partition,
and
grep -ccounts the post-failover line exactly once. The two checksums captured in section 32.6.5 differ because the file grew - a checksum comparison proves integrity only for identical content, so the procedure checksums the fixed baseline first and counts writes second. For a production acceptance test, checksum a file that no one writes during the exercise, then compare it across the failover. - Identity stability.
exportfs -vprinted the same export line - same path, same network, samefsid=1- on both owners, and the systemd evidence showed the sameha-handbookscope on the new server. The client remounted the same export, not a lookalike. - Metadata preservation. The client's append after failover required
no permission change: the
0666mode and the world-writablerecordsdirectory created in section 32.6.2 survived both ownership moves, because the filesystem moved as a block device with its metadata intact. - Lock recovery semantics, bounded by evidence. Lock recovery proper
is the grace-period reclaim that section 32.6.4 described: former
clients re-establish open files and locks against the new server
during the window in which it refuses new state. The walkthrough's
flockexercise supports the mechanism it can - locks acquired, were refused, and released through the virtual address after the group had moved twice - a fresh-lock check on the new owner, not a reclaim by a client that held state across the failure. A production acceptance test adds that case: hold a lock, force the failover, and confirm the client regains it once the grace period ends. - A measured interruption. Sixteen seconds, standby to service, on the practice hardware, with the measurement's boundaries stated in section 32.6.5.
The evidence set is deliberately small enough to run after every change to the cluster: one checksum, one count, one export listing, one lock test, one timed failover. A test plan that cannot be run routinely will not be run at all, and an unverified failover is the assumption that section 32.4.1 spent its whole length arguing against.
32.6.7. Rolling Maintenance, Node Replacement, Independent Backups, and Restore Acceptance
Rolling maintenance is the planned switchover, applied per node. The
sequence: switch the service to the peer with the standby procedure from
section 32.6.5, apply package updates or configuration changes to the idle
node, reboot it if the kernel changed, verify it rejoins as Unpromoted
with its DRBD copy resynchronized, then decide - deliberately - whether
to fail back. Repeat with the nodes exchanged. Section 32.12.1 develops
the standby and maintenance modes in detail, and section 32.12.2 covers
the version-compatibility rules that make the rolling sequence safe.
Node replacement extends the same sequence with the cluster's own join
and remove operations. To replace ha2, for example: switch the service
to ha1, remove the old node with crm cluster remove ha2, build the
replacement host with the same hostname, addresses, and packages, and join
with the same sudo crm cluster join -y -i eth2 -c ha1 shown in
section 32.3.3.
The join retrieves the cluster configuration and authkey; the new node's
DRBD copy then resynchronizes from the surviving primary exactly as
Chapter 31 rebuilt a replaced peer, and Pacemaker integrates
the clone instance with no resources on it. The captured rejoin in
section 32.3.5 - a node returning as Unpromoted while the group stays
put - is the same evidence pattern.
Backups are the independence that replication cannot provide. DRBD keeps
two identical copies and deletes, corrupts, or encrypts both with equal
fidelity, so the cluster's backups must come from somewhere else: an
rsync or dump-style copy of the mounted export made from a separate
host, or a snapshot-based backup of one node's backing device, stored
outside the pair. Chapter 15 covers the policy and
mechanics. What the cluster adds to a backup plan is only the window:
back up from the active node while the service is up, or from the
standby copy while it is idle, and never from both in a way that requires
them to be consistent with each other.
Restore acceptance closes the loop. Restoring is a procedure, not a property, and the test is the one Chapter 31 used for its backup: restore the copy to a scratch location, compare its checksum against the recorded original, and read the result with the application or client that would have to consume it. A restore that has never been exercised is a checksum of hope. Do the exercise at least once when the cluster is first built, and after any change to the data path - a new DRBD resource layout, a changed export list, a new backup host - because those are the changes that silently break restores.