Support Questions

Find answers, ask questions, and share your expertise

How to check the namenode status?

avatar
Expert Contributor

As a developer how can I check the current state of a given Namenode? I have tried the getServiceState command but that is only intended for the admins with superuser access. Any command that can be run from the edge node to get the status of a provided namemnode??

1 ACCEPTED SOLUTION

avatar
Expert Contributor

Finally, I got an answer to this.

As a developer, one cannot execute dfsadmin commands due to the restriction in the policy. To check the namenode availability I used the below if loop in shellscript which did the trick. It wont tell you exactly the namenode is active but with the loop you can easily execute the program accordingly.

if hdfs dfs -test -e hdfs://namenodeip/* ; then
echo exist
else 
echo not exist
fi

View solution in original post

5 REPLIES 5

avatar

@Alex Raj

You can run the command

hdfs dfsadmin -report

However you may not able to see full output but still can see something like below

Configured Capacity: 28956426240 (26.97 GB)Present Capacity: 9947332608 (9.26 GB)DFS Remaining: 7329509376 (6.83 GB)DFS Used: 2617823232 (2.44 GB)DFS Used%: 26.32%Under replicated blocks: 0Blocks with corrupt replicas: 0Missing blocks: 0Missing blocks (with replication factor 1): 0

avatar
Rising Star

@Alex Raj

Check to see if the following helps.

avatar
Expert Contributor

Finally, I got an answer to this.

As a developer, one cannot execute dfsadmin commands due to the restriction in the policy. To check the namenode availability I used the below if loop in shellscript which did the trick. It wont tell you exactly the namenode is active but with the loop you can easily execute the program accordingly.

if hdfs dfs -test -e hdfs://namenodeip/* ; then
echo exist
else 
echo not exist
fi

avatar

You can do a curl command to find out the Active and secondary Namenode for example

curl -u username -H "X-Requested-By: ambari" -X GET http://cluster-hostname:8080/api/v1/clusters//services/HDFS

avatar
Rising Star

You can find it from boht way

thorugh Hadoop commands and Curl command

1) hdfs dfsamdin -report

2) Hadoop fsck /

3) curl -u username -H "X-Requested-By: ambari" -X GET http://cluster-hostname:8080/api/v1/clusters/clustername/services/HDFS