4

I referred to these questions Name node is in safe mode. Not able to leave and SafeModeException : Name node is in safe mode.

the commands i have executed is below

enter image description here

it shows that the safe mode is off but the immediate next command shows name node is in safe mode.

and ls /root is shown below

enter image description here

how to fix it ??

Community
  • 1
  • 1
Tejus Prasad
  • 6,322
  • 7
  • 47
  • 75

2 Answers2

5

Does this happen always Or only at the beginning only when you start hadoop?

If only at the beginning, then wait for sometime in order for NameNode to check if everything is okay before you access hdfs. If it's not leaving safemode after a considerable amount of time, that means there is some imbalance in the filesystem (e.g. under replicated or corrupted blocks). Under replicated blocks will be automatically balanced after some time. For corrupted blocks, you can have a look at output of this command:

hdfs fsck -list-corruptfileblocks

And try to delete corrupted blocks using:

hdfs fsck / -delete

If this does not help, as suggested by @Nishu, use hdfs dfsadmin -safemode leave command to get NameNode out of safemode forcefully. Once you do so, check the output of hdfs dfsadmin -safemode get to confirm that safemode is actually turned off.

PradeepKumbhar
  • 3,361
  • 1
  • 18
  • 31
  • If you manually want to fix the under-replicated blocks, this link might be useful: https://community.hortonworks.com/articles/4427/fix-under-replicated-blocks-in-hdfs-manually.html – PradeepKumbhar Mar 16 '16 at 06:25
  • In my case, it was in safe node because resources were low (running on docker) – pomber Oct 09 '17 at 22:37
1

Try with following command :

[ubuntu~]bin/hdfs dfsadmin -safemode leave

For newer distribution, hadoop dfsadmin command is deprecated, instead use hdfs dfsadmin command.

Nishu Tayal
  • 20,106
  • 8
  • 49
  • 101
  • It doe not work for me. though it says "Safe mode is OFF" after running the cmd, it still fail to mkdir "mkdir: Cannot create directory /public. Name node is in safe mode." – Leon Jul 25 '17 at 04:31