Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to check the namenode status?

Solved Go to solution

How to check the namenode status?

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

Accepted Solutions

Re: How to check the namenode status?

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
5 REPLIES 5

Re: How to check the namenode status?

@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

Re: How to check the namenode status?

Contributor

@Alex Raj

Check to see if the following helps.

Re: How to check the namenode status?

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

Re: How to check the namenode status?

New Contributor

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

Highlighted

Re: How to check the namenode status?

New Contributor

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

Don't have an account?
Coming from Hortonworks? Activate your account here