The command:
hdfs haadmin -getServiceState machine-98
Works only if you know the machine name. Is there any command like:
h
In a High Availability Hadoop cluster, there will be 2 namenodes - one active and one standby.
To find the active namenode, we can try executing the test hdfs command on each of the namenodes and find the active name node corresponding to the successful run.
Below command executes successfully if the name node is active and fails if it is a standby node.
hadoop fs -test -e hdfs:///
Unix script
active_node=''
if hadoop fs -test -e hdfs:/// ; then
active_node=''
elif hadoop fs -test -e hdfs:/// ; then
active_node=''
fi
echo "Active Dev Name node : $active_node"