zoukankan      html  css  js  c++  java
  • hive中创建子表并插入数据过程初始化MR报错解决方法

    本文继成上一篇通过hive分析nginx日志文章,详情参考下面链接:

    http://www.cnblogs.com/wcwen1990/p/7066230.html

    接着来:

    创建业务子表:

    drop table if exists chavin.nginx_access_log_comm;
    create table if not exists chavin.nginx_access_log_comm(
    host STRING,
    time STRING,
    request STRING,
    referer STRING
    )
    row format delimited fields terminated by ' '
    STORED AS orc tblproperties("orc.compress"="SNAPPY");
    insert into chavin.nginx_access_log_comm select host,time,request,referer from chavin.nginx_access_log;

    结果报错如下:

    hive (default)> insert into chavin.nginx_access_log_comm select host,time,request,referer from chavin.nginx_access_log;
    Query ID = root_20170623203838_35656104-9f46-4801-9dbd-1d5685de8187
    Total jobs = 1
    Launching Job 1 out of 1
    Number of reduce tasks is set to 0 since there's no reduce operator
    Starting Job = job_1498218985196_0009, Tracking URL = http://db01:8088/proxy/application_1498218985196_0009/
    Kill Command = /opt/cloudera/parcels/CDH-5.9.2-1.cdh5.9.2.p0.3/lib/hadoop/bin/hadoop job  -kill job_1498218985196_0009
    Hadoop job information for Stage-1: number of mappers: 4; number of reducers: 0
    2017-06-23 20:38:10,702 Stage-1 map = 0%,  reduce = 0%
    2017-06-23 20:38:32,584 Stage-1 map = 100%,  reduce = 0%
    Ended Job = job_1498218985196_0009 with errors
    Error during job, obtaining debugging information...
    Examining task ID: task_1498218985196_0009_m_000002 (and more) from job job_1498218985196_0009

    Task with the most failures(4):
    -----
    Task ID:
       task_1498218985196_0009_m_000002

    URL:
       http://db01:8088/taskdetails.jsp?jobid=job_1498218985196_0009&tipid=task_1498218985196_0009_m_000002
    -----
    Diagnostic Messages for this Task:
    Error: java.lang.RuntimeException: Error in configuring object
         at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109)
         at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:75)
         at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:133)
         at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:449)
         at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343)
         at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:164)
         at java.security.AccessController.doPrivileged(Native Method)
         at javax.security.auth.Subject.doAs(Subject.java:415)
         at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1912)
         at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158)
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:606)
         at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:106)
         ... 9 more
    Caused by: java.lang.RuntimeException: Error in configuring object
         at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109)
         at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:75)
         at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:133)
         at org.apache.hadoop.mapred.MapRunner.configure(MapRunner.java:38)
         ... 14 more
    Caused by: java.lang.reflect.InvocationTargetException
         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:606)
         at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:106)
         ... 17 more
    Caused by: java.lang.RuntimeException: Map operator initialization failed
         at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.configure(ExecMapper.java:147)
         ... 22 more
    Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.ClassNotFoundException: Class org.apache.hadoop.hive.contrib.serde2.RegexSerDe not found
         at org.apache.hadoop.hive.ql.exec.MapOperator.getConvertedOI(MapOperator.java:323)
         at org.apache.hadoop.hive.ql.exec.MapOperator.setChildren(MapOperator.java:333)
         at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.configure(ExecMapper.java:116)
         ... 22 more
    Caused by: java.lang.ClassNotFoundException: Class org.apache.hadoop.hive.contrib.serde2.RegexSerDe not found
         at org.apache.hadoop.conf.Configuration.getClassByName(Configuration.java:2105)
         at org.apache.hadoop.hive.ql.plan.PartitionDesc.getDeserializer(PartitionDesc.java:140)
         at org.apache.hadoop.hive.ql.exec.MapOperator.getConvertedOI(MapOperator.java:297)
         ... 24 more


    FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
    MapReduce Jobs Launched:
    Stage-Stage-1: Map: 4   HDFS Read: 0 HDFS Write: 0 FAIL
    Total MapReduce CPU Time Spent: 0 msec
    hive (default)>

    从日志看,貌似执行mr因为缺少包而导致的故障。
    解决办法:向hive命令行中添加hive-contrib-1.1.0-cdh5.9.2.jar包:

    hive (chavin)> add jar /opt/cloudera/parcels/CDH/lib/hive/lib/hive-contrib-1.1.0-cdh5.9.2.jar;
    Added [/opt/cloudera/parcels/CDH/lib/hive/lib/hive-contrib-1.1.0-cdh5.9.2.jar] to class path
    Added resources: [/opt/cloudera/parcels/CDH/lib/hive/lib/hive-contrib-1.1.0-cdh5.9.2.jar]

    再次运行加载数据命令:

    hive (chavin)>insert into chavin.nginx_access_log_comm select host,time,request,referer from chavin.nginx_access_log;
    Query ID = root_20170623203333_d244452b-9fae-4131-826a-428620219dbe
    Total jobs = 1
    Launching Job 1 out of 1
    Number of reduce tasks is set to 0 since there's no reduce operator
    Starting Job = job_1498218985196_0007, Tracking URL = http://db01:8088/proxy/application_1498218985196_0007/
    Kill Command = /opt/cloudera/parcels/CDH-5.9.2-1.cdh5.9.2.p0.3/lib/hadoop/bin/hadoop job  -kill job_1498218985196_0007
    Hadoop job information for Stage-1: number of mappers: 4; number of reducers: 0
    2017-06-23 20:33:59,442 Stage-1 map = 0%,  reduce = 0%
    2017-06-23 20:34:19,200 Stage-1 map = 13%,  reduce = 0%, Cumulative CPU 50.65 sec
    2017-06-23 20:34:20,239 Stage-1 map = 25%,  reduce = 0%, Cumulative CPU 53.72 sec
    2017-06-23 20:34:21,333 Stage-1 map = 42%,  reduce = 0%, Cumulative CPU 56.75 sec
    2017-06-23 20:34:22,368 Stage-1 map = 55%,  reduce = 0%, Cumulative CPU 62.82 sec
    2017-06-23 20:34:24,451 Stage-1 map = 63%,  reduce = 0%, Cumulative CPU 68.45 sec
    2017-06-23 20:34:28,984 Stage-1 map = 88%,  reduce = 0%, Cumulative CPU 88.58 sec
    2017-06-23 20:34:31,049 Stage-1 map = 100%,  reduce = 0%, Cumulative CPU 91.97 sec
    MapReduce Total cumulative CPU time: 1 minutes 31 seconds 970 msec
    Ended Job = job_1498218985196_0007
    Stage-4 is filtered out by condition resolver.
    Stage-3 is selected by condition resolver.
    Stage-5 is filtered out by condition resolver.
    Starting Job = job_1498218985196_0008, Tracking URL = http://db01:8088/proxy/application_1498218985196_0008/
    Kill Command = /opt/cloudera/parcels/CDH-5.9.2-1.cdh5.9.2.p0.3/lib/hadoop/bin/hadoop job  -kill job_1498218985196_0008
    Hadoop job information for Stage-3: number of mappers: 1; number of reducers: 0
    2017-06-23 20:34:38,770 Stage-3 map = 0%,  reduce = 0%
    2017-06-23 20:34:44,973 Stage-3 map = 100%,  reduce = 0%, Cumulative CPU 1.46 sec
    MapReduce Total cumulative CPU time: 1 seconds 460 msec
    Ended Job = job_1498218985196_0008
    Loading data to table chavin.nginx_access_log_comm
    Table chavin.nginx_access_log_comm stats: [numFiles=1, numRows=2538166, totalSize=6856514, rawDataSize=1598858202]
    MapReduce Jobs Launched:
    Stage-Stage-1: Map: 4   Cumulative CPU: 91.97 sec   HDFS Read: 1000717778 HDFS Write: 6859275 SUCCESS
    Stage-Stage-3: Map: 1   Cumulative CPU: 1.46 sec   HDFS Read: 6989009 HDFS Write: 6856514 SUCCESS
    Total MapReduce CPU Time Spent: 1 minutes 33 seconds 430 msec
    OK
    host    time    request    referer
    Time taken: 55.218 seconds

    问题解决,但是该解决方法只能对本次Hive会话有用,Hive使用命令exit退出后再进入依旧会出现该问题。

  • 相关阅读:
    Tomcat中实现IP访问限制
    webservice ssl双向认证配置
    如何更专业的使用Chrome开发者工具
    C++中常量成员函数的含义
    写时拷贝COW(copy-on-write)
    char* 、const char*和string之间的转换
    C++模板特化与偏特化
    lamda表达式和尾置返回类型
    编译期多态和运行时多态
    静态绑定和动态绑定
  • 原文地址:https://www.cnblogs.com/wcwen1990/p/7074298.html
Copyright © 2011-2022 走看看