In Elasticsearch 5.x running as a service, how do I set the memory (heap) size?
The environment variables
ES_MIN_MEM ES_MAX_MEM ES_HEAP_SIZE
are not being read or taken into account when Elasticsearch is started as a service through Systemd on Debian-based distros (Ubuntu, Mint, etc) using
sudo service elasticsearch start
In ElasticSearch 5.x, after October 26, 2016 the old methods to set memory size do not work anymore.
For example: after changing ES_HEAP_SIZE in /etc/default/elasticsearch and in etc/init.d/elasticsearch, if you run
ps aux | grep elasticsearch
you will still get
/usr/bin/java -Xms2g -Xmx2g
Meaning 2G min and 2G max RAM
You have to make the changes in
/etc/elasticsearch/jvm.options
Xms
represents the initial size of total heap spaceXmx
represents the maximum size of total heap space
so change them according to your needs, for example:
-Xms16g
-Xmx16g
Documentation on deciding the right size (still showing the old variable and file names at the time of writing)
the default setting in Elasticsearch 5 are -Xms2g -Xmx2g
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With