NameNode safemode

Safemode is a NameNode state, in which it doesn’t replicate blocks and doesn’t allow any modifications to the file system. The operations that don’t imply any changes to data blocks or the system, like read operations, are still available.

The NameNode enters this state automatically during start up to make time for synchronizing with the DataNodes. After it loads the file system state from the fsimage and the edits log file, it waits for DataNodes block reports. If the number of safely replicated blocks is at the acceptable threshold, the NameNode exits the safemode state.

The NameNode front page shows whether safemode is on or off. For more information on the NameNode UI, see HDFS UI overview.

You can place the NameNode in the safemode state using the dfs admin -safemode command.

To turn the safemode on, run:

$ hdfs dfsadmin -safemode enter

The ouput will look like this:

Safe mode is ON in elenas-adh.ru-central1.internal/127.0.0.1:8020
Safe mode is ON in elenas-adh1.ru-central1.internal/127.0.0.2:8020

If you turned on the NameNode safemode state manually, it has to be manually turned off.

To turn the safemode off, run:

$ hdfs dfsadmin -safemode leave

The ouput will look like this:

Safe mode is OFF in elenas-adh.ru-central1.internal/127.0.0.1:8020
Safe mode is OFF in elenas-adh1.ru-central1.internal/127.0.0.2:8020

In some cases, the NameNode will remain in safemode. You can forcefully turn it off, but it might mean losing some metadata.

To forcefully turn off the safemode, run:

$ hdfs dfsadmin -safemode forceExit
Found a mistake? Seleсt text and press Ctrl+Enter to report it