Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot create directory in hdfs NameNode is in safe mode

Tags:

hadoop

hdfs

I upgrade to the latest version of cloudera.Now I am trying to create directory in HDFS

hadoop fs -mkdir data

Am getting the following error

Cannot Create /user/cloudera/data Name Node is in SafeMode.

How can I do this?

like image 581
Arun Kumar Avatar asked Jun 10 '17 03:06

Arun Kumar


People also ask

What does namenode in safe mode mean in Hadoop?

Namenode in safe mode means, Hadoop is in read-only mode. At this point, Hadoop won’t allow any files to be written/append into HDFS, i.e., no changes are allowed in HDFS. So, if we try to create a directory in HDFS, above error in question will be thrown.

What is the use of SafeMode in HDFS?

Namenode enters into safemode when there is shortage of memory. As a result the HDFS becomes readable only. That means one can not create any additional directory or file in the HDFS. To come out of the safemode, the following command is used: But it doesn't always solve the problem. The complete solution lies in making some space in the memory.

Why can't I create a directory or file in HDFS?

That means we can not create any additional directory or file in the HDFS, as it may effect replication of files due to less storage. Secondly, during start up Namenode loads the filesystem state from fsimage and edits log file.

What happened to dfsadmin in Hadoop?

hadoop dfsadmin has been deprecated and so is hadoop fs command, all hdfs related tasks are being moved to a separate command hdfs. Basically namenode enters in safe mode in unusual situations, for example when disk is full, also in the start-up phase. Read more here; hadoop.apache.org/docs/stable/hdfs_user_guide.html#Safemode


Video Answer


2 Answers

When you start hadoop, for some time limit hadoop stays in safemode. You can either wait (you can see the time limit being decreased on Namenode web UI) until the time limit or You can turn it off with

hadoop dfsadmin -safemode leave

The above command turns off the safemode of hadoop

like image 68
Ramesh Maharjan Avatar answered Oct 12 '22 10:10

Ramesh Maharjan


In addition to Ramesh Maharjan answer, By default, cloudera machine(Cloudera Quick Start#5.12) doesn't allow to SET OFF safe mode, it's required to specify the -u options as shown below:

sudo -u hdfs hdfs dfsadmin -safemode leave
like image 35
Suresh Gautam Avatar answered Oct 12 '22 09:10

Suresh Gautam