Advertisement

Wednesday, April 18, 2018

Hadoop V2 - Safe Mode

In this blog I will discuss about Safe Mode in Namenode

Safe Mode is a special mode of Hadoop which is read only mode (No client connections still) and no changes are allowed in this mode.
No block replications / deletions allowed as well.


Safe Mode is -
- entered automatically at startup and is left only when enough replicas are found
- entered automatically when disk is running out of space on Namenode
- entered automatically when disk space falls below threshold (dfs.namenode.du.reserved)   
(In this situation you have to clear the disk and exit the safe mode manually)
- entered manually for maintenance and administrative operations


Manual Safe Mode
You can put name node in safe mode manually
1. Get Status of Safe Mode
[hdfs@nn ~]$ hdfs dfsadmin -safemode get
Safe mode is OFF

2. Enter Safe Mode
[hdfs@nn ~]$ hdfs dfsadmin -safemode enter
Safe mode is ON


3. Leave Safe Mode
[hdfs@nn ~]$ hdfs dfsadmin -safemode leave
Safe mode is OFF


4. Safe Mode Wait
hdfs dfsadmin –safemode wait
Wait till all replication is complete (this allows replication in safe mode).
You should already be in safemode to run this command.

Using Safe Mode to Backup Namenode metadata

1. Enter Safe Mode
2. Backup (metsave and saveNamespace)
3. Exit Safe Mode


[hdfs@nn logs]$ hdfs dfsadmin -safemode enter
Safe mode is ON

[hdfs@nn logs]$ hdfs dfsadmin -saveNamespace
Save namespace successful

(New FS Image, Edits and FS MD5 file create)

[hdfs@nn logs]$ hdfs dfsadmin -metasave metadata.txt
Created metasave file metadata.txt in the log directory of namenode hdfs://nn:8020

[hdfs@nn logs]$ hdfs dfsadmin -safemode leave
Safe mode is OFF




No comments:
Write comments