Hadoop作业仅在LocalJobRunner上运行

时间:2015-01-27 17:14:51

标签: java hadoop

Hadoop初学者在这里。我有以下运行和主要方法:

public int run(String[] args) throws Exception {

    Job job = new Job();

    job.setOutputKeyClass(Text.class);
    job.setOutputValueClass(IntWritable.class);

    job.setMapperClass(Map.class);
    job.setReducerClass(Reduce.class);

    job.setInputFormatClass(TextInputFormat.class);
    job.setOutputFormatClass(TextOutputFormat.class);

    FileInputFormat.setInputPaths(job, new Path(args[0]));
    FileOutputFormat.setOutputPath(job, new Path(args[1]));

    job.submit();
    return 0;
    }

 public static void main(String[] args) throws Exception {
    Tool myTool = new Extractor();
    Configuration config = new Configuration();
    config.set("mapred.job.tracker", "<IP>:9001");
    config.set("fs.default.name", "hdfs://<IP>:9000");

    myTool.setConf(config);
    ToolRunner.run(myTool, new String[]{"<file>.json", "output"});
 }

出于某种原因,这运行得很好,但只能在本地机器上运行。这是直接从日食中运行的。虽然工作跟踪器在技术上位于同一个盒子上,但它从不接受任何工作。我的配置有什么问题?

core-site.xml是:

<configuration>
        <property>
                <name>fs.default.name</name>
                <value>hdfs:/<IP>:9000</value>
        </property>
</configuration>

1 个答案:

答案 0 :(得分:1)

你是如何提交工作的?

您的客户端可能无法读取正确的配置文件。确保mapred-site.xml上有类似的内容。因为你从代码中传递了这个,所以应该没问题。

  <property>
    <name>mapred.job.tracker</name>
    <value>localhost:8021</value>
  </property>

还要确保你没有通过

-Dmapred.job.tracker=local

当你运行这份工作时

并在run方法中创建配置,以便您可以这样做。

工作职位=新工作(conf);

相关问题