How do I enable mlockall on Linux?

As a precursor, see the mlockall section in http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-configuration.html#setup-configuration-memory

The location of some of the files below may vary depending on your distribution.

Systemd

  1. In elasticsearch.yml: set bootstrap.mlockall: true
  2. In /etc/sysconfig/elasticsearch set: MAX_LOCKED_MEMORY=unlimited. ES_HEAP_SIZE must also be set
  3. In /usr/lib/systemd/system/elasticsearch.service set: LimitMEMLOCK=infinity
  4. Run systemctl daemon-reload
  5. Restart Elasticsearch

SysV

  1. In elasticsearch.yml set: bootstrap.mlockall: true
  2. In /etc/sysconfig/elasticsearch set: MAX_LOCKED_MEMORY=unlimited
  3. Restart Elasticsearch

Upstart

  1. In elasticsearch.yml set: bootstrap.mlockall: true
  2. In /etc/default/elasticsearch set: MAX_LOCKED_MEMORY=unlimited. ES_HEAP_SIZE must also be set
  3. Restart Elasticsearch

You can then test if mlockall is enabled by running curl 'http://127.0.0.1:9200/_nodes/process?pretty' and checking for mlockall: true

2 Likes

Hi Shaunak,
For people using CentOs 6 we dont have a directory "systemd". How to continue with out this?

Hi,

Configuring with the SysV notes should be enought.