2015-07-20 29 views
1

我正在运行减速器数量设置为默认(减速器)的减速器作业。从理论上讲,输出必须每减速一个文件,但是当我跑我的工作,我有两个文件将减速器设置为默认值,但最后我有两个文件

部分-R-00000

部分-R-00001

为什么这是否发生?

群集中只有一个节点。

我Driver类:

 
public class DriverDate extends Configured implements Tool { 

    @Override 
    public int run(String[] args) throws Exception { 
     if (args.length != 2) { 
      System.out.printf("Usage: AvgWordLength inputDir outputDir\n"); 
      System.exit(-1); 
     } 
      Job job = new Job(getConf()); 
      job.setJobName("Job transformacio dates"); 

      job.setJarByClass(DriverDate.class); 
      job.setMapperClass(MapDate.class); 
      job.setReducerClass(ReduceDate.class); 

      job.setMapOutputKeyClass(Text.class); 
      job.setMapOutputValueClass(NullWritable.class); 

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


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


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

      job.waitForCompletion(true); 

     return 0; 
    } 

    public static void main(String[] args) throws Exception{ 
     Configuration conf = new Configuration(); 
     ToolRunner.run(conf,new DriverDate(), args); 
    } 

} 
+0

你可以发表你的主要方法(或驱动程序类),以及所执行的运行程序的命令? – vefthym

+1

没有其他额外的配置,我敢肯定,我运行的jar是正确的。 –

+0

然后,我没有答案...只是等待别人..对不起,祝你好运! – vefthym

回答

0

好的我找到了答案。

在cloudera Manager中,Yarn(MR2)中的配置选项具有每个Job的reducers任务的默认值,一个节点中的cluster设置为2,因此默认reducer的数量为两个。

为了解决这个问题,有两个选项,通过java明确地设置减速器的数量与一个:

job.setNumReduceTasks(1);

,或者Cloudera的经理纱构造改变的默认减速值

1

你是正确的,该代码应该产生一个输出文件,因为reduce任务的默认数量为1,并且每个减速产生一个输出文件。

然而,事情可能出现了问题包括(但不限于):

  • 确保运行正确的罐子,确保您更新正确的罐子,产生它的时候。确保将生成它的计算机上的正确jar复制到(单节点)集群的主节点。例如,在你的指示,你说 Usage: AvgWordLength inputDir outputDir, 但这个罐子的名字是不可能AvgWordLength ...

  • 确保你没有指定不同数量的命令行减速(例如,通过使用-D属性)。

除此之外,我无法找到任何其他可能的原因...

节点群中的数字是不相关的。