Namenode stores meta-data i.e. number of Data Blocks, their location, replicas and other details. This meta-data is available in memory in the master for faster retrieval of data. NameNode maintains and manages the slave nodes, and assigns tasks to them.
Whenever a Name Node is started, it does the following things:
1) It Loads the File System State from the FsImage and the edits logs file.
2) Once the Name node is loaded, it now waits for the Data Nodes to report their blocks. Name Node will just not start replicating the data since already the replicated blocks are on each of the data nodes, the Name node needs to know the blocks from each of the dataNode.
3) Once the Name Node has enough or most of the file system block reported and it is available, it will automatically come out of the Safe mode.
Things to note:
SafeMode– It is the Read-Only mode for the HDFS cluster. The System is the read-only mode, no new block can be added or deleted during this time.
<li style=”list-style-type: none”>
we can also place the HDFS in safe mode manually.
HDFS could be placed in SafeMode by running
bin/hdfs dfsadmin -safemode command
Front page of namenode shows the status of the NameNode if it is in safe mode on or off.
We can make the Name Node to leave safe mode by using
bin/hadoop dfsadmin -safemode leave
It is recommended to run a fsck once to check for any inconsistencies on HDFS.