How to change Elasticsearch max memory size

后端 未结 11 822
时光取名叫无心
时光取名叫无心 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:55

    If you installed ES using the RPM/DEB packages as provided (as you seem to have), you can adjust this by editing the init script (/etc/init.d/elasticsearch on RHEL/CentOS). If you have a look in the file you'll see a block with the following:

    export ES_HEAP_SIZE
    export ES_HEAP_NEWSIZE
    export ES_DIRECT_SIZE
    export ES_JAVA_OPTS
    export JAVA_HOME
    

    To adjust the size, simply change the ES_HEAP_SIZE line to the following:

    export ES_HEAP_SIZE=xM/xG
    

    (where x is the number of MB/GB of RAM that you would like to allocate)

    Example:

    export ES_HEAP_SIZE=1G
    

    Would allocate 1GB.

    Once you have edited the script, save and exit, then restart the service. You can check if it has been correctly set by running the following:

    ps aux | grep elasticsearch
    

    And checking for the -Xms and -Xmx flags in the java process that returns:

    /usr/bin/java -Xms1G -Xmx1G
    

    Hope this helps :)

提交回复
热议问题