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
- In
elasticsearch.yml
: setbootstrap.mlockall: true
- In
/etc/sysconfig/elasticsearch
set:MAX_LOCKED_MEMORY=unlimited
.ES_HEAP_SIZE
must also be set - In
/usr/lib/systemd/system/elasticsearch.service
set:LimitMEMLOCK=infinity
- Run
systemctl daemon-reload
- Restart Elasticsearch
SysV
- In
elasticsearch.yml
set:bootstrap.mlockall: true
- In
/etc/sysconfig/elasticsearch
set:MAX_LOCKED_MEMORY=unlimited
- Restart Elasticsearch
Upstart
- In
elasticsearch.yml
set:bootstrap.mlockall: true
- In
/etc/default/elasticsearch
set:MAX_LOCKED_MEMORY=unlimited
.ES_HEAP_SIZE
must also be set - 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