gouchaoer
V2EX  ›  Java

往 hive 里批量插数据如果大于了 10M 左右就会出错

  •  
  •   gouchaoer · Jul 18, 2017 · 5189 views
    This topic created in 3223 days ago, the information mentioned may be changed or developed.

    现在需要把 mysql 里面的数据进行一些脱敏处理,然后往 hive 里面插,我用的 hiveserver2 作为服务器端,然后用客户端通过 thrift 去连接 hiveserver2 来插数据的。

    由于一次 mapreduce 耗时很长,所以我尽可能一次插很多的数据进去,也就是用的 INSERT INTO table VALUES...这个语法。现在问题来了就是如果插得数据大于 10M 的话就会出错,客户端提示的错误就是:

    Hive ERROR_STATE Error Message: Error while processing statement: FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask

    去找出 yarn 的 log 就是这样:

    2017-07-18 11:35:54,832 WARN org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor: Exit code from container container_1499276494511_0407_01_000005 is : 255 2017-07-18 11:35:54,832 WARN org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor: Exception from container-launch with container ID: container_1499276494511_0407_01_000005 and exit code: 255 ExitCodeException exitCode=255: at org.apache.hadoop.util.Shell.runCommand(Shell.java:538) at org.apache.hadoop.util.Shell.run(Shell.java:455) at org.apache.hadoop.util.Shell$ShellCommandExecutor.execute(Shell.java:715) at org.apache.hadoop.yarn.server.nodemanager.DefaultContainerExecutor.launchContainer(DefaultContainerExecutor.java:212) at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:302) at org.apache.hadoop.yarn.server.nodemanager.containermanager.launcher.ContainerLaunch.call(ContainerLaunch.java:82) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)

    可以看到 2 个提示都不是有价值的信息,目前已经排除了 jvm 的 stack 或者 heap 不足了,因为之前遇到过 heap 不足抛出 OutOfMemory 异常,增加-Xmx 后问题就解决了。

    我搜遍了互联网都找不到答案,求 hvie 大神帮忙看看

    6 replies    2017-07-19 10:58:09 +08:00
    cye3s
        1
    cye3s  
       Jul 18, 2017 via Android
    直接 load data 到一张表,再插入另一张表报错么?
    tttwww18
        2
    tttwww18  
       Jul 18, 2017
    信息量有点少。看 hive log 里面能找到啥线索不?
    Comdex
        4
    Comdex  
       Jul 18, 2017
    把 map 和 reduce 的内存设大点试试
    tomatoz
        5
    tomatoz  
       Jul 19, 2017
    你这是 nodemanager 的日志,应该去 application 日志里去找
    yarn logs -applicationId XXX
    另外'10M'这个数也有点微妙,因为 hadoop 默认的 job.split.metainfo 最大值恰好是 10M(全称是 mapreduce.job.split.metainfo.maxsize)
    但是 metainfo 的长度应该和插入数据量没关系呀。可能我想多了。。
    gouchaoer
        6
    gouchaoer  
    OP
       Jul 19, 2017
    @tomatoz 现在改变方案了,似乎通用的做法是把数据按格式导入一个 txt 文件,然后在使用 hive 的 load data 命令来导入比较好。。。insert into 每一次都是一次 mapred,消耗太大了
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   980 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 18:57 · PVG 02:57 · LAX 11:57 · JFK 14:57
    ♥ Do have faith in what you're doing.