Reputation: 91
I'm trying to copy a local file called 'afile' to the HDFS. So I ran the following command:
'hadoop fs -copyFromLocal /home/neo/afile in' or 'hadoop fs -put /home/neo/afile in'
However, it says: 'File /home/neo/afile does not exist'
Then I put the file 'afile' into the directory under hadoop. Now the copyFromLocal succeeded. However, the file 'in' is empty, since I run 'hadoop fs - ls', it shows
'-rw-r--r--' 1 neo supergroup 0 2015-04-06 17:45 /user/neo/in
I also tried 'hadoop fs -cat in', nothing returned.
Could someone please help?
Thanks!
Upvotes: 1
Views: 4024
Reputation: 2574
Create a new file in local filesystem named test.txt
in /home/neo/
Add content to test.txt
: echo "sample text for wordcount" > /home/neo/test.txt
Create a new directory in hdfs using: hadoop fs -mkdir /user/neo/in/
Copy file from local directory to HDFS: hadoop fs -copyFromLocal /home/neo/test.txt /user/neo/in/test.txt
Upvotes: 2