Home > Enterprise >  Limiting Elasticsearch heap memory size with environment variables
Limiting Elasticsearch heap memory size with environment variables

Time:11-17

I'm trying to limit Elasticsearch JVM heap size.

I have a custom docker image (just added some plugins) and to start it up, I'm using this following line:

docker run --name elastic-search -d -p 9200:9200 -p 9300:9300 --env-file=elastic-docker.properties build-server/my-elastic:latest

docker.properties file looks like this:

discovery.type=single-node
bootstrap.memory_lock=true
xpack.security.enabled=true
ELASTIC_USERNAME=elastic
ELASTIC_PASSWORD=changeme
ES_JAVA_OPTS="-Xms2g -Xmx2g"

But setting ES_JAVA_OPTS as such gets me Error: Could not find or load main class "-Xms2g. I tried with combinations of ES_JAVA_OPTS=".bin/my-elastic -Xms2g -Xmx2g", but did not manage to get anywhere.

Any help is appreciated, I would really prefer to do this through environment options.

CodePudding user response:

Seems like quotation marks were at fault here. It should actually be listed as ES_JAVA_OPTS=-Xms2g -Xmx2g in environment file.

  • Related