How to change Elasticsearch max memory size

后端 未结 11 729
时光取名叫无心
时光取名叫无心 2020-11-30 16:57

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

相关标签:
11条回答
  • 2020-11-30 17:56

    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
    
    0 讨论(0)
  • 2020-11-30 17:59

    For anyone looking to do this on Centos 7 or with another system running SystemD, you change it in

    /etc/sysconfig/elasticsearch 
    

    Uncomment the ES_HEAP_SIZE line, and set a value, eg:

    # Heap Size (defaults to 256m min, 1g max)
    ES_HEAP_SIZE=16g
    

    (Ignore the comment about 1g max - that's the default)

    0 讨论(0)
  • 2020-11-30 17:59

    In elasticsearch 2.x :

    vi /etc/sysconfig/elasticsearch 
    

    Go to the block of code

    # Heap size defaults to 256m min, 1g max
    # Set ES_HEAP_SIZE to 50% of available RAM, but no more than 31g
    #ES_HEAP_SIZE=2g
    

    Uncomment last line like

    ES_HEAP_SIZE=2g
    
    0 讨论(0)
  • 2020-11-30 18:00
    • Elasticsearch will assign the entire heap specified in jvm.options via the Xms (minimum heap size) and Xmx (maximum heap size) settings.
      • -Xmx12g
      • -Xmx12g
    • Set the minimum heap size (Xms) and maximum heap size (Xmx) to be equal to each other.
    • Don’t set Xmx to above the cutoff that the JVM uses for compressed object pointers (compressed oops), the exact cutoff varies but is near 32 GB.

    • It is also possible to set the heap size via an environment variable

      • ES_JAVA_OPTS="-Xms2g -Xmx2g" ./bin/elasticsearch
      • ES_JAVA_OPTS="-Xms4000m -Xmx4000m" ./bin/elasticsearch
    0 讨论(0)
  • 2020-11-30 18:00

    In elasticsearch path home dir i.e. typically /usr/share/elasticsearch, There is a config file bin/elasticsearch.in.sh. Edit parameter ES_MIN_MEM, ES_MAX_MEM in this file to change -Xms2g, -Xmx4g respectively. And Please make sure you have restarted the node after this config change.

    0 讨论(0)
提交回复
热议问题