执行HiveSQL出现的问题
2020-07-30 14:19:34,034 INFO [main] org.apache.hadoop.hive.ql.exec.ReduceSinkOperator: RECORDS_OUT_INTERMEDIATE:50, 2020-07-30 14:19:34,037 FATAL [main] org.apache.hadoop.mapred.YarnChild: Error running child : java.lang.OutOfMemoryError: Java heap space at org.apache.orc.impl.DynamicByteArray.get(DynamicByteArray.java:283) at org.apache.orc.impl.TreeReaderFactory$StringDictionaryTreeReader.nextVector(TreeReaderFactory.java:1584) at org.apache.orc.impl.TreeReaderFactory$StringTreeReader.nextVector(TreeReaderFactory.java:1277) at org.apache.orc.impl.TreeReaderFactory$ListTreeReader.nextVector(TreeReaderFactory.java:2001) at org.apache.orc.impl.TreeReaderFactory$StructTreeReader.nextBatch(TreeReaderFactory.java:1815) at org.apache.orc.impl.RecordReaderImpl.nextBatch(RecordReaderImpl.java:1184) at org.apache.hadoop.hive.ql.io.orc.RecordReaderImpl.ensureBatch(RecordReaderImpl.java:77) at org.apache.hadoop.hive.ql.io.orc.RecordReaderImpl.hasNext(RecordReaderImpl.java:93) at org.apache.hadoop.hive.ql.io.orc.OrcInputFormat$OrcRecordReader.next(OrcInputFormat.java:238) at org.apache.hadoop.hive.ql.io.orc.OrcInputFormat$OrcRecordReader.next(OrcInputFormat.java:213) at org.apache.hadoop.hive.ql.io.HiveContextAwareRecordReader.doNext(HiveContextAwareRecordReader.java:360) at org.apache.hadoop.hive.ql.io.CombineHiveRecordReader.doNext(CombineHiveRecordReader.java:167) at org.apache.hadoop.hive.ql.io.CombineHiveRecordReader.doNext(CombineHiveRecordReader.java:52) at org.apache.hadoop.hive.ql.io.HiveContextAwareRecordReader.next(HiveContextAwareRecordReader.java:116) at org.apache.hadoop.hive.shims.HadoopShimsSecure$CombineFileRecordReader.doNextWithExceptionHandler(HadoopShimsSecure.java:229) at org.apache.hadoop.hive.shims.HadoopShimsSecure$CombineFileRecordReader.next(HadoopShimsSecure.java:142) at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.moveToNext(MapTask.java:199) at org.apache.hadoop.mapred.MapTask$TrackedRecordReader.next(MapTask.java:185) at org.apache.hadoop.mapred.MapRunner.run(MapRunner.java:52) at org.apache.hadoop.mapred.MapTask.runOldMapper(MapTask.java:459) at org.apache.hadoop.mapred.MapTask.run(MapTask.java:343) at org.apache.hadoop.mapred.YarnChild$2.run(YarnChild.java:177) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1893) at org.apache.hadoop.mapred.YarnChild.main(YarnChild.java:171) 2020-07-30 14:19:34,049 INFO [main] org.apache.hadoop.metrics2.impl.MetricsSystemImpl: Stopping MapTask metrics system... 2020-07-30 14:19:34,050 INFO [main] org.apache.hadoop.metrics2.impl.MetricsSystemImpl: MapTask metrics system stopped. 2020-07-30 14:19:34,050 INFO [main] org.apache.hadoop.metrics2.impl.MetricsSystemImpl: MapTask metrics system shutdown complete.
这就是堆内存溢出。
看看yarn-site.xml 的配置
<property> <name>yarn.nodemanager.resource.memory-mb</name> <value>24576</value> <!-- 每个节点可用内存,配置为24G 限制了NodeManager 从本机中申请内存的上限--> </property> <property> <name>yarn.scheduler.maximum-allocation-mb</name> <value>16384</value> <!-- 单个任务最大可申请内存16G,这里只是进行了一个限制,也就是不能超过它,如果超过了会被kill--> </property> <property> <name>yarn.scheduler.minimum-allocation-mb</name> <value>2048</value> <!-- 单个任务可申请的最小内存2G,这是只是进行了一个限制,如果是map任务还需要在mapred-site.xml 再次设置 --> </property> <property> <name>yarn.nodemanager.vmem-check-enabled</name> <value>false</value> <!-- 关闭检查虚拟内存量 --> </property>
看看mapred-site.xml
<property> <name>mapreduce.map.memory.mb</name> <value>4096</value> <!-- map 任务最大内存 --> </property> <property> <name>mapreduce.reduce.memory.mb</name> <value>4096</value> <!-- reduce 任务最大内存 --> </property> <property> <name>mapred.child.java.opts</name> <value>-Xmx2048m</value> <!-- JVM 虚拟机的启动参数 --> </property>
一直没找到原因;然后就想到了是不是hive 自身的问题;
终于找到了解决方案,在执行HiveSQL 之前进行一下设置
set mapreduce.map.java.opts=-Xmx2048m; -- 然后在执行sql select * from xxx
By Ginfoo