Question

The file new.txt is available for sure; I dunno why when I'm trying to move into directory of hdfs, it's saying file doesn't exist.

deepak@deepak:/$ cd $HOME/fs
deepak@deepak:~/fs$ ls
new.txt
deepak@deepak:~/fs$ cat new.txt
an apple a day keeps the doctor away
deepak@deepak:~/fs$ hadoop fs -cp $HOME/fs/new.txt $HOME/hdfs
cp: File does not exist: /home/deepak/fs/new.txt
deepak@deepak:~/fs$ 

PS: I have created a directory called hdfs already:

deepak@deepak:~/fs$ hadoop fs -mkdir $HOME/hdfs
mkdir: cannot create directory /home/deepak/hdfs: File exists
Was it helpful?

Solution

cp is used when you wish to copy data from one HDFS location to another HDFS location. But you intend to copy data from your local FS to HDFS. To copy data from local FS to HDFS you can use either put or copyFromLocal.

If you really wish to do it using cp then you must specify the complete path along with the scheme. Say,

hadoop fs -cp file:///Users/miqbal1/date.txt /

cp by default assumes the scheme to be hdfs://

But why would you do that, when you have put and copyFromLocal??

HTH

OTHER TIPS

For copying files from local to hdfs, Following command should be used

hadoop fs -copyFromLocal $HOME/fs/new.txt $HOME/hdfs

For cat hdfs file you may use the following command

hadoop fs -cat $HOME/hdfsnew.txt 
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top