Understanding Safemode in Hadoop
Goals
Safemode is a representation that Hadoop is in read-only mode. It is ideally meant for transitioning the cluster from production to maintenance mode. In this mode, HDFS doesn’t allow any write-related and processing operations.
However, read is possible. When we start Hadoop services, HDFS service goes in safemode to perform the following activities:
- Flush edits to fsimage and load fsimage in-memory
- Get the block report from each DataNode and check the compliance of metadata
- Report and update replication parameters (under-replicated and over-replicated blocks)
However, a user can bring the Hadoop cluster in safemode for the following reasons:
- Check-pointing metadata
- Removing orphaned blocks
- Removing corrupted blocks and its metadata.
HDFS Files: none
Safe Mode
1. How to control safemode activity
To check whether the cluster is in safemode or not:
hdfs dfsadmin -safemode get
To switch the cluster from production to maintenance mode:
hdfs dfsadmin -safemode enter
To switch the cluster from maintenance to production mode:
hdfs dfsadmin -safemode leave
To check whether the HDFS is out of safe mode or not:
```console
hdfs dfsadmin -safemode wait
How to do Checkpointing Manually?
2. Ensure the Hadoop cluster is in safemode
hdfs dfsadmin -safemode enter
3. Commit the edit logs to fsimage
hdfs dfsadmin -saveNamespace
4. Bring the cluster back to production mode
hdfs dfsadmin -safemode leave
Results
Congrats!
You see how the nodes can be checkpointed manually.