如何从远程集群上的本地IDE运行MapReduce程序

时间:2017-03-02 20:31:02

标签: java hadoop mapreduce

我有一个简单的MapReduce程序,我想在远程集群上运行它。我可以通过简单地运行

从命令行执行此操作
hadoop jar myjar.jar input output

但是当我想从我的IDE调用MR作业的junit TestCase类中运行一个函数时,我收到以下警告:

 WARN org.apache.hadoop.mapreduce.JobSubmitter  - No job jar file set.  User classes may not be found. See Job or Job#setJar(String).
 INFO org.apache.hadoop.mapred.YARNRunner  - Job jar is not present. Not adding any jar to the list of resources.

虽然我提交了这一行,但在提交MR工作之前:

job.setJarByClass(MyJob.class);

因此作业失败,因为它无法找到合适的类(如映射器键类MyMapKey)来操作。

Error: java.io.IOException: Initialization of all the collectors failed. Error in last collector was :java.lang.RuntimeException: java.lang.ClassNotFoundException: Class MyMapKey not found
at org.apache.hadoop.mapred.MapTask.createSortingCollector(MapTask.java:414)
at org.apache.hadoop.mapred.MapTask.access$100(MapTask.java:81)
at org.apache.hadoop.mapred.MapTask$NewOutputCollector.<init>(MapTask.java:698)
at org.apache.hadoop.mapred.MapTask.runNewMapper(MapTask.java:770)
at org.apache.hadoop.mapred.MapTask.run(MapTask.java:341)
at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
at java.security.AccessController.doPrivileged(Native Method)
at javax.security.auth.Subject.doAs(Subject.java:422)
at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1709)
at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)

对此有何看法?

1 个答案:

答案 0 :(得分:0)

首先,您应该将远程Hadoop集群配置文件(即core-site.xml,hdfs-site.xml,mapred-site.xml,yarn-site.xml,ssl-client.xml)作为资源添加到Configuration对象。然后按照上面链接中的步骤查看如何将作业jar手动添加到远程集群上的类路径。