SafeModeException: Name node is in safe mode

classorg_1_1apache_1_1hadoop_1_1hdfs_1_1server_1_1namenode_1_1_safe_mode_exception

org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory /user/...../test. Name node is in safe mode.

In order to forcefully let the namenode leave safemode, following command should be executed:

$ bin/hadoop dfsadmin -safemode leave

-safemode isn’t a sub-command for hadoop fs, but it is of hadoop dfsadmin.

Run following command so that any inconsistencies in the hdfs might be sorted out.

$ hadoop fsck

Reference:

http://hadoop.apache.org/docs/stable/hdfs_user_guide.html#Safemode

 https://www.inkling.com/read/hadoop-definitive-guide-tom-white-3rd/chapter-10/hdfs

Namenode not starting

I was using Hadoop in a pseudo-distributed mode and everything was working fine. But when I restarted my computer I can’t start Namenode. Only way I can start Namenode is by formatting it and I end up losing data in HDFS.

  • Make following changes to start Namenode 

In conf/hdfs-site.xml, you should have a property like

<property>

    <name>dfs.name.dir</name>

    <value>/home/hduser/hadoop/data</value>

</property>

The property “dfs.name.dir” allow you to control where Hadoop writes NameNode metadata. And giving it another dir rather than /tmp makes sure the NameNode data isn’t being deleted when you reboot.

Format Namenode after you change it

$ bin/hadoop namenode -format

$ bin/hadoop start-all.sh


Reference:

http://hadoop.apache.org/docs/stable/hdfs-default.html

%d bloggers like this: