[英]HADOOP - Reduce Phase Hangs on Simple MR Job
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.
Map阶段完成,但是reduce阶段刚刚挂起。 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?
我该如何解决?
Needed to reformat namenode and restart daemons. 需要重新格式化namenode并重新启动守护程序。 This was on my mac osx, probably related to sleeping.
这是在我的Mac OS X上,可能与睡眠有关。
My problem was memory. 我的问题是记忆。 I was using VirtualBox and I used the default 512M memory.
我使用VirtualBox,并且使用默认的512M内存。 After increasing the memory to 2G, everything worked.
将内存增加到2G之后,一切正常。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.