HADOOP - 减少阶段在简单的MR作业上挂起 [英] HADOOP - Reduce Phase Hangs on Simple MR Job

查看:108
本文介绍了HADOOP - 减少阶段在简单的MR作业上挂起的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的地图缩小工作。最初,这只是将输入目录中的文件复制到输出目录的一种简单方法。地图阶段完成,但缩小阶段只是挂起。我究竟做错了什么?这是一小部分代码,这里是整个工作:

Here is a simple map reduce job. Initially this is just a simple way of copying files in an input directory to an output directory. The Map phase completes, but the reduce phase just hangs. What am I doing wrong? It is a small amount of code, here is the whole job:

import java.io.IOException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.*;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class MapDemo {

    public static class Map extends Mapper<Object, Text, Text, NullWritable> {
        private Text word = new Text();
        public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
            String line = value.toString();
            word.set(line);
            context.write(word, NullWritable.get());
        }
    }

    public static class Reduce extends Reducer<Text, NullWritable, Text, NullWritable> {
        public void reduce(Text key, Iterable<NullWritable> values, Context context) throws IOException, InterruptedException {
            context.write(key, NullWritable.get());
        }
    }

    public static void main(String[] args) throws Exception {
        Configuration configuration = new Configuration();
        Job job = new Job(configuration, "MapDemo");
        job.setJarByClass(WordCount.class);
        job.setMapperClass(Map.class);
        job.setReducerClass(Reduce.class);
        job.setNumReduceTasks(10);
        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(NullWritable.class);
        FileInputFormat.addInputPath(job, new Path(args[0]));
        FileOutputFormat.setOutputPath(job, new Path(args[1]));
        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }

}

它会一直执行,直到挂起:

It executes until here and then just hangs:

$ hadoop jar target/map-demo.jar /Users/dwilliams/input /Users/dwilliams/output
2013-09-16 11:51:19.131 java[6041:1703] Unable to load realm info from SCDynamicStore
13/09/16 11:51:19 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
13/09/16 11:51:19 INFO input.FileInputFormat: Total input paths to process : 1
13/09/16 11:51:19 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
13/09/16 11:51:19 WARN snappy.LoadSnappy: Snappy native library not loaded
13/09/16 11:51:19 INFO mapred.JobClient: Running job: job_201309150844_0012
13/09/16 11:51:20 INFO mapred.JobClient:  map 0% reduce 0%
13/09/16 11:51:25 INFO mapred.JobClient:  map 100% reduce 0%
... then nothing

这里有什么问题?如何解决这个问题?

Whats wrong here? How do I fix this?

推荐答案

需要重新设置namenode的格式并重新启动守护进程。这是在我的mac osx上,可能与睡眠有关。

Needed to reformat namenode and restart daemons. This was on my mac osx, probably related to sleeping.

这篇关于HADOOP - 减少阶段在简单的MR作业上挂起的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆