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;

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







本文转自mfrbuaa博客园博客,原文链接:http://www.cnblogs.com/mfrbuaa/p/4890317.html,如需转载请自行联系原作者


相关文章
|
7月前
Elasticsearch【问题记录 02】【不能以root运行es + max virtual memory areas vm.max_map_count [65530] is too low处理】
【4月更文挑战第12天】Elasticsearch【问题记录 02】【不能以root运行es + max virtual memory areas vm.max_map_count [65530] is too low处理】
71 3
|
7月前
|
前端开发
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
47 0
|
7月前
|
SQL 存储 Java
Hive 特殊的数据类型 Array、Map、Struct
在Hive中,`Array`、`Map`和`Struct`是三种特殊的数据类型。`Array`用于存储相同类型的列表,如`select array(1, "1", 2, 3, 4, 5)`会产生一个整数数组。`Map`是键值对集合,键值类型需一致,如`select map(1, 2, 3, "4")`会产生一个整数到整数的映射。`Struct`表示结构体,有固定数量和类型的字段,如`select struct(1, 2, 3, 4)`创建一个无名结构体。这些类型支持嵌套使用,允许更复杂的结构数据存储。例如,可以创建一个包含用户结构体的数组来存储多用户信息
669 0
|
存储 SQL HIVE
数据仓库的Hive的数据类型的复杂数据类型的map
在数据仓库领域,Hive是一个常用的工具。它提供了一种简单的方式来查询和分析大量数据。
196 0
|
Web App开发 JavaScript 前端开发
解决DevTools failed to load SourceMap Could not load content for .js.map HTTP error code 404 问题
解决DevTools failed to load SourceMap Could not load content for .js.map HTTP error code 404 问题
917 0
|
SQL Oracle 关系型数据库
Hive:Error while compiling statement: FAILED: ParseException cannot recognize input near '<EOF>' '<
Hive:Error while compiling statement: FAILED: ParseException cannot recognize input near '<EOF>' '<
Hive:Error while compiling statement: FAILED: ParseException cannot recognize input near '<EOF>' '<
|
7月前
|
SQL 分布式计算 资源调度
[已解决]FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask. Unable to
[已解决]FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.MoveTask. Unable to
352 0
|
SQL HIVE Python
Window10 pyhive连接hive报错:Could not start SASL: b‘Error in sasl_client_start (-4) SASL(-4)
Window10 pyhive连接hive报错:Could not start SASL: b‘Error in sasl_client_start (-4) SASL(-4)
681 0
Window10 pyhive连接hive报错:Could not start SASL: b‘Error in sasl_client_start (-4) SASL(-4)
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
DevTools failed to load source map: Could not load content for…System error: net::ERR_FILE_NOT_FOUN
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
188 0