reducer在mapper完成之前启动

hmae6n7t  于 2021-05-30  发布在  Hadoop
关注(0)|答案(3)|浏览(383)

我正在运行一个map reduce程序。然而,我得到了类似的输出,即使我运行它只有Map器或两者与Map器和减速机。
在这之后,它永远不会完成。它挂在那里。
我不明白为什么减速机是开始之前,Map已经完成100%?可能存在哪些潜在问题?
输出:

Map 10% Reduce 0%
Map 19% Reduce 0%
Map 21% Reduce 0%
Map 39% Reduce 0%
Map 49% Reduce 0%
Map 63% Reduce 0% 
Map 67% Reduce 0% 
Map 68% Reduce 0% 
Map 68% Reduce 22%
Map 69% Reduce 22%

以下是Map程序代码:

public class EntityCountMapper extends Mapper<LongWritable, Text, Text, IntWritable> {
  static String total_record="";

  @Override
  protected void map(LongWritable baseAddress, Text line, Context context)
        throws IOException, InterruptedException {

    Text entity=new Text();
    IntWritable one=new IntWritable(1);

    total_record=total_record.concat(line.toString());
    String[] fields=total_record.split("::");
    if(fields.length==24)
    {
        entity.set(fields[22].trim());          
        context.write(entity,one);
        total_record="";
    }       
  }
}
r1zhe5dt

r1zhe5dt1#

这是由 mapreduce.job.reduce.slowstart.completedmaps 设置。默认情况下,一旦完成5%的Map,就会安排reduces。这通常只会启动reducer的复制阶段。一旦Map完成,每个reducer就会对输入(Map器的输出)进行排序和减少。

7lrncoxx

7lrncoxx2#

reduce阶段有3个步骤:shuffle、sort、reduce。shuffle是reducer从每个Map器收集数据的地方。这可能发生在Map程序生成数据时,因为它只是数据传输。另一方面,排序和减少只能在所有Map器完成后启动。您可以通过查看reducer完成百分比来判断mapreduce在做哪一个:0-33%表示它在执行shuffle,34-66%表示sort,67%-100%表示reduce。这就是为什么你的减速机有时看起来“卡住”在33%——它在等待Map程序完成。

qf9go6mv

qf9go6mv3#

将config“mapreduce.job.reduce.slowstart.completedmaps”的值设置得尽可能高(我们通常按照惯例将其设置在0.96到0.98之间)。这将使Map器完成96%到98%,然后减速器将启动。
这还可以避免在Map程序仍在运行时reducer占用资源。

相关问题