7

I get the error

Cannot create directory /home/hadoop/hadoopinfra/hdfs/namenode/current

While trying to install hadoop on my local Mac.

What could be the reason for this? Just for reference, I'm putting my xml files down below:

mapred-site.xml:

<configuration>

   <property> 
      <name>mapreduce.framework.name</name>
      <value>yarn</value>
   </property>
</configuration>

hdfs-site.xml:

<configuration>
    <property>
      <name>dfs.replication</name>
      <value>1</value>
    </property>

   <property>
      <name>dfs.name.dir</name>
      <value>file:///home/hadoop/hadoopinfra/hdfs/namenode </value>
   </property>

   <property>
      <name>dfs.data.dir</name> 
      <value>file:///home/hadoop/hadoopinfra/hdfs/datanode </value> 
   </property>
</configuration>

core-site.xml:

<configuration>
  <property>
    <name>hadoop.tmp.dir</name>
    <value>/usr/local/Cellar/hadoop/hdfs/tmp</value>
    <description>A base for other temporary directories.</description>
  </property>
  <property>
    <name>fs.default.name</name>
    <value>hdfs://localhost:9000</value>
  </property>
</configuration>

I think my problem lies in my hdfs-site.xml file, but I'm not sure how to pinpoint/change it.

I'm using this tutorial, and "hadoop" in the file path is replaced by my username.

lordingtar
  • 1,042
  • 2
  • 12
  • 29

5 Answers5

8

Possible error: misconfiguration of the hdfs-site.xml file

This happened to me when I was following a setup tutorial. The contents of the hdfs-site.xml for me was

<configuration>
    <property>
            <name>dfs.namenode.name.dir</name>
            <value>/home/hadoop/data/nameNode</value>
    </property>

    <property>
            <name>dfs.datanode.data.dir</name>
            <value>/home/hadoop/data/dataNode</value>
    </property>

    <property>
            <name>dfs.replication</name>
            <value>1</value>
    </property>
</configuration>

Only then I realized that the text hadoop in the above file corresponds to the user name, where in my case, it had to replaced with hduser. When both occurrences of hadoop was replaced with hduser, the hdfs namenode -format command worked fine.

Ébe Isaac
  • 11,563
  • 17
  • 64
  • 97
6

I had this problem too and it was a permission problem. I just did:

sudo chmod 777 /home/hadoop/hadoopinfra/hdfs/namenode/

and works!

Luiz Calaça
  • 61
  • 1
  • 7
0

In the step where you need to verify the hadoop installation, instead of 'hdfs namenode -format' use '/usr/local/hadoop/bin/hdfs namenode -format'

Found this answer from: hadoop java.io.IOException: while running namenode -format

Community
  • 1
  • 1
0

If you are not using any other distro than native hadoop, then add the current user to hadoop group and retry formatting the namenode.

sudo usermod -a -G hadoop <current-username>

In case of using thirdparty hadoop distros such Cloudera, Hortonworks or MapR, switch to root user and again switch to hdfs user then try formatting the namenode will succeed.

$ sudo -i 
$ su - hdfs
$ hdfs namenode -format
S.K. Venkat
  • 1,749
  • 2
  • 23
  • 35
0

Try the Hadoop command with sudo