Elasticsearch ignores my JVM heap size settings
Asked Answered
W

3

6

I am running Elasticsearch inside a Docker container in Linux (Ubuntu). I am having a lot of circuit_breaking_exception problems, citing a 486.3mb limit; so I've decided to raise my JVM heap size a bit. My machine has 6 GB physical memory, so up to 3 GB should be safe for the heap size.

So I've gone to change the setting in jvm.options. The default is:

-Xms1g 
-Xmx1g

And I've changed it to:

-Xms2g 
-Xmx2g

And here comes the twist: not only I keep getting the same circuit_breaking_exception with the same size limit; echo $ES_JAVA_OPTS returns -Xmx512m -Xms512m. This is not even the default setting. I've also tried leaving the default jvm.options and creating a new user.options inside jvm.options.d, with the same result. Am I missing something? Am I doing anything wrong here?

Washrag answered 6/10, 2020 at 8:35 Comment(1)
Hi, can you add how you are running elasticsearch as in if you can share the Dockerfile if you are building your own image or using the official image. For the official image I am able to pass - "ES_JAVA_OPTS=-Xms2g -Xmx2g" as the environment variable and able to increase heap size.Py
M
12

As shown in the official installation of ES using docker, you can pass it as env variable

version: '2.2'
services:
  es01:
    image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
    container_name: es01
    environment: -> it comes under environment section, removed other settings for brevity
      - "ES_JAVA_OPTS=-Xms512m -Xmx512m" --> note this
    

You need to restart the docker container after changing this ES_JAVA_OPTS env variable value

Mammillary answered 6/10, 2020 at 8:58 Comment(4)
Aww, it looks like I was doing just this. I'm modifying my docker-compose.yml and see what happens. Thanks a lot for the tip.Washrag
@Washrag glad you found it useful, please don'r forget to upvote and accept the answer :DMammillary
I was just checking that it worked, and it did. Thanks a lot again.Washrag
I'm trying to do this with -XX:-MaxFDLimit or -XX:+MaxFDLimit instead of heap size and it isn't working.Soper
E
5

You can pass this setting to container using env var ES_JAVA_OPTS.

docker run -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e "ES_JAVA_OPTS=-Xms2g -Xmx2g" docker.elastic.co/elasticsearch/elasticsearch:7.9.2
Esdraelon answered 6/10, 2020 at 8:48 Comment(1)
This would create a new container, wouldn't it? I'd like to modifiy the current one.Washrag
D
0

According to the documentation, in a docker environment, you have to set it in the docker-compose.yml

https://www.elastic.co/guide/en/elasticsearch/reference/current/docker.html#docker-compose-file

Downstairs answered 6/10, 2020 at 8:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.