I have recently been wrestling with ElasticSearch/Elastic and how to finally enable mlockall under CentOS 7. You usually will get the “Unable to lock JVM memory (ENOMEM). This can result in part of the JVM being swapped out. Increase RLIMIT_MEMLOCK (ulimit)`.”
These are all the places I made changes to get it to work. Now, I don’t know if some of these steps are skippable (my guess is some of them are), but I got it working i nthe end, and my nodes are now happily showing `mlockall: true“
Make sure
bootstrap.mlockall: true
is uncommented in/etc/elasticsearch/elasticsearch.yml
or the appropiate config file for your configuration.Edit
/etc/security/limits.conf
and add these lines (or edit them if applicable). You usually will want to add them at the very end of the file.
1 2 3 |
|
- Edit
/etc/sysconfig/elasticsearch
. You will find these values commented, and possibly without values. Change them to these:
1 2 3 4 5 6 7 8 9 |
|
- Edit
/usr/lib/systemd/system/elasticsearch.service
and make sureLimitMEMLOCK
is uncommented and set to infinity
1 2 3 4 |
|
- Edit
/etc/init.d/elasticsearch
and addsu $ES_USER --shell /bin/bash -c "ulimit -l unlimited"
before the actual start of ES, this is more or less how it looks in mine:
1 2 3 4 |
|
After I had everything in place, I restared my nodes and now they all show mlockall: true
when checked with curl http://localhost:9200/_nodes/process?pretty
Hope this helps someone!