Once Namenode HA is configured for the Hadoop cluster, generally you have one ‘active’ and one ‘standby’ namenode.
Basically, this enables automatic failover in between the two master servers.
However, today I was faced with a need to manually switch between the namenodes.
The command to manually failover is generally available. However, what I was not sure was: What is the serviceId of Namenode? or How to get the serviceId for hdfs haadmin command?
The name node serviceId can be found at hdfs-site.xml property “dfs.ha.namenodes.”
Then, from the terminal you can proceed to implement the commands as follows:
[hdfs@edge ~]$ hdfs haadmin -getServiceState nn1 standby [hdfs@edge ~]$ hdfs haadmin -getServiceState nn2 active [hdfs@edge ~]$ hdfs haadmin -failover nn2 nn1 Failover to NameNode at hdpmaster01.cloudserver.com/123.45.67.89:8020 successful [hdfs@edge ~]$ hdfs haadmin -getServiceState nn1 active [hdfs@edge ~]$ hdfs haadmin -getServiceState nn2 standby
1 Comment