1
votes

I've tried to add a text file to HDFS filesystem, but Hadoop refuses it with error message "No such file or directory".

$ bin/hdfs dfs -put /home/NDelt/Datasets/SampleText.txt /home/NDelt/HadoopDir/hdata
put: `/home/NDelt/HadoopDir/hdata': No such file or directory: `hdfs://localhost:9000/home/NDelt/HadoopDir/hdata'

But the path of SampleText.txt and hdata directory is correct. What is the problem?

This is my hdfs-site.xml file:

<configuration>
  <property>
    <name>dfs.replication</name>
    <value>1</value>
  </property>
  <property>
    <name>dfs.namenode.name.dir</name>
    <value>/home/NDelt/HadoopDir/hdata/dfs/namenode</value>
  </property>
  <property>
    <name>dfs.datanode.data.dir</name>
    <value>/home/NDelt/HadoopDir/hdata/dfs/datanode</value>
  </property>
</configuration>
2

2 Answers

2
votes

As cricket_007 mentioned, there's no /home directory in HDFS.

How to test hdfs put

$ bin/hdfs dfs -put /home/NDelt/Datasets/SampleText.txt /tmp

And test whether the file is added in HDFS by

$ bin/hdfs dfs -get /tmp/SampleText.txt

If the file content is small, you can also view the content

$ bin/hdfs dfs -cat /tmp/SampleText.txt

1
votes

On HDFS, there is no /home directory

Your user account in HDFS would be under /user

And you'd need to explicitly create the HDFS parent path of where you're putting files first with hdfs mkdir -p

There is also no requirement to match your local file system exactly over into HDFS