Two runbooks for a ZooKeeper ensemble in trouble. Pick by how much of the ensemble is down: one member that cannot start is rebuilt from its healthy peers; an ensemble that lost quorum is rebuilt from one approved snapshot.
flowchart TD accTitle: Choosing a ZooKeeper recovery runbook accDescr: If exactly one member is damaged and the others still form a healthy quorum, recover that single member. If no two members report a healthy quorum, follow the approved quorum-loss restore from one snapshot. Anything uncertain is escalated. S[ZooKeeper member or ensemble down] --> Q{Do two members report a healthy quorum?} Q -->|Yes, one member damaged| One[Recover the single member] Q -->|No| Lost[Restore after quorum loss from one approved snapshot] Q -->|Unsure| E[Stop and escalate]
Recovering a single member
Use this when exactly one ZooKeeper member cannot start because a full disk left its transaction log incomplete, typically with Last transaction was partial., Unable to load database on disk, or java.io.EOFException.
Freeing disk space removes the write blockage but does not repair a truncated log, and looping on restarts does not help.1
Preconditions
Proceed only if exactly one member is damaged, the others form a healthy quorum, dataDir and any dataLogDir are known, the damaged member is stopped, and there is capacity for a backup and a fresh sync. Stop and escalate if quorum is unavailable, freshness is uncertain, or more than one member needs rebuilding.1
Steps
- Confirm quorum on the healthy members. Expect one leader and one follower,
Outstanding: 0, and matching or convergingZxidandNode count.imokfromruokonly proves the process is bound, not that it is in quorum. Do not widen the four-letter-word allowlist during the incident; on a TLS-only port usezkServer.sh statuswith TLS settings. - Read the real paths from
zoo.cfgandmyid; confirm noQuorumPeerMainprocess or listener remains. - Move, do not delete, the damaged
version-2to a timestamped name, keepingmyidunchanged; move a distinctdataLogDircopy separately. Do not create a newversion-2by hand. - Start the member and look for leader discovery and a DIFF, SNAP, or TRUNC sync ending in the follower role.1
Acceptance
One leader, two followers, Outstanding: 0, matching Node count, and matching or converging Zxid. Then repeat the original dependent-service request (the runbook loops it 20 times), because ZooKeeper recovering does not prove it was the only cause.
Never clear version-2 on two or more members, copy another member’s myid, chmod 777, or delete the backup right after the member rejoins.1
Restoring after quorum loss
An incident-only procedure for a three-member ZooKeeper ensemble that has lost quorum and cannot accept updates. With no surviving authoritative copy to resync from, recovery is a rebuild from one approved snapshot. It destroys each member’s current local state and may lose writes made after the snapshot.2
Before starting
- Incident commander, ZooKeeper owner, application owners, and security owner approve it.
- Client traffic is blocked and applications are stopped or in safe mode.
- No two members report a healthy quorum; if two do, use single-member recovery instead.
- One approved snapshot with a verified SHA-512 checksum, an administrator certificate already proven to hold
ALLon/,serializeLastProcessedZxidenabled, and a rehearsal in an isolated environment.2
Steps
- Confirm quorum loss and preserve evidence on all three members.
ruokis not quorum evidence. - Enable a temporary AdminServer on one member through a systemd drop-in: bound to
127.0.0.1:8443, HTTPS forced, client certificate required. Reach it only through an SSH tunnel, and confirm a request without the client certificate fails. - Restore member by member. Stop the member, move both
version-2directories aside with a timestamp, create empty ones plus the one-timeinitializemarker, start it,POSTthe same verified snapshot to/commands/restore, then persist it with/commands/snapshot?streaming=falseand recordlast_zxid. Never mix snapshots or run members in parallel. - Re-form quorum without restarting: wait for election and check for exactly one leader and two followers. If it does not form, stop and escalate rather than retrying as an experiment.
- Close the recovery interface. Remove the drop-in, restart one member at a time, and confirm nothing listens on
8443. Run each application’s ACL checks, reopen traffic gradually, and keep the preserved directories until the incident closes.2