Hive failed; error=‘Cannot allocate memory‘ (errno=12)
Posted Mr.zhou_Zxy
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Hive failed; error=‘Cannot allocate memory‘ (errno=12)相关的知识,希望对你有一定的参考价值。
Hive failed; error=‘Cannot allocate memory’ (errno=12)
一、问题
[root@hadoop_zxy bin]# hive
Logging initialized using configuration in jar:file:/zxy/apps/hive-1.2.1/lib/hive-common-1.2.1.jar!/hive-log4j.properties
Java HotSpot(TM) 64-Bit Server VM warning: INFO: os::commit_memory(0x00000000fec00000, 20971520, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (mmap) failed to map 20971520 bytes for committing reserved memory.
# An error report file with more information is saved as:
# /zxy/apps/hive-1.2.1/bin/hs_err_pid24710.log
二、解决
由于报错os::commit_memory(0x00000000fec00000, 20971520, 0),但是经检查内存充足
于是判断是系统内存分配策略的问题,做以下修改
[root@hadoop_zxy bin]# vim /etc/sysctl.conf
修改前
修改后
[root@hadoop_zxy bin]# sysctl -p
kernel.sem = 250 64000 100 512
kernel.shmmax = 500000000
kernel.shmmni = 4096
kernel.shmall = 4000000000
kernel.sysrq = 1
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
net.ipv4.tcp_syncookies = 1
net.ipv4.ip_forward = 0
net.ipv4.conf.default.accept_source_route = 0
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_max_syn_backlog = 4096
net.ipv4.conf.all.arp_filter = 1
net.ipv4.conf.default.arp_filter = 1
net.core.netdev_max_backlog = 10000
vm.overcommit_memory = 1
vm.max_map_count = 262144
三、测试
[root@hadoop_zxy bin]# hive --service hiveserver2 &
[1] 583
[root@hadoop_zxy bin]# hive --service metastore &
[2] 818
四、拓展
vm.overcommit_memory配置
linux系统会对大部分的申请都回复yes,以便于运行更多的程序。但是有些程序申请完内存后并不一定会立马使用,这就叫做overcommit。
而通过vm.overcommit_memory的配置就可以控制overcommit的内存分配策略,主要分为以下三种:
0:内核首先会检查是否有足够的内存分配,如果没有就反馈申请失败,也就是cannot allocate memory的出现
1:内核允许超量使用内存直到内存用完为止
2:表示内核绝不允许超量使用内存,即系统的内存空间不能超过swap+50%的RAM值,50%是overcommit_ratio的默认值,该参数支持修改
以上是关于Hive failed; error=‘Cannot allocate memory‘ (errno=12)的主要内容,如果未能解决你的问题,请参考以下文章
启动hive报错[ERROR] Terminal initialization failed; falling back to unsupported
DataGrip 连接 Kerberos 认证的 hive 报 Hive JDBC Kerberose Authentication Error: GSS initiate failed 错误
编译语句时出错:FAILED: SemanticException [Error 10002] - MAKE SELECT WITH MAX ON HIVE
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask
FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.mr.MapRedTask
hive 错误 FAILED: SemanticException [Error 10041]: No partition predicate found for