apache/hadoop · error · HadoopIllegalArgumentException

HA is not enabled for this namenode.

Error message

HA is not enabled for this namenode.

What it means

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.

Source

Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSZKFailoverController.java:153

   *
   * @param conf input configuration
   * @return the bind host address found in conf
   */
  private static String getZkfcServerBindHost(Configuration conf) {
    String addr = conf.getTrimmed(
        DFSConfigKeys.DFS_NAMENODE_SERVICE_RPC_BIND_HOST_KEY);
    if (addr == null || addr.isEmpty()) {
      addr = conf.getTrimmed(DFSConfigKeys.DFS_NAMENODE_RPC_BIND_HOST_KEY);
    }
    return addr;
  }

  public static DFSZKFailoverController create(Configuration conf) {
    Configuration localNNConf = DFSHAAdmin.addSecurityConfiguration(conf);
    String nsId = DFSUtil.getNamenodeNameServiceId(conf);

    if (!HAUtil.isHAEnabled(localNNConf, nsId)) {
      throw new HadoopIllegalArgumentException(
          "HA is not enabled for this namenode.");
    }
    String nnId = HAUtil.getNameNodeId(localNNConf, nsId);
    if (nnId == null) {
      String msg = "Could not get the namenode ID of this node. " +
          "You may run zkfc on the node other than namenode.";
      throw new HadoopIllegalArgumentException(msg);
    }
    NameNode.initializeGenericKeys(localNNConf, nsId, nnId);
    DFSUtil.setGenericConf(localNNConf, nsId, nnId, ZKFC_CONF_KEYS);
    
    NNHAServiceTarget localTarget = new NNHAServiceTarget(
        localNNConf, nsId, nnId);
    return new DFSZKFailoverController(localNNConf, localTarget);
  }

  private DFSZKFailoverController(Configuration conf,
      NNHAServiceTarget localTarget) {

View on GitHub (pinned to 2add963021)

Solutions

  1. 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.
  2. 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).
  3. 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.
  4. Once HA passes, set dfs.ha.automatic-failover.enabled=true and ha.zookeeper.quorum, then format ZK with 'hdfs zkfcadmin -formatZK'.

Example fix

<!-- before: no HA keys for the resolved nameservice -->
<property><name>dfs.nameservices</name><value>mycluster</value></property>

<!-- after: HA enabled for the nameservice -->
<property><name>dfs.nameservices</name><value>mycluster</value></property>
<property><name>dfs.ha.namenodes.mycluster</name><value>nn1,nn2</value></property>
<property><name>dfs.namenode.rpc-address.mycluster.nn1</name><value>nn1-host:8020</value></property>
<property><name>dfs.namenode.rpc-address.mycluster.nn2</name><value>nn2-host:8020</value></property>
<property><name>dfs.ha.namenode.id</name><value>nn1</value></property>
Defensive patterns

Strategy: validation

Validate before calling

Configuration conf = new HdfsConfiguration();
String nsId = DFSUtil.getNamenodeNameServiceId(conf);
if (nsId == null || !HAUtil.isHAEnabled(conf, nsId)) {
  throw new IllegalStateException("zkfc requires an HA nameservice: set dfs.nameservices "
      + "and dfs.ha.namenodes." + nsId + " before starting");
}
DFSZKFailoverController zkfc = DFSZKFailoverController.create(conf);

Try / catch

try {
  DFSZKFailoverController.create(conf);
} catch (HadoopIllegalArgumentException e) {
  // config-level failure: rethrow with deployment context, do not retry with same conf
  throw new IllegalStateException("ZKFC startup rejected: " + e.getMessage()
      + " (check dfs.nameservices / dfs.ha.namenodes.<ns> on this host)", e);
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/25c0f53d3cb36456. Report an issue: GitHub.