什么时候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;

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

Hive ERROR: Out of memory due to hash maps used in map-side aggregation的更多相关文章

  1. Out of memory due to hash maps used in map-side aggregation解决办法

    在运行一个group by的sql时,抛出以下错误信息: Task with the most failures(4): -----Task ID:  task_201411191723_723592 ...

  2. 黄聪:wordpress中PHP运行错最有效解决办法Fatal error: Out of memory (allocated 6029312)(转)

    近日在升级wordpress 3.2.1和若干插件的过程中,发现了一个wordpress的错误:Allowed memory size of XXX bytes exhausted Fatal err ...

  3. PHP运行错最有效解决办法Fatal error: Out of memory (allocated 786432) (tried to allocate 98304 bytes) in H:\freehost\zhengbao2\web\includes\lib_common.php on line 744

    原文 PHP运行错最有效解决办法Fatal error: Out of memory (allocated 6029312) Fatal error: Out of memory (allocated ...

  4. Tomcat7 JDK8 Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x0000000540000000, 5368709120, 0) failed; error='Cannot allocate memory' (errno=12)

    [root@crm-web- bin]# shutdown.sh bash: shutdown.sh: command not found [root@crm-web- bin]# sh shutdo ...

  5. android stdio 编译项目报Error:Failed to find target with hash string 'android-24

    android stdio 编译项目报Error:Failed to find target with hash string 'android-24 查看已有的SDK 设置项目的sdk为 25 an ...

  6. wp8.1 sqlite Error - Deployment optimization failed due to an assembly that's not valid.

    这里我们使用的sqlite的版本为3.8.5,vs2013在发布的时候出现 Error - Deployment optimization failed due to an assembly that ...

  7. Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000fa980000, 59244544, 0) failed; error='Cannot allocate memory' (errno=12)

    启动项目报错 Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000fa980000, 592445 ...

  8. Fatal Error: Out of memory php内存溢出处理三种方法

    有时候我们在运行php程序的时候会发现 Fatal Error: Out of memory 这样的提示,这有可能是程序中用到了大量了变量和对象,导致分配的内存不够用. 修改php.ini文件里的me ...

  9. OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000c0000000, 1073741824, 0) failed; error='Out of memory' (errno=12)

    使用docker 安装kafka时启动失败 查看报错日志 # docker logs --since 30m 71846a96e514 Excluding KAFKA_HOME from broker ...

随机推荐

  1. 如何解决ORA-12547: TNS:lost contact错

    执行环境:ubuntu+oracle 11.2.0 为了启动oracle时间,出现ORA-12547: TNS:lost contact错误. 中午好好的纳,下午就无论了.以为是链接失效,关机重新启动 ...

  2. A Game of Thrones(18) - Catelyn

    “We will make King’s Landing within the hour.” Catelyn turned away from the rail and forced herself ...

  3. hdu 4291 A Short problem(矩阵+取模循环节)

    A Short problem                                                          Time Limit: 2000/1000 MS (J ...

  4. struts2文件上传限制大小问题

    struts2默认文件上传大小为2M,如需改动默认大小,解决方法例如以下: <struts> <constant name="struts.multipart.maxSiz ...

  5. VS Code开发调试.NET Core

    使用VS Code开发 调试.NET Core 应用程序   使用VS Code开发 调试.NET Core RC2应用程序,由于.NET Core 目前还处于预览版. 本文使用微软提供的示例进行开发 ...

  6. 不知道的JavaScript

    你不知道的JavaScript上卷笔记 前言 You don't know JavaScript是github上一个系列文章  初看到这一标题的时候,感觉怎么老外也搞标题党,用这种冲突性比较强的题目吸 ...

  7. C# Dictionary.Add(key,value) 与 Dictionary[key]=value的区别

    1. MSDN上的描述. http://msdn.microsoft.com/zh-cn/library/9tee9ht2(v=VS.85).aspx 通过设置 Dictionary 中不存在的键值, ...

  8. poj1947(树形dp)

    题目链接:http://poj.org/problem?id=1947 题意:给n(n<=150)个点的一棵树,求删掉最少边数k使得最后该树只剩下p(1<=p<=n)个节点.(求最小 ...

  9. js实现页面重定位的几种方法

    参考地址:http://www.cnblogs.com/super-d2/archive/2011/10/01/2197004.html js实现页面重定向 在现行的网站应用中URL重定向的应用有很多 ...

  10. SWT的TableVierer的使用二(数据排序)

    有一个功能是我们常使用的,就是在列的头上点击一下,整个表的记录按照这个列来排序,再点击一下按照这个列的反序来排序.那JFace是如何实现这个功能的呢?在JFace中是通过一个排序器来实现的,就是Vie ...