您好,登錄后才能下訂單哦!
這篇文章主要為大家展示了“hive關聯查詢連接hbase的外部表時如何解決內存溢出問題”,內容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“hive關聯查詢連接hbase的外部表時如何解決內存溢出問題”這篇文章吧。
計劃把數據都保存到hbase中,而查詢統計數據使用hive。在把數據灌入hbase中后,發現兩個外部表的數據大概在200萬和300萬左右,join查詢后報錯,內存溢出。錯誤如下方
感覺不會呀,對于hadoop來說,這么點數據不至于吧。上網查了很多資料未果。今天終于找到一個靠譜的,見鏈接http://itindex.net/detail/51977-hive-hbase-%E5%A4%96%E9%83%A8
“默認情況下,Hive會自動將小表加到DistributeCache中,然后在Map掃描大表的時候,去和DistributeCache中的小表做join,這稱為Mapjoin。”
這里意思是,因為查詢的表是連接hbase后的外部表,所以在hive的存儲目錄中是空的目錄,數據文件大小是0,所以hive將之視為小數據表,會把它加載到DistributeCache并進行mapjoin。但實際上數據量是很大的,結果就內存溢出了。
解決方法:
在hive中執行以下命令:
SET mapred.job.queue.name=queue3; SET hbase.client.scanner.caching=10000; SET hbase.zookeeper.quorum=node1,node2,node3,node4,node5; SET zookeeper.znode.parent=/hbase; SET hbase.regionserver.lease.period=180000; SET hive.auto.convert.join=false; SET hive.ignore.mapjoin.hint=false;
其中SET mapred.job.queue.name=queue3;是設置一個queue隊列,我的hadoop沒有配置隊列,我也不太熟,直接改為SET mapred.job.queue.name=default;(貌似不執行就是default吧)
SET hbase.client.scanner.caching=10000;是設置hbase每次所描數據的記錄個數,默認是1的,改了會有較大性能提升。
SET hbase.zookeeper.quorum=node1,node2,node3,node4,node5;設置zookeeper
SET zookeeper.znode.parent=/hbase;這個還不知道
set hbase.regionserver.lease.period=180000; 這個也不清楚
SET hive.auto.convert.join=false;關閉自動轉化MapJoin,默認為true;
SET hive.ignore.mapjoin.hint=false;關閉忽略mapjoin的hints(不忽略,hints有效),默認為true(忽略hints)。
hive的sql執行后,內存溢出的日志信息如下:
Query ID = hadoop_20150826162508_4c06d5ea-0f33-485d-8e0d-904dc67f51b1 Total jobs = 1 Execution log at: /tmp/hadoop/hadoop_20150826162508_4c06d5ea-0f33-485d-8e0d-904dc67f51b1.log 2015-08-26 16:25:17 Starting to launch local task to process map join; maximum memory = 477102080 2015-08-26 16:27:09 Dump the side-table for tag: 1 with group count: 60765 into file: file:/tmp/c84b84b9-452b-46cd-b90d-45a628385803/hive_2015-08-26_16-25-08_004_3456412479615750499-1/-local-10003/HashTable-Stage-2/MapJoin-mapfile01--.hashtable 2015-08-26 16:27:11 Uploaded 1 File to: file:/tmp/c84b84b9-452b-46cd-b90d-45a628385803/hive_2015-08-26_16-25-08_004_3456412479615750499-1/-local-10003/HashTable-Stage-2/MapJoin-mapfile01--.hashtable (19315960 bytes) 2015-08-26 16:27:11 End of local task; Time Taken: 114.62 sec. Execution completed successfully MapredLocal task succeeded Launching Job 1 out of 1 Number of reduce tasks not specified. Estimated from input data size: 1 In order to change the average load for a reducer (in bytes): set hive.exec.reducers.bytes.per.reducer=<number> In order to limit the maximum number of reducers: set hive.exec.reducers.max=<number> In order to set a constant number of reducers: set mapreduce.job.reduces=<number> Starting Job = job_1440161019277_0326, Tracking URL = http://db2:8088/proxy/application_1440161019277_0326/ Kill Command = /data/hadoop/bin/hadoop job -kill job_1440161019277_0326 Hadoop job information for Stage-2: number of mappers: 2; number of reducers: 1 2015-08-26 16:27:32,336 Stage-2 map = 0%, reduce = 0% 2015-08-26 16:28:32,735 Stage-2 map = 0%, reduce = 0% 2015-08-26 16:29:32,789 Stage-2 map = 0%, reduce = 0% 2015-08-26 16:30:33,082 Stage-2 map = 0%, reduce = 0% 2015-08-26 16:31:33,823 Stage-2 map = 0%, reduce = 0% 2015-08-26 16:32:34,188 Stage-2 map = 0%, reduce = 0% 2015-08-26 16:33:34,868 Stage-2 map = 0%, reduce = 0% 2015-08-26 16:33:54,390 Stage-2 map = 100%, reduce = 100% Ended Job = job_1440161019277_0326 with errors Error during job, obtaining debugging information... Job Tracking URL: http://db2:8088/proxy/application_1440161019277_0326/ Examining task ID: task_1440161019277_0326_m_000000 (and more) from job job_1440161019277_0326 Task with the most failures(4): ----- Task ID: task_1440161019277_0326_m_000000 URL: http://db2:8088/taskdetails.jsp?jobid=job_1440161019277_0326&tipid=task_1440161019277_0326_m_000000 ----- Diagnostic Messages for this Task: Error: java.lang.RuntimeException: Error in configuring object at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:112) at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:78) at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:136) at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:449) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:163) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Unknown Source) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1657) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:158) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109) ... 9 more Caused by: java.lang.RuntimeException: Error in configuring object at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:112) at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:78) at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:136) at org.apache.hadoop.mapred.MapRunner.configure(MapRunner.java:38) ... 14 more Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109) ... 17 more Caused by: java.lang.OutOfMemoryError: Java heap space at org.apache.hadoop.hive.serde2.objectinspector.primitive.WritableIntObjectInspector.copyObject(WritableIntObjectInspector.java:41) at org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.copyToStandardObject(ObjectInspectorUtils.java:311) at org.apache.hadoop.hive.serde2.objectinspector.ObjectInspectorUtils.copyToStandardObject(ObjectInspectorUtils.java:346) at org.apache.hadoop.hive.ql.exec.persistence.MapJoinEagerRowContainer.read(MapJoinEagerRowContainer.java:138) at org.apache.hadoop.hive.ql.exec.persistence.MapJoinEagerRowContainer.read(MapJoinEagerRowContainer.java:131) at org.apache.hadoop.hive.ql.exec.persistence.MapJoinTableContainerSerDe.load(MapJoinTableContainerSerDe.java:85) at org.apache.hadoop.hive.ql.exec.mr.HashTableLoader.load(HashTableLoader.java:98) at org.apache.hadoop.hive.ql.exec.MapJoinOperator.loadHashTable(MapJoinOperator.java:288) at org.apache.hadoop.hive.ql.exec.MapJoinOperator$1.call(MapJoinOperator.java:173) at org.apache.hadoop.hive.ql.exec.MapJoinOperator$1.call(MapJoinOperator.java:169) at org.apache.hadoop.hive.ql.exec.mr.ObjectCache.retrieve(ObjectCache.java:55) at org.apache.hadoop.hive.ql.exec.mr.ObjectCache.retrieveAsync(ObjectCache.java:63) at org.apache.hadoop.hive.ql.exec.MapJoinOperator.initializeOp(MapJoinOperator.java:166) at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:362) at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:481) at org.apache.hadoop.hive.ql.exec.Operator.initializeChildren(Operator.java:438) at org.apache.hadoop.hive.ql.exec.Operator.initialize(Operator.java:375) at org.apache.hadoop.hive.ql.exec.mr.ExecMapper.configure(ExecMapper.java:131) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109) at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:78) at org.apache.hadoop.util.ReflectionUtils.newInstance(ReflectionUtils.java:136) at org.apache.hadoop.mapred.MapRunner.configure(MapRunner.java:38) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.hadoop.util.ReflectionUtils.setJobConf(ReflectionUtils.java:109) at org.apache.hadoop.util.ReflectionUtils.setConf(ReflectionUtils.java:78) Container killed by the ApplicationMaster. Container killed on request. Exit code is 143 Container exited with a non-zero exit code 143 FAILED: Execution Error, return code 2 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask MapReduce Jobs Launched: Stage-Stage-2: Map: 2 Reduce: 1 HDFS Read: 0 HDFS Write: 0 FAIL Total MapReduce CPU Time Spent: 0 msec
以上是“hive關聯查詢連接hbase的外部表時如何解決內存溢出問題”這篇文章的所有內容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內容對大家有所幫助,如果還想學習更多知識,歡迎關注億速云行業資訊頻道!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。