Search code examples
hadoophdfs

How to check the namenode status?


As a developer how can I check the current state of a given Namenode if it is active or standby? 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??


Solution

  • Finally, I got an answer to this.

    As a developer, one cannot execute dfsadmin commands due to the restriction. 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 desired program accordingly.

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