# Cannot set up mlockall 'true' on RedHat 6.6

**URL:** <https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059>\
**Category:** Elasticsearch\
**Created:** [May 21, 2015, 4:56am UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059 "2015-05-21T04:56:36Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![ccrivelli](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@ccrivelli](https://discuss.elastic.co/u/ccrivelli)\
**Post date:** [May 21, 2015, 4:56am UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/1 "2015-05-21T04:56:36Z")

</div>

I read a lot around, but I'm not able to set mlockall as 'true' yet.  
Can you please help me?

This is the procedure I followed so far:

elasticsearch config  
`# vim /etc/elasticsearch/elasticsearch.yml`

`bootstrap.mlockall: true`

added memlock unlimited in system security limits  
`# vim /etc/security/limits.conf`

````auto
elasticsearch - memlock unlimited
root - memlock unlimited```

add these lines for sysconfig
```# vim /etc/sysconfig/elasticsearch```

```ES_HEAP_SIXE=8g
MAX_OPEN_FILES=65535
MAX_LOCKED_MEMORY=unlimited```

uncomment also this line for systemd (even if I'm using SystemV)
```# vim /usr/lib/systemd/system/elasticsearch.service```

```(uncomment)
LimitMEMLOCK=infinity```

to be sure I also added "ulimit -l unlimited" when start elasticsearch the service
```# vim /etc/init.d/elasticsearch```

```(add)
 su $ES_USER --shell /bin/bash -c "ulimit -l unlimited"```

changed the TMP directory to be sure is not mounted as 'noexec'
```# mkdir /opt/apps/elasticsearch/tmp```
```# vim /etc/sysconfig/elasticsearch```

```(change tmp directory)```
```#WORK_DIR=/tmp/elasticsearch
WORK_DIR=/opt/apps/elasticsearch/tmp```
	
start the service
```# service elasticsearch start```

check heap size (OK - uses 8Gb)
```# ps aux | grep elastic
497 26547 200 1.0 11122692 167744 ? Sl 10:47 0:04 /usr/bin/java -Xms8g -Xmx8g -Djava.awt.headless``

check mlockall (still false)
```# curl http://localhost:9200/_nodes/process?pretty | grep mlockall```

        "mlockall" : false
        "mlockall" : false
        "mlockall" : false
        "mlockall" : false
        "mlockall" : false
        "mlockall" : false
        "mlockall" : false

Thanks
````

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [May 21, 2015, 5:34am UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/2 "2015-05-21T05:34:09Z")

</div>

running elasticsearch 1.5.2 with java8. what I did is uncomment the bootstrap.mlockall: true and restart the node. other settings pretty much centos stock settings.

```
[user@localhost ~]$ curl 'localhost:9200/_cat/health?v'
epoch timestamp cluster status node.total node.data shards pri relo init unassign pending_tasks 
1432186260 07:31:00 elasticsearch green 3 3 0 0 0 0 0 0 
[user@localhost ~]$ curl -s http://localhost:9200/_nodes/process?pretty | grep mlockall
        "mlockall" : true
        "mlockall" : true
        "mlockall" : true
```

---

<div class="post-metadata">

**Author:** ![ccrivelli](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@ccrivelli](https://discuss.elastic.co/u/ccrivelli)\
**Post date:** [May 21, 2015, 5:47am UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/3 "2015-05-21T05:47:27Z")

</div>

Hi Jason,  
when you say 'restart the node' do you mean 'restart elasticsearch' or 'restart the machine'?

---

<div class="post-metadata">

**Author:** ![Jason\_Wee](https://avatars.discourse-cdn.com/v4/letter/j/7ea924/32.png) [@Jason\_Wee](https://discuss.elastic.co/u/Jason_Wee)\
**Post date:** [May 21, 2015, 5:59am UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/4 "2015-05-21T05:59:06Z")

</div>

sorry, my bad, I meant to say restart elasticsearch instance.

---

<div class="post-metadata">

**Author:** ![ccrivelli](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@ccrivelli](https://discuss.elastic.co/u/ccrivelli)\
**Post date:** [May 21, 2015, 6:07am UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/5 "2015-05-21T06:07:42Z")

</div>

It's what I did at the beginning:

- uncomment "mlockall" : true in elasticsearch.yml
- restart elasticsearch

But It didn't work!  
That's why I started changing other settings ...

I'm running elasticsearch 1.5.0 (installed with elasticsearch-1.5.0.noarch.rpm) and Java8.

Any other idea?  
Thanks

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 21, 2015, 7:54am UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/6 "2015-05-21T07:54:31Z")

</div>

It's a known issue - [https://github.com/elastic/elasticsearch/issues/9357](https://github.com/elastic/elasticsearch/issues/9357)

---

<div class="post-metadata">

**Author:** ![ccrivelli](https://avatars.discourse-cdn.com/v4/letter/c/f1d935/32.png) [@ccrivelli](https://discuss.elastic.co/u/ccrivelli)\
**Post date:** [May 22, 2015, 12:48am UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/7 "2015-05-22T00:48:30Z")

</div>

After changing all the options above before..

it worked for me after setting up also the WORK\_DIR on a different path than /tmp ( because the /tmp directory is mounted as 'noexec') and appending "-Djna.tmpdir=$WORK\_DIR" as additional parameter in elasticsearch start command line inside /etc/init.d/elasticsearch ( even if there is already a parameter like "-Des.default.path.work=$WORK\_DIR" ).

`# curl http://localhost:9200/_nodes/process?pretty | grep mlockall`

```
"mlockall" : true
"mlockall" : false
"mlockall" : true
"mlockall" : false
"mlockall" : true
"mlockall" : true
"mlockall" : true

```

But I think It's all good because 2 nodes are client nodes (master and data false).

---

<div class="post-metadata">

**Author:** ![terrasacer](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@terrasacer](https://discuss.elastic.co/u/terrasacer)\
**Post date:** [September 25, 2015, 7:49pm UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/8 "2015-09-25T19:49:45Z")

</div>

Hi guys,

I have same problem.

my system information  
Yosemite 10.10. 6  
java version "1.8.0\_60-ea"

elasticsearch config file

```
bootstrap.mlockall: true

```

when I run the '[http://localhost:9200/\_nodes/process?pretty](http://localhost:9200/_nodes/process?pretty)' command I get the following output

```
curl 'http://localhost:9200/_nodes/process?pretty'
{
  "cluster_name" : "elasticsearch",
  "nodes" : {
    "l70PZsNpTTOTFo0nxoZBnA" : {
      "name" : "Eliminator",
      "transport_address" : "inet[192.168.1.21/192.168.1.21:9300]",
      "host" : "terrasacer-air.local",
      "ip" : "192.168.1.21",
      "version" : "1.7.1",
      "build" : "b88f43f",
      "http_address" : "inet[/192.168.1.21:9200]",
      "process" : {
        "refresh_interval_in_millis" : 1000,
        "id" : 8565,
        "max_file_descriptors" : 10240,
        "mlockall" : false
      }
    }
  }
}

```

but when I run the following command

```
curl 'http://localhost:9200/_nodes/?pretty'
{
...
,
  "foreground" : "yes",
   "bootstrap" : {
          "mlockall" : "true"
  },
...
}

```

what is going on? 😄

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 25, 2015, 8:08pm UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/9 "2015-09-25T20:08:23Z")

</div>

Mac OS X does not have `mlockall` implemented.

---

<div class="post-metadata">

**Author:** ![terrasacer](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@terrasacer](https://discuss.elastic.co/u/terrasacer)\
**Post date:** [September 25, 2015, 8:14pm UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/10 "2015-09-25T20:14:20Z")

</div>

Hi @jprante,

First, thank you for your answer.

The documentation says:

> The third option is to use mlockall on _ **Linux/Unix systems** _, or VirtualLock on Windows, to try to lock the process address space into RAM, preventing any Elasticsearch memory from being swapped out. This can be done, by adding this line to the config/elasticsearch.yml file:

Is there misdirection here?

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 25, 2015, 8:29pm UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/11 "2015-09-25T20:29:57Z")

</div>

The documentation is correct.

Apple decided not to expose the memory pinning functions to user space processes, like `mlockall`. Only Mac OS X kernel drivers are allowed to do this.

---

<div class="post-metadata">

**Author:** ![terrasacer](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@terrasacer](https://discuss.elastic.co/u/terrasacer)\
**Post date:** [September 25, 2015, 8:34pm UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/12 "2015-09-25T20:34:22Z")

</div>

Okey, I understand.

In this case, misleading information returned by the curl '[http://localhost:9200/\_nodes/?pretty](http://localhost:9200/_nodes/?pretty)' command:

```
curl 'http://localhost:9200/_nodes/?pretty'
{
...
,
  "foreground" : "yes",
   "bootstrap" : {
          "mlockall" : "true"
  },
...
}
```

---

<div class="post-metadata">

**Author:** ![jprante](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jprante/32/44941_2.png) [@jprante](https://discuss.elastic.co/u/jprante)\
**Post date:** [September 25, 2015, 8:42pm UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/13 "2015-09-25T20:42:40Z")

</div>

These are just your command line arguments that you have passed to the JVM. The output means nothing with regard to having the parameters applied successfully.

---

<div class="post-metadata">

**Author:** ![terrasacer](https://avatars.discourse-cdn.com/v4/letter/t/ecd19e/32.png) [@terrasacer](https://discuss.elastic.co/u/terrasacer)\
**Post date:** [September 25, 2015, 8:46pm UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/14 "2015-09-25T20:46:36Z")

</div>

Ok @jprante,

Thank you very much for the explanation.

---

<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, 11:48pm UTC](https://discuss.elastic.co/t/cannot-set-up-mlockall-true-on-redhat-6-6/1059/15 "2017-07-05T23:48:00Z")

</div>


