All Products
Search
Document Center

E-MapReduce:HDFS HA commands (hdfs haadmin)

Last Updated:Mar 17, 2025

This topic describes the hdfs haadmin commands that are provided by Hadoop Distributed File System (HDFS) to implement high availability (HA).

Background information

In versions earlier than Hadoop 2.0.0, only one NameNode is deployed in each cluster. If the NameNode is unavailable, the cluster also becomes unavailable. The cluster cannot provide services until the NameNode reestablishes a connection with the cluster.

Single-NameNode deployment affects the availability of HDFS clusters in the following aspects:

  • If an exception occurs, such as node downtime, the cluster becomes unavailable. In this case, you must manually restart the NameNode.

  • If you perform O&M operations, such as software update or hardware upgrade, the cluster also becomes unavailable during a period of time.

The HDFS HA feature can be used to resolve the issues. In HA mode, two NameNodes are deployed in active-standby mode. You can perform a switchover between the NameNodes to restore services of a cluster in case of node downtime or during O&M.

Limits

You must turn on High Service Availability when you create an E-MapReduce (EMR) cluster.

HDFS HA

EMR HA clusters use Quorum Journal Manager (QJM) to implement HDFS HA. For more information about the HA architecture, see Architecture. For information about the deployment topology of HDFS, see Deployment topology of HDFS.

Common HDFS HA commands

View the status of all NameNodes

Run the hdfs haadmin -getAllServiceState command to query the status of all NameNodes. Sample commands:

su - hdfs
hdfs haadmin -getAllServiceState

Sample success response:

master-1-1.c-dadaf2f2bea8****.cn-hangzhou.emr.aliyuncs.com:8021 standby
master-1-2.c-dadaf2f2bea8****.cn-hangzhou.emr.aliyuncs.com:8021 active
master-1-3.c-dadaf2f2bea8****.cn-hangzhou.emr.aliyuncs.com:8021 standby

Check whether a NameNode is in the active or standby state

Run the hdfs haadmin -getServiceState <serviceId> command. The value active or standby is returned.

  • View the status of nn1.

    su - hdfs
    hdfs haadmin -getServiceState nn1
  • View the status of nn2.

    su - hdfs
    hdfs haadmin -getServiceState nn2
  • View the status of nn3.

    su - hdfs
    hdfs haadmin -getServiceState nn3

Perform a switchover between the active and standby NameNodes

Run the hdfs haadmin -failover <serviceId of current active> <serviceId of new active> command to perform a switchover between the active and standby NameNodes.

For example, nn1 is the current active NameNode. After you run the following commands, nn2 serves as the new active NameNode. If nn2 is already the active NameNode, nn2 still serves as the active NameNode after the commands are run.

su - hdfs
hdfs haadmin -failover nn1 nn2

Sample success response:

Failover to NameNode at master-1-2.c-dadaf2f2bea8****.cn-hangzhou.emr.aliyuncs.com successful