11

When I am trying to delete a directory in the HDFS file system, I am getting the following error:

Cannot delete directory. Name node is in safe mode.

How to solve this issue? Please advice.

3 Answers3

12

If you see that error that means the Namenode is in safe mode and it is almost equivalent to read-only mode.

To leave the namenode from the safemode run the below command:

$ hadoop dfsadmin –safemode leave

Shashikanth Komandoor
  • 781
  • 1
  • 11
  • 29
  • 2
    Although this answer was correct in 2014 it is incorrect now because this script was deprecated and does not work. Use "hdfs dfsadmin -safemode leave" as @Philip suggests. – AlexR Aug 20 '19 at 15:47
11

if you are using hadoop 2.9.0 or higher, use

hdfs dfsadmin -safemode leave
Philip
  • 173
  • 1
  • 8
1

In my case the hadoop dfsadmin -safemode leave canceled safemode but as soon as I tried to delete the old directory, the system returned to safemode.

I deleted all the tmp folders that I could find related to hadoop installations but the old directory did not disappear and it could not be deleted.

Finally I used:

ps aux | grep -i namenode

and discovered that there was a running process that was using parameters from an older Hadoop implementation (different version). I killed the process using kill pid and finally this action removed the old directory.

edwcd15
  • 11
  • 2