Configure the Elasticsearch Service Heap Size

The Elasticsearch service is memory-intensive. By default, the Elasticsearch service is configured to use a minimum and maximum heap size of 2 GB. You can override these default values by making changes in the Elasticsearch Warden configuration file and the jvm.options file. Restart Elasticsearch after you modify the settings.

Configuring Memory in the Warden Configuration File

You can enable memory settings in the ElasticSearch Warden configuration file, located in the /opt/mapr/conf/conf.d/warden.elasticsearch.conf directory. Modify the service.heapsize.min and service.heapsize.max values set in warden.elasticsearch.conf, as shown:
service.heapsize.min=2000
service.heapsize.max=2000

The service.heapsize.min and service.heapsize.max values are set in megabytes as an integer. For older EEPs, you must make sure that the -Xms and -Xmx values in the jvm.options file match the settings in the Warden configuration file.

About the jvm.options File

The jvm.options file centralizes arguments to the Java Virtual Machine to simplify the management of the JVM options. You can no longer set the JVM options through the ES_MIN_MEM, ES_MAX_MEM, ES_HEAP_SIZE, ES_HEAP_NEWSIZE, ES_DIRECT_SIZE, ES_USE_IPV4,ES_GC_OPTS, ES_GC_LOG_FILE, and JAVA_OPTS environment variables.

If you installed the Elasticsearch service from the TAR or ZIP distributions, you can locate the jvm.options file in config/jvm.options. If you installed ElasticSearch from the Debian or RPM packages, you can locate the jvm.options file in the $ES_HOME/etc/elasticsearch/jvm.options directory, for example:
/opt/mapr/elasticsearch/elasticsearch-<version>/etc/elasticsearch

To specify an alternative location, set the ES_JVM_OPTIONS environment variable to the file path.

Configuring Memory in the jvm.options File

NOTE
If you configured Elasticsearch memory in the Warden configuration file, configuring memory in the jvm.options file is not required for EEPs 6.2.0, 6.1.1, 6.0.2 and later, which contain logic to edit the jvm.options file automatically. For other EEPs, you must ensure that memory-configuration changes are made both in the Warden configuration file and in thejvm.options file.
The -Xms and -Xmx values in the jvm.options file set the Elasticsearch heap size, as shown:
-Xms2g
-Xmx2g

The -Xms parameter sets the minimum heap size in gigabytes. The -Xmx parameter sets the maximum heap size in gigabytes. Elasticsearch recommends that both parameters have the same value.

Restarting the Elasticsearch Service

After you modify memory settings, issue the following command to restart the Elasticsearch service:
maprcli node services -name elasticsearch -nodes <space separated list of Elasticsearch nodes> -action restart
TIP
  • On a production cluster, you can lock Elasticsearch memory to improve performance. To lock Elasticsearch memory, set the bootstrap.mlockall: true option in $ES_HOME/etc/elasticsearch/elasticsearch.yml.
  • If Elasticsearch uses more than 75% of the configured heap size, you may want to increase the maximum heapsize value.

    For more information, see the Elasticsearch documentation.