# How do I enable mlockall on Linux?

**URL:** <https://discuss.elastic.co/t/how-do-i-enable-mlockall-on-linux/97>\
**Category:** Elasticsearch\
**Created:** [May 1, 2015, 10:44am UTC](https://discuss.elastic.co/t/how-do-i-enable-mlockall-on-linux/97 "2015-05-01T10:44:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![shaunak](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shaunak/32/6643_2.png) [@shaunak](https://discuss.elastic.co/u/shaunak)\
**Post date:** [May 1, 2015, 10:44am UTC](https://discuss.elastic.co/t/how-do-i-enable-mlockall-on-linux/97/1 "2015-05-01T10:44:43Z")

</div>

As a precursor, see the mlockall section in [http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/setup-configuration.html#setup-configuration-memory](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`

---

<div class="post-metadata">

**Author:** ![tomer](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@tomer](https://discuss.elastic.co/u/tomer)\
**Post date:** [February 16, 2017, 8:47am UTC](https://discuss.elastic.co/t/how-do-i-enable-mlockall-on-linux/97/2 "2017-02-16T08:47:39Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xavierfacq](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xavierfacq/32/8744_2.png) [@xavierfacq](https://discuss.elastic.co/u/xavierfacq)\
**Post date:** [February 16, 2017, 9:58am UTC](https://discuss.elastic.co/t/how-do-i-enable-mlockall-on-linux/97/3 "2017-02-16T09:58:01Z")

</div>

Hi,

Configuring with the SysV notes should be enought.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 10:03pm UTC](https://discuss.elastic.co/t/how-do-i-enable-mlockall-on-linux/97/4 "2017-07-05T22:03:10Z")

</div>


