zoukankan      html  css  js  c++  java
  • MapperReduce常见错误及解决方案

    1)导包容易出错。尤其Text和CombineTextInputFormat。
    2)Mapper中第一个输入的参数必须是LongWritable或者NullWritable,不可以是IntWritable. 报的错误是类型转换异常。
    3)java.lang.Exception: java.io.IOException: Illegal partition for 13926435656 (4),说明Partition和ReduceTask个数没对上,调整ReduceTask个数。
    4)如果分区数不是1,但是reducetask为1,是否执行分区过程。答案是:不执行分区过程。因为在MapTask的源码中,执行分区的前提是先判断ReduceNum个数是否大于1。不大于1肯定不执行。
    5)在Windows环境编译的jar包导入到Linux环境中运行,
    hadoop jar wc.jar com.atguigu.mapreduce.wordcount.WordCountDriver /user/atguigu/ /user/atguigu/output
    报如下错误:
    Exception in thread "main" java.lang.UnsupportedClassVersionError: com/atguigu/mapreduce/wordcount/WordCountDriver : Unsupported major.minor version 52.0
    原因是Windows环境用的jdk1.7,Linux环境用的jdk1.8。
    解决方案:统一jdk版本。
    6)缓存pd.txt小文件案例中,报找不到pd.txt文件
    原因:大部分为路径书写错误。还有就是要检查pd.txt.txt的问题。还有个别电脑写相对路径找不到pd.txt,可以修改为绝对路径。
    7)报类型转换异常。
    通常都是在驱动函数中设置Map输出和最终输出时编写错误。
    Map输出的key如果没有排序,也会报类型转换异常。
    8)集群中运行wc.jar时出现了无法获得输入文件。
    原因:WordCount案例的输入文件不能放用HDFS集群的根目录。
    9)出现了如下相关异常

    Exception in thread "main" java.lang.UnsatisfiedLinkError: org.apache.hadoop.io.nativeio.NativeIO(Windows.access0(Ljava/lang/String;I)Z at org.apache.hadoop.io.nativeio.NativeIO)Windows.access0(Native Method)
    at org.apache.hadoop.io.nativeio.NativeIO$Windows.access(NativeIO.java:609)
    at org.apache.hadoop.fs.FileUtil.canRead(FileUtil.java:977)
    java.io.IOException: Could not locate executable nullinwinutils.exe in the Hadoop binaries.
    at org.apache.hadoop.util.Shell.getQualifiedBinPath(Shell.java:356)
    at org.apache.hadoop.util.Shell.getWinUtilsPath(Shell.java:371)
    at org.apache.hadoop.util.Shell.(Shell.java:364)

    解决方案:拷贝hadoop.dll文件到Windows目录C:WindowsSystem32。个别同学电脑还需要修改Hadoop源码。
    10)自定义Outputformat时,注意在RecordWirter中的close方法必须关闭流资源。否则输出的文件内容中数据为空。

    @Override
    public void close(TaskAttemptContext context) throws IOException, InterruptedException {
    		if (atguigufos != null) {
    			atguigufos.close();
    		}
    		if (otherfos != null) {
    			otherfos.close();
    		}
    }
    
    如果真的不知道做什么 那就做好眼前的事情吧 你所希望的事情都会慢慢实现...
  • 相关阅读:
    接收一次性广播,开启服务永久监听
    iOS开发之主题皮肤
    Android软件版本更新
    android服务Service(上)- IntentService
    Android之条码扫描二维码扫描
    Android之Service与IntentService的比较
    强烈推荐visual c++ 2012入门经典适合初学者入门
    转载文章:Windows Azure 七月份更新:SQL 数据库、流量管理器、自动伸缩、虚拟机
    CSV 客座文章系列:KGroup 通过 Windows Azure 将 Qoob 内容管理发布到云中
    Windows Azure 网站:应用程序字符串和连接字符串的工作原理
  • 原文地址:https://www.cnblogs.com/sunbr/p/13680079.html
Copyright © 2011-2022 走看看