Hadoop WordCount示例 - Run On Hadoop(Eclipse)选项不提示选择Hadoop服务器在窗口上运行

时间:2013-04-21 15:54:09

标签: eclipse hadoop mapreduce word-count

我正在尝试在 Eclipse 上运行字数统计示例。通常当我们点击eclipse中的“run on hadoop”选项时,我们会得到一个新窗口,要求选择服务器位置。但是,现在它直接运行程序而不要求我从下面的列表中选择现有服务器。

我认为因此我得到以下例外:

13/04/21 08:46:31 ERROR security.UserGroupInformation: PriviledgedActionException as:hduser1 cause:org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: file:/home/hduser1/gutenbergIP/pg4300.txt
Exception in thread "main" org.apache.hadoop.mapred.InvalidInputException: Input path does not exist: file:/home/hduser1/gutenbergIP/pg4300.txt

如果我更改了以下行,我的代码就可以了:

FileInputFormat.setInputPaths(conf, "/home/hduser1/gutenbergIP/pg4300.txt");

为:

FileInputFormat.setInputPaths(conf, "hdfs://localhost:54310/home/hduser1/gutenbergIP/pg4300.txt");

如果我使用完整网址明确指定文件名,那么它正在运行。我想要一些帮助。如何使我的相对URL工作而不是提供完整的URL(必须在学校作为作业提交)。

1 个答案:

答案 0 :(得分:0)

在代码中添加以下两行:

config.addResource(new Path("/HADOOP_HOME/conf/core-site.xml"));
config.addResource(new Path("/HADOOP_HOME/conf/hdfs-site.xml"));

如果你没有指定这个,你的客户端会查看本地FS,它不包含指定的路径,因此会抛出该错误。