How to change Elasticsearch max memory size Ask Question

How to change Elasticsearch max memory size Ask Question

I have an Apache server with a default configuration of Elasticsearch and everything works perfectly, except that the default configuration has a max size of 1GB.

I don't have such a large number of documents to store in Elasticsearch, so I want to reduce the memory.

I have seen that I have to change the -Xmx parameter in the Java configuration, but I don't know how.

I have seen I can execute this:

bin/ElasticSearch -Xmx=2G -Xms=2G

But when I have to restart Elasticsearch this will be lost.

Is it possible to change max memory usage when Elasticsearch is installed as a service?

ベストアンサー1

In ElasticSearch >= 5 the documentation has changed, which means none of the above answers worked for me.

I tried changing ES_HEAP_SIZE in /etc/default/elasticsearch and in /etc/init.d/elasticsearch, but when I ran ps aux | grep elasticsearch the output still showed:

/usr/bin/java -Xms2g -Xmx2g # aka 2G min and max ram

I had to make these changes in:

/etc/elasticsearch/jvm.options

# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space

-Xms1g 
-Xmx1g 
# the settings shipped with ES 5 were: -Xms2g
# the settings shipped with ES 5 were: -Xmx2g

おすすめ記事