Our Community is getting an upgrade! To get everything ready for the relaunch, we’ll be placing the site in read-only mode starting September 21st.
We really appreciate your understanding while we get things set up behind the scenes. Catch up on all the exciting details about the move here.
Need help or have questions? Drop us a line at [email protected]

Archives of Support Questions (Read Only)

This is an archived board for historical reference. Information and links may no longer be available or relevant
Announcements
This board is archived and read-only for historical reference. To ask a new question, please post a new topic on the appropriate active board.

how to verify if name node is in safe mode

avatar

how to verify if name node is in safe mode ?

goal - in case of name node in safe mode , then bash script will perform the following steps on one of the masters machines

# su - hdfs  
$ hdfs dfsadmin -safemode get 
$ hdfs dfsadmin -safemode leave 

second how to perform the steps as described in the bash script

is it ok to do the following :

su - hdfs -c "hdfs dfsadmin -safemode get"
su - hdfs -c "hdfs dfsadmin -safemode leave" 
Michael-Bronson
1 ACCEPTED SOLUTION

avatar
Super Guru

@Michael Bronson,

Yes. You can use the second way to achieve your task. You can also use the below to check if namenode is in SafeMode and leave conditionally.

su - hdfs -c "hdfs dfsadmin -safemode get" | grep ON
if [ $? -ne 0 ]
then
  su - hdfs -c "hdfs dfsadmin -safemode leave" 
fi

To run the above script, put the content in a file say xyz.sh

chmod +x xyz.sh
./xyz.sh

Thanks,

Aditya

View solution in original post

1 REPLY 1

avatar
Super Guru

@Michael Bronson,

Yes. You can use the second way to achieve your task. You can also use the below to check if namenode is in SafeMode and leave conditionally.

su - hdfs -c "hdfs dfsadmin -safemode get" | grep ON
if [ $? -ne 0 ]
then
  su - hdfs -c "hdfs dfsadmin -safemode leave" 
fi

To run the above script, put the content in a file say xyz.sh

chmod +x xyz.sh
./xyz.sh

Thanks,

Aditya