Skip to main content
khanarshadazmat
Gold ⭐️
May 30, 2021
Question

How to find active namenode from cli

Hi Team,

 

How to find active name node from cli and also want to know where to check automatic namenode failover triggered in the cluster?

3 replies

vamsi_redd
Gold ⭐️
Gold ⭐️
May 30, 2021

Hi,

 

 You can use the below ambari api to get the Active NN:

 

http://{HOST}:8080/api/v1/clusters/{CLUSTER_NAME}/host_components?HostRoles/component_name=NAMENODE&...

 
Translate
khanarshadazmat
Gold ⭐️
May 31, 2021

Thanks to @vamsi_redd for helping us with Ambari API.

Do you have the same API for Cloudera Manager as well?

Translate
tjangid
Gold ⭐️
Gold ⭐️
May 31, 2021

Hello @khanarshadazmat ,

 

You may get the role information using CM API for HDFS service.

 

API: 

https://archive.cloudera.com/cm7/7.2.4/generic/jar/cm_api/apidocs/resource_RolesResource.html#resource_RolesResource_ClustersResourceV43_ServicesResourceV42_RolesResourceV41_readRoles_GET

 

See the below example for a better understanding:

• When I execute the above API, I would get the below details for HDFS service:

"name" : "HDFS-1-NAMENODE-cb7144bc695976e34cfbaaf26c176d21",
"type" : "NAMENODE",
"serviceRef" : {
"clusterName" : "Cluster 1",
"serviceName" : "HDFS-1",
"serviceDisplayName" : "HDFS-1",
"serviceType" : "HDFS"
},
...
"roleState" : "STARTED",
"healthSummary" : "GOOD",
"configStalenessStatus" : "FRESH",
"haStatus" : "STANDBY",
"maintenanceMode" : false,
"commissionState" : "COMMISSIONED",
"roleConfigGroupRef" : {
"roleConfigGroupName" : "HDFS-1-NAMENODE-BASE"
},

• and, for the second namenode, I'll get something as below:

"name" : "HDFS-1-NAMENODE-b1d777dd6714507397225b07ea9057ce",
"type" : "NAMENODE",
"serviceRef" : {
"clusterName" : "Cluster 1",
"serviceName" : "HDFS-1",
"serviceDisplayName" : "HDFS-1",
"serviceType" : "HDFS"
},
...
"roleState" : "STARTED",
"healthSummary" : "GOOD",
"configStalenessStatus" : "FRESH",
"haStatus" : "ACTIVE",
"maintenanceMode" : false,
"commissionState" : "COMMISSIONED",
"roleConfigGroupRef" : {
"roleConfigGroupName" : "HDFS-1-NAMENODE-BASE"
},
"entityStatus" : "GOOD_HEALTH"

• In both the above examples, check for the keyword "haStatus". The namenode with haStatus as Active would be your Active Namenode. 

 

Let me know if this helps.

 

Cheers!

Was your question answered? Make sure to mark the answer as the accepted solution.

If you find a reply useful, say thanks by clicking on the thumbs up button.

Translate