{"record":{"id":"25c0f53d3cb36456","repo":"apache/hadoop","slug":"ha-is-not-enabled-for-this-namenode-25c0f5","errorCode":null,"errorMessage":"HA is not enabled for this namenode.","messagePattern":"HA is not enabled for this namenode\\.","errorType":"exception","errorClass":"HadoopIllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSZKFailoverController.java","lineNumber":153,"sourceCode":"   *\n   * @param conf input configuration\n   * @return the bind host address found in conf\n   */\n  private static String getZkfcServerBindHost(Configuration conf) {\n    String addr = conf.getTrimmed(\n        DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_BIND_HOST_KEY);\n    if (addr == null || addr.isEmpty()) {\n      addr = conf.getTrimmed(DFSConfigKeys.DFS_NAMENODE_RPC_BIND_HOST_KEY);\n    }\n    return addr;\n  }\n\n  public static DFSZKFailoverController create(Configuration conf) {\n    Configuration localNNConf = DFSHAAdmin.addSecurityConfiguration(conf);\n    String nsId = DFSUtil.getNamenodeNameServiceId(conf);\n\n    if (!HAUtil.isHAEnabled(localNNConf, nsId)) {\n      throw new HadoopIllegalArgumentException(\n          \"HA is not enabled for this namenode.\");\n    }\n    String nnId = HAUtil.getNameNodeId(localNNConf, nsId);\n    if (nnId == null) {\n      String msg = \"Could not get the namenode ID of this node. \" +\n          \"You may run zkfc on the node other than namenode.\";\n      throw new HadoopIllegalArgumentException(msg);\n    }\n    NameNode.initializeGenericKeys(localNNConf, nsId, nnId);\n    DFSUtil.setGenericConf(localNNConf, nsId, nnId, ZKFC_CONF_KEYS);\n    \n    NNHAServiceTarget localTarget = new NNHAServiceTarget(\n        localNNConf, nsId, nnId);\n    return new DFSZKFailoverController(localNNConf, localTarget);\n  }\n\n  private DFSZKFailoverController(Configuration conf,\n      NNHAServiceTarget localTarget) {","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSZKFailoverController.java#L135-L171","documentation":"DFSZKFailoverController.create(conf) builds the ZooKeeper Failover Controller for automatic HA failover. Before doing anything it calls HAUtil.isHAEnabled(localNNConf, nsId), which requires dfs.nameservices to be set and dfs.ha.namenodes.<nsId> to list more than one NameNode for the resolved nameservice. If HA is not configured for that nameservice, the ZKFC refuses to start with this HadoopIllegalArgumentException, because automatic failover is only meaningful for an HA namespace.","triggerScenarios":"Running 'hdfs --daemon start zkfc' (or DFSZKFailoverController.main) where hdfs-site.xml has no dfs.ha.namenodes.<ns> entry for the resolved nameservice id, has dfs.ha.automatic-failover.enabled=true on a non-HA (single NameNode) namespace, or where DFSUtil.getNamenodeNameServiceId(conf) resolves no or the wrong nameservice id so the HA keys never match.","commonSituations":"Starting zkfc before finishing HA setup; pointing HADOOP_CONF_DIR at a stale or client-only config dir on the zkfc host; a typo in dfs.ha.namenodes.<ns> (e.g. missing the nameservice suffix); missing dfs.nameservice.id / dfs.ha.namenode.id so the id cannot be resolved.","solutions":["In hdfs-site.xml set dfs.nameservices (e.g. mycluster) and dfs.ha.namenodes.mycluster=nn1,nn2 with at least two NameNode IDs, then restart zkfc.","Make sure the local node resolves a nameservice id that has HA keys: set dfs.nameservice.id and dfs.ha.namenode.id (or rely on hostname matching via dfs.namenode.rpc-address entries).","Verify HADOOP_CONF_DIR on the zkfc host contains the same HA config used by the NameNodes; a common miss is an old non-HA config left on one host.","Once HA passes, set dfs.ha.automatic-failover.enabled=true and ha.zookeeper.quorum, then format ZK with 'hdfs zkfcadmin -formatZK'."],"exampleFix":"<!-- before: no HA keys for the resolved nameservice -->\n<property><name>dfs.nameservices</name><value>mycluster</value></property>\n\n<!-- after: HA enabled for the nameservice -->\n<property><name>dfs.nameservices</name><value>mycluster</value></property>\n<property><name>dfs.ha.namenodes.mycluster</name><value>nn1,nn2</value></property>\n<property><name>dfs.namenode.rpc-address.mycluster.nn1</name><value>nn1-host:8020</value></property>\n<property><name>dfs.namenode.rpc-address.mycluster.nn2</name><value>nn2-host:8020</value></property>\n<property><name>dfs.ha.namenode.id</name><value>nn1</value></property>","handlingStrategy":"validation","validationCode":"Configuration conf = new HdfsConfiguration();\nString nsId = DFSUtil.getNamenodeNameServiceId(conf);\nif (nsId == null || !HAUtil.isHAEnabled(conf, nsId)) {\n  throw new IllegalStateException(\"zkfc requires an HA nameservice: set dfs.nameservices \"\n      + \"and dfs.ha.namenodes.\" + nsId + \" before starting\");\n}\nDFSZKFailoverController zkfc = DFSZKFailoverController.create(conf);","typeGuard":null,"tryCatchPattern":"try {\n  DFSZKFailoverController.create(conf);\n} catch (HadoopIllegalArgumentException e) {\n  // config-level failure: rethrow with deployment context, do not retry with same conf\n  throw new IllegalStateException(\"ZKFC startup rejected: \" + e.getMessage()\n      + \" (check dfs.nameservices / dfs.ha.namenodes.<ns> on this host)\", e);\n}","preventionTips":["Gate service startup scripts on HAUtil.isHAEnabled so misconfigured hosts fail with your own message before zkfc launches.","Keep zkfc hosts' hdfs-site.xml identical to the NameNodes' and manage it with the same config management tool.","Smoke-test HA config with 'hdfs getconf -confKey dfs.ha.namenodes.<ns>' before enabling automatic failover."],"tags":["hadoop","hdfs","high-availability","zkfc","configuration"],"backgroundTag":"ha-not-enabled","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}