zoukankan      html  css  js  c++  java
  • Hive ERROR: Out of memory due to hash maps used in map-side aggregation

    什么时候hive在运行大数据量的统计查询语句时。常常会出现以下OOM错误。详细错误提演示样例如以下:

    Possible error: Out of memory due to hash maps used in map-side aggregation.
    
    Solution: Currently hive.map.aggr.hash.percentmemory is set to 0.5. Try setting it to a lower value. i.e 'set hive.map.aggr.hash.percentmemory = 0.25;'

    查看task的失败信息为:

    Error:GC overhead limit exceeded

    对于这个错误,一般是由两种情况造成的:(1) hive sql写的不合理,导致运行时hash map过大;(2)hive sql没有优化的余地了(要得到想要的数据仅仅能写这种sql)。

    对于(1)则改变sql语句,从而减少hash map的大小。对于(2)则能够调整參数。

    以下分别说明(1)和(2)的情况:

    (1)改变sql语句

    select count(distinct v) from tbl;
    能够改为select count(1) from (select v from tbl group by v) t;

    说明:降低了hash map的key个数 

    select collect_set(messageDate)[0],count(*) from incidents_hive group by substr(messageDate,8,2);
    能够改为select hourNum, count(1) from (select substr(messageDate,9,2) as hourNum from incidents_hive ) t group by hourNum;

    说明:没有降低hash map的key个数。可是降低了value的大小

    (2)调整參数

    对于这个sql语句。是没办法进行优化(由于keywords的反复率非常低。导致map阶段里面维护的一个内存Map对象非常巨大)来减少hash map大小的:

    INSERT OVERWRITE TABLE hbase_table_poi_keywords_count SELECT concat(substr(key,0,8), svccode, keywords), substr(key,0,8), svccode, keywords, count(*) where substr(key,0,8)="$yesterday" AND length(keywords)>0 AND svccode is not null GROUP BY substr(key,0,8),svccode,keywords;

    与mapjoin和map aggregate相关的优化參数有:

    hive.map.aggr

    hive.groupby.mapaggr.checkinterval

    hive.map.aggr.hash.min.reduction

    hive.map.aggr.hash.percentmemory

    hive.groupby.skewindata

    以上參数能够查看配置文件说明即文档进行调整。

    假设需求确实没法通过调整这些參数来达到,那么set hive.map.aggr=false便是终于的方案,它肯定能满足你需求。仅仅是运行速度比map join 和 map aggr慢些,但通过实际跑数据你非常可能发现事实上它也不慢哈。

    參考文章:

    http://blog.csdn.net/macyang/article/details/9260777
    http://www.myexception.cn/open-source/1487747.html
    http://blog.csdn.net/lixucpf/article/details/20458617


    INSERT OVERWRITE TABLE hbase_table_poi_keywords_count SELECT concat(substr(key,0,8), svccode, keywords), substr(key,0,8), svccode, keywords, count(*) where substr(key,0,8)="$yesterday" AND length(keywords)>0 AND svccode is not null GROUP BY substr(key,0,8),svccode,keywords;

    版权声明:本文博主原创文章,博客,未经同意不得转载。

  • 相关阅读:
    python之路3-元组、列表、字典、集合
    python之路2-字符串操作
    Python之路1-变量、数据类型、循环语法
    config模块
    os模块
    logging模块
    控制台报错定位问题所在
    time模块
    random模块
    列表生成
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4890317.html
Copyright © 2011-2022 走看看