Diagnosing HDFS NameNode HA Automatic Failover Failures in Hadoop 2.7+ and 3.x
A step‑by‑step diagnostic guide for HDFS NameNode HA automatic failover failures in Hadoop 2.7+ and 3.x, covering ZooKeeper quorum, fencing mis‑configuration, network partitions, JournalNode health, and firewall issues.
17 Jul 2025, 14:17 UTC

Recognizable Condition
The active NameNode crashes or becomes partitioned, but the standby never takes over. ZKFC logs show Failed to elect active or Fencing failed. Both NameNodes remain in standby and the cluster enters an unsafe mode where no writes succeed.
Cause / Diagnostic Table
| # | Symptom | Likely Root Cause | Quick Verification |
|---|---|---|---|
| 1 | ZKFC cannot acquire lock | ZooKeeper quorum loss | zkCli.sh -server <zk-hosts> ls /hadoop-ha returns error or missing ActiveStandbyElectorLock |
| 2 | Fencing command returns non‑zero | Misconfigured dfs.ha.fencing.methods (shell/ssh) | Run the configured fence script manually; observe exit code |
| 3 | Active isolated from ZooKeeper but reachable by clients | Network partition | Ping ZooKeeper nodes from active NN; check netstat -an | grep 2181 |
| 4 | Edits not syncing | JournalNode quorum unavailable | hdfs jn -status shows majority false |
| 5 | Health checks fail | Firewall blocks NN RPC/HTTP or ZKFC ports | telnet <nn-host> 8020 and telnet <nn-host> 9870 from ZKFC host |
Ordered Checks
- Verify ZooKeeper ensemble – Run on any ZooKeeper node (requires
zkCli.shin PATH):
Expect a list containingzkCli.sh -server zk1:2181,zk2:2181,zk3:2181 ls /hadoop-haActiveStandbyElectorLock. If the command hangs or returnsNode does not exist, quorum is lost. - Check ZKFC processes – On each NameNode host (as
hdfsuser):
Missing process means ZKFC isn’t running; start withjps | grep ZKFChdfs --daemon start zkfc. - Inspect ZKFC logs – Look in
$HADOOP_LOG_DIR/hadoop-hdfs-zkfc-<host>.logfor lines containingElecting activeandFencing. Note timestamps and error codes. - Test fencing command manually – On the standby NameNode (or a client with SSH keys):
Requires passwordlessssh nn1.example.com 'hdfs dfsadmin -fs hdfs://nn1:8020 -shutdownDatanode <dn-host>'sudoforhdfson the target. Exit code 0 confirms the fence works; non‑zero indicates mis‑configuration. - Confirm JournalNode quorum – On any JournalNode host:
Output must show a majority (e.g., 3 of 3, 3 of 5). Bring up any down nodes and verifyhdfs jn -statusdfs.namenode.shared.edits.dirpoints to the correct quorum. - Validate NameNode RPC/HTTP accessibility – From each ZKFC host:
All three ports must accept connections. Firewall or security‑group rules blocking any of them will cause ZKFC health checks to fail.telnet nn1.example.com 8020 telnet nn1.example.com 9870 telnet nn1.example.com 8485
Fixes Tied to Findings
- ZooKeeper quorum loss (1) – Restart the affected ZooKeeper nodes until a majority is online. Verify with
zkCli.shthat theActiveStandbyElectorLockznode reappears. - Fencing mis‑configuration (2) – Edit
hdfs-site.xmlon both NameNodes:
Ensure<property> <name>dfs.ha.fencing.methods</name> <value>shell(/opt/hadoop/bin/fence.sh)</value> </property>fence.shexists, is executable, and uses passwordless SSH keys. Test again with step 4. - Network partition (3) – Enable
dfs.ha.automatic-failover.enabled=trueinhdfs-site.xmland provision redundant network paths (bonded NICs, separate VLANs). Verify that each NameNode can reach the ZooKeeper ensemble over distinct routes. - JournalNode quorum unavailable (4) – Start missing JournalNodes, then run
hdfs namenode -recoveron the active NN if edits are stale. Confirmdfs.namenode.shared.edits.dirlists a majority of JNs. - Firewall blocks (5) – Open TCP ports 8020 (RPC), 9870 (HTTP), and 8485 (ZKFC) on all NameNode and ZKFC hosts. In cloud environments, adjust security groups accordingly.
Escalation Criteria
Engage the platform team when:
- Failover does not complete within
dfs.ha.fencing.timeout.ms(default 10 s) after three consecutive automatic attempts. - Both NameNodes report
HAState=activesimultaneously (split‑brain). - Manual failover via
hdfs haadmin -failover --forceactive <targetNN>is required.
Provide the team with ZKFC logs, ZooKeeper znode state, and the output of the ordered checks.
Limitations & Practical Verification
Automatic failover requires ZooKeeper 3.4.6+; older releases may not honor session expiration reliably. Fencing via SSH depends on passwordless sudo for the hdfs user—mis‑configured /etc/sudoers yields silent failures. Never disable dfs.ha.fencing.methods; without fencing, split‑brain can corrupt HDFS metadata. JournalNode quorum must be odd‑numbered (3, 5); losing majority halts edits and blocks failover. If the NameNode web UI is disabled (dfs.namenode.http-address=0.0.0.0:0), ZKFC cannot monitor the standby.
Verification steps (run after any fix):
- Simulate failover:
hdfs haadmin -failover nn1 nn2– confirm active switches in the NameNode web UI and ZKFC logs. - Run the configured fence command against the current active NN; ensure it returns 0 and the NN transitions to standby.
- Check that the znode
/hadoop-ha/<nameservice>/ActiveStandbyElectorLockexists and its holder matches the active NN. - Monitor HA metrics (NameNode HAState, ZKFC election latency, JournalNode sync lag) via JMX or Prometheus exporters.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.