<span style="font-size: 14px;"></span>
用hadoop streaaming写了个小的mapreduce实验程序,脚本如下:
#! /bash/shhadoop jar /usr/share/hadoop/contrib/streaming/hadoop-streaming-1.2.1.jar \-input intest \-output outtest \-mapper cat \-reducer cat\-file intest
运行后出现了错误:ERROR streaming.StreamJob: Job not successful. Error: # of failed Reduce Tasks exceeded allowed limit. FailedCount: 1. LastFailedTask: task_201406150409_0003_r_000000
这个问题是说reduce任务执行超时,也就是reduce失败了。但是只通过这个输出是没法锁定问题所在的,还要去看运行日志(现在真心觉得hadoop日志太重要了,不管什么问题基本都能从日志中找到起因)。在日志中可以看到这样一个错误:
Caused by: java.io.IOException: Cannot run program "cat-file": java.io.IOException: error=2, No such file or directory
这个错误的意思是说找不到程序”cat-file“,但是我为reduce指定的程序其实是cat,看来是书写错误。赶紧回到脚本,发现-reducer cat和下一行的-file选项之间少了个空格,这让hadoop误以为cat和-file是一体的,所以导致了之前的错误。将空格加上后,问题得到解决。