Safemode is a maintenance state of NameNode during which NameNode doesn’t allow any modifications to the file system. HDFS cluster is in read mode only during safemode.
At the startup of NameNode it loads the file system namespace from the last saved fsimage into its main memory and the edits log file. Then, merges edits log file on fsimage and results in new file system namespace. Then it receives Block reports containing information about block location from all datanodes. In Safemode NameNode performs collection of block reports from datanodes.
NameNode enters safemode automatically during its start up. NameNode leaves Safemode after the DataNodes have reported that most blocks are available.
Use below command to know status of Safemode
hadoop dfsadmin –safemode get
Use below command to know enter in Safemode
bin/hadoop dfsadmin –safemode enter
Use below command to leave Safemode
hadoop dfsadmin -safemode leave