What is Safe Mode in Hadoop?
Safe mode is a read-only maintenance state that the NameNode enters automatically under certain conditions. During safe mode, the NameNode does not accept any write operations from clients — no new files, no deletions, no modifications.
What is Safe Mode in Hadoop?
Safe mode is a read-only maintenance state that the NameNode enters automatically under certain conditions. During safe mode, the NameNode does not accept any write operations from clients — no new files, no deletions, no modifications. The cluster is alive but not fully serviceable.
-
When does the NameNode enter safe mode?
There are two situations:
- On startup or restart: The NameNode loads the FS Image into memory, then replays the Edit Log to catch up on any recent changes. It then waits for DataNodes to send their block reports. Only once it has confirmed enough replicas exist does it leave safe mode.
- Automatically: If the percentage of under-replicated blocks drops below the configured minimum threshold (default 99.9%), Hadoop enters safe mode to protect data integrity.
-
What is Checkpointing?
- Over time the Edit Log keeps growing. Checkpointing is the process of merging the Edit Log into the FS Image to create a compact, up-to-date snapshot. This is done by the Standby NameNode (in HA setup) or the Secondary NameNode (in non-HA setup) — not by the Active NameNode itself. The result is a fresh FS Image that loads faster on the next restart.
-
What happens during safe mode?
- NameNode loads FS Image into memory
- DataNodes send block reports — "I have these blocks"
- NameNode verifies replication levels
- Once satisfied → exits safe mode → cluster is fully operational
-
Manual safe mode commands:
- Enter:
hdfs dfsadmin -safemode enter - Leave:
hdfs dfsadmin -safemode leave - Check:
hdfs dfsadmin -safemode get
- Enter:
Interview tip: The key point interviewers want to hear is that safe mode is read-only, it is triggered on restart AND on under-replication, and that checkpointing is the Standby NameNode's job — not the Active NameNode's job.