Hello everyone,
I am in the process of configuring an Elasticsearch environment. After set up the parameters according to the documentation, I get an error message when I try to get the version, even though there is free memory at the OS level:
[root@ip-xx-xxx-xx-xx ~]# free -m (total memory: 8G, free memory: 2.8 G)
total used free shared buffers cached
Mem: 7979 5168 2810 0 66 384
-/+ buffers/cache: 4717 3261
Swap: 0 0 0
[root@ip-xx-xxx-xx-xx ~]# /usr/share/elasticsearch/bin/elasticsearch --version
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006ca660000, 4120510464, 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 4120510464 bytes for committing reserved memory.
An error report file with more information is saved as:
/root/hs_err_pid11983.log
Next my configuration:
[root@ip-xx-xxx-xx-xx ~]# uname -a (Amazon Linux):
Linux ip-xx-xxx-xx-xxx 4.14.33-51.34.amzn1.x86_64 #1 SMP Fri Apr 13 18:18:26 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
Elasticsearch version: Version: 5.6.8, Build: 688ecce/2018-02-16T16:46:30.010Z, JVM: 1.8.0_171
[root@ip-xx-xxx-xx-xx ~]# cat /usr/lib/systemd/system/elasticsearch.service.d/elasticsearch.conf
[Service]
LimitMEMLOCK=infinity
[root@ip-xx-xxx-xx-xx ~]# cat /etc/elasticsearch/jvm.options | grep Xm
-Xms4g
-Xmx4g
[root@ip-xx-xxx-xx-xx ~]# cat /etc/security/limits.d/00-defaults.conf
soft nofile 100000
hard nofile 100000
elasticsearch soft memlock unlimited
elasticsearch hard memlock unlimited
[root@ip-xx-xxx-xx-xx ~]# cat /etc/sysctl.d/00-defaults.conf
vm.swappiness=1
vm.max_map_count=262144
..
..
[root@ip-xx-xxx-xx-xx ~]# cat /etc/elasticsearch/elasticsearch.yml | grep bootstrap.memory
bootstrap.memory_lock: true
[root@ip-xx-xxx-xx-xx ~]# ps -ef | grep -i java (the service starts OK "/sbin/service elasticsearch start", however I got the error shown at the begining)
496 8328 1 2 21:56 ? 00:00:31 /usr/bin/java -Xms4g -Xmx4g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX: +UseCMSInitiatingOccupancyOnly -XX:+AlwaysPreTouch -server -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -
Djdk.io.permissionsUseCanonicalPath=true -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -
Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Dlog4j.skipJansi=true -XX:+HeapDumpOnOutOfMemoryError -Xms4g -Xmx4g -Des.path.home=/usr/share/elasticsearch -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch -p /var/run/elasticsearch/elasticsearch.pid -d -Edefault.path.logs=/var/log/elasticsearch -Edefault.path.data=/var/lib/elasticsearch -Edefault.path.conf=/etc/elasticsearch
If I try to get the Elasticsearch version with 2G (intead of 4g) for Java Heap size, I get the version smoothly:
ES_JAVA_OPTS="-Xms2g -Xmx2g" /usr/share/elasticsearch/bin/elasticsearch --version
Version: 5.6.8, Build: 688ecce/2018-02-16T16:46:30.010Z, JVM: 1.8.0_171
However, if I try with 4G (which is the actually Heap Size of the JVM), I get the error message:
ES_JAVA_OPTS="-Xms4g -Xmx4g" /usr/share/elasticsearch/bin/elasticsearch --version
OpenJDK 64-Bit Server VM warning: INFO: os::commit_memory(0x00000006ca660000, 4120510464, 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 4120510464 bytes for committing reserved memory.
An error report file with more information is saved as:
/var/log/elasticsearch/hs_err_pid18376.log
free -m
total used free shared buffers cached
Mem: 7979 5115 2863 0 58 343
-/+ buffers/cache: 4713 3265
Swap: 0 0 0
So, the question is, why I get this error, considering there is enough free memory and, more important, the Heap size configured is actually 4g (not 2g) ?
thanks in advance !