Wordcount程序在地图部分后失败。抛出以下错误。
这是我在做hadoop设置后尝试的第一个mapreduce程序
操作系统:Mac
hadoop版本:1.2.1
$ HADOOP_OPTS =" -Djava.security.krb5.realm = OX.AC.UK -Djava.security.krb5.kdc = kdc0.ox.ac.uk:kdc1.ox.ac.uk -Djava.net。 preferIPv4Stack =真"
Hadoop日志:
14/06/10 20:58:59 WARN mapred.JobClient: Use GenericOptionsParser for parsing the arguments. Applications should implement Tool for the same.
14/06/10 20:58:59 INFO input.FileInputFormat: Total input paths to process : 1
14/06/10 20:58:59 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
14/06/10 20:58:59 WARN snappy.LoadSnappy: Snappy native library not loaded
14/06/10 20:58:59 INFO mapred.JobClient: Running job: job_201406102056_0002
14/06/10 20:59:00 INFO mapred.JobClient: map 0% reduce 0%
14/06/10 20:59:06 INFO mapred.JobClient: map 100% reduce 0%
14/06/10 21:01:04 INFO mapred.JobClient: Task Id : attempt_201406102056_0002_m_000000_0, Status : FAILED
Too many fetch-failures
14/06/10 21:01:05 WARN mapred.JobClient: Error reading task outputServer returned HTTP response code: 407 for URL: http://localhost:50060/tasklog?plaintext=true&attemptid=attempt_201406102056_0002_m_000000_0&filter=stdout
14/06/10 21:01:05 WARN mapred.JobClient: Error reading task outputServer returned HTTP response code: 407 for URL: http://localhost:50060/tasklog?plaintext=true&attemptid=attempt_201406102056_0002_m_000000_0&filter=stderr
14/06/10 21:01:06 INFO mapred.JobClient: map 0% reduce 0%
14/06/10 21:01:08 INFO mapred.JobClient: map 100% reduce 0%
14/06/10 21:02:10 INFO mapred.JobClient: Task Id : attempt_201406102056_0002_m_000000_1, Status : FAILED
Too many fetch-failures
14/06/10 21:03:10 WARN mapred.JobClient: Error reading task outputRead timed out
14/06/10 21:04:10 WARN mapred.JobClient: Error reading task outputRead timed out
14/06/10 21:06:55 INFO mapred.JobClient: Task Id : attempt_201406102056_0002_m_000000_2, Status : FAILED
Too many fetch-failures
我的wordcount计划:
import java.io.IOException;
import java.util.StringTokenizer;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.Text;
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 WordCount {
public static class TokenizerMapper
extends Mapper<Object, Text, Text, IntWritable>{
private final static IntWritable one = new IntWritable(1);
private Text word = new Text();
public void map(Object key, Text value, Context context
) throws IOException, InterruptedException {
StringTokenizer itr = new StringTokenizer(value.toString());
while (itr.hasMoreTokens()) {
word.set(itr.nextToken());
context.write(word, one);
}
}
}
public static class IntSumReducer
extends Reducer<Text,IntWritable,Text,IntWritable> {
private IntWritable result = new IntWritable();
public void reduce(Text key, Iterable<IntWritable> values,
Context context
) throws IOException, InterruptedException {
int sum = 0;
for (IntWritable val : values) {
sum += val.get();
}
result.set(sum);
context.write(key, result);
}
}
public static void main(String[] args) throws Exception {
Configuration conf = new Configuration();
if (args.length != 2) {
System.err.println("Usage: wordcount <in> <out>");
System.exit(2);
}
Job job = new Job(conf, "word count");
job.setJarByClass(WordCount.class);
job.setMapperClass(TokenizerMapper.class);
job.setCombinerClass(IntSumReducer.class);
job.setReducerClass(IntSumReducer.class);
job.setOutputKeyClass(Text.class);
job.setOutputValueClass(IntWritable.class);
FileInputFormat.addInputPath(job, new Path(args[0]));
FileOutputFormat.setOutputPath(job, new Path(args[1]));
System.exit(job.waitForCompletion(true) ? 0 : 1);
}
}
答案 0 :(得分:2)
此错误表示reducer无法获取映射器输出。如果这种情况反复发生,TaskTrackers可能会被列入黑名单。此外,请确保您没有遭受不正确的DNS解析。
确保映射器端有足够的http线程。可以使用 mapred-site.xml 文件中的 tasktracker.http.threads 属性进行调整。它决定http服务器的工作线程数,并用于映射输出获取。您还可以通过 mapred.reduce.parallel.copies 属性增加并行减少转移的数量。
<强> P.S。 :在驱动程序代码中添加以下行以避免进一步的问题:
job.setMapOutputKeyClass(Text.class);
job.setMapOutputValueClass(IntWritable.class);