在運作一個group by的sql時,抛出以下錯誤資訊:
Task with the most failures(4):
-----
Task ID:
task_201411191723_723592_m_000004
URL:
http://DDS0204.dratio:50030/taskdetails.jsp?jobid=job_201411191723_723592&tipid=task_201411191723_723592_m_000004
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.25. Try setting it to a lower value. i.e 'set hive.map.aggr.hash.percentmemory = 0.125;'
Diagnostic Messages for this Task:
FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
MapReduce Jobs Launched:
Job 0: Map: 12 Reduce: 1 Cumulative CPU: 164.04 sec HDFS Read: 0 HDFS Write: 0 FAIL
Total MapReduce CPU Time Spent: 2 minutes 44 seconds 40 msec
原因是在map端進行了聚合,超過hash map的大小
終極解決辦法:set hive.map.aggr=false 或者更改為子sql 或者嘗試更改以下參數
備注:
與mapjoin和map aggregate相關的優化參數有:
①.hive.map.aggr 是否關閉關掉map端的aggregation,sethive.map.aggr=false就關閉map端的聚合了
②.hive.map.aggr.hash.min.reduction如果記憶體Map超過一定大小,就關閉MapAggregation功能,比如set hive.map.aggr.hash.min.reduction=0.5;
③.hive.map.aggr.hash.percentmemory
當記憶體的Map大小,占到jsm配置的Map程序的25%(設定sethive.map.aggr.hash.percentmemory = 0.25)的時候(預設是50%),就将這個資料flush到reducer去,以釋放記憶體Map的空間。
④.hive.groupby.skewindata資料據傾斜的時候進行負載均衡,當hive.groupby.skewindata=true,生成的查詢計劃會有兩個 mr job。第一個mr中,每個map的輸出結果集合會随機分布到reduce中,reduce做部分聚合操作。第二個mr再根據上個mr的資料結果按照group by key分布到 reduce中完成最終的聚合操作。
參考:
http://dev.bizo.com/2013/02/map-side-aggregations-in-apache-hive.html