使用猪时,hadoop路径出错

时间:2013-06-29 04:02:16

标签: hadoop apache-pig

我有猪和hadoop工作。但由于未知的原因,它停止了为下一个文件工作。在重新安装hadoop和格式化之后,我遇到了一个新问题。我无法将输入文件复制到hadoop:

hduser@ubuntu:/usr/local/hadoop$ bin/hadoop dfs -copyFromLocal /home/hduser/pig/tutorial/pigtmp/bigdata.txt /user/hduser
hduser@ubuntu:/usr/local/hadoop$ bin/hadoop dfs -ls /user/hduser
Found 1 items
-rw-r--r--   1 hduser supergroup   10485760 2013-06-28 20:48 /user/hduser
hduser@ubuntu:/usr/local/hadoop$ 

任何人都可以建议我该怎么办?我对hadoop或猪没有很好的了解。 感谢。

1 个答案:

答案 0 :(得分:0)

您的文件已复制到HDFS,并已复制到您命名为/home/hduser的文件。您列出的ls输出显示文件大小约为10MB。

现在我假设你要找的是该文件存在于文件夹/home/hduser中。我还猜测在运行-copyFromLocal命令之前该文件夹不存在 - 在这种情况下,hadoop将复制到指定文件。如果指定的文件是目录,则hadoop将复制到该目录中的文件(该文件与本地副本同名)。

因此,要解决此问题,您需要在执行-copyFromLocal fs命令之前确保该文件夹存在:

# Delete the current file you have:
hduser@ubuntu:/usr/local/hadoop$ bin/hadoop dfs -rmr /user/hduser

# create the hdusers home directory
hduser@ubuntu:/usr/local/hadoop$ bin/hadoop dfs -mkdir /user/hduser

# Copy the txt file from local to the hduser folder in hdfs
hduser@ubuntu:/usr/local/hadoop$ bin/hadoop dfs -copyFromLocal /home/hduser/pig/tutorial/pigtmp/bigdata.txt /user/hduser/

# Now the ls should show the file
hduser@ubuntu:/usr/local/hadoop$ bin/hadoop dfs -ls /user/hduser/