ES_JAVA_OPTS are not cosidered

#1

Hello community,

I run on the following problem. I don’t want to use docker-compose and use the Ansible docker_manage module instead to manage containers.

When I run the Elastcsearch container with Anisble or the “docker run” command and with ES_JAVA_OPTS they are not considered.

Example:
sudo docker run -e ES_JAVA_OPTS=’-Xms4g -Xmx4g’ -p 9200:9200 -p 9600:9600 -v /srv:/usr/share/elasticsearch/data -v /usr/share/ca-certificates/ca.pem:/usr/share/elasticsearch/config/ca.pem -v /usr/share/ca-certificates/test.crt:/usr/share/elasticsearch/config/test.crt -v /usr/share/ca-certificates/test.key:/usr/share/elasticsearch/config/test.key -v /etc/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml --network host --ulimit memlock=-1:-1 amazon/opendistro-for-elasticsearch

Output (from inside container):
ps -ef|grep elastic
elastic+ 1 0 99 08:27 ? 00:00:41 /opt/jdk-11.0.1/bin/java -Xms1g -Xmx1g -XX:+UseConcMarkSweepGC -XX:CMSInitiatingOccupancyFraction=75 -XX:+UseCMSInitiatingOccupancyOnly -Des.networkaddress.cache.ttl=60 -Des.networkaddress.cache.negative.ttl=10 -XX:+AlwaysPreTouch -Xss1m -Djava.awt.headless=true -Dfile.encoding=UTF-8 -Djna.nosys=true -XX:-OmitStackTraceInFastThrow -Dio.netty.noUnsafe=true -Dio.netty.noKeySetOptimization=true -Dio.netty.recycler.maxCapacityPerThread=0 -Dlog4j.shutdownHookEnabled=false -Dlog4j2.disable.jmx=true -Djava.io.tmpdir=/tmp/elasticsearch-15046601552492541201 -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=data -XX:ErrorFile=logs/hs_err_pid%p.log -Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m -Djava.locale.providers=COMPAT -XX:UseAVX=2 -Djava.security.policy=file:///usr/share/elasticsearch/plugins/opendistro_performance_analyzer/pa_config/es_security.policy -Dclk.tck=100 -Djdk.attach.allowAttachSelf=true -Des.cgroups.hierarchy.override=/ -Xms4g -Xmx4g -Des.path.home=/usr/share/elasticsearch -Des.path.conf=/usr/share/elasticsearch/config -Des.distribution.flavor=oss -Des.distribution.type=tar -cp /usr/share/elasticsearch/lib/* org.elasticsearch.bootstrap.Elasticsearch

echo $ES_JAVA_OPTS
-Xms4g -Xmx4g

Only Java parameter
-Des.cgroups.hierarchy.override=/ -Xms4g -Xmx4g
is set to ES_JAVA_OPTS value.

But I assume that’s not what should be set. Please correct me if I’ wrong.

Has anybody an idea?

Thanks in advance!

Martin

#2

Hello!

Found a workaround meanwhile:
I replaced the /user/share/elasticsearch/config/jvm.options file and changed the heap settings in this file.

But it would be much better if the heap size can be passed as argument.

#3

Hi @Martin !

Setting heap size param via argument is working fine. There are a lot of questions about how it param works :slight_smile: I agree that it can be a little bit confusing

For advance. To check actual heap size limit I recommend you to check it through ES API

curl localhost:9200/_nodes/your_node_name/jvm
And you can notice that Xms and Xmx have correct values

#4

Hi @prizov!

Thank you very much. Indeed … it’s confusing. But good, that it works!

Greetings,

Martin