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“
bootstrap.mlockall: trueis uncommented in
/etc/elasticsearch/elasticsearch.ymlor the appropiate config file for your configuration.
/etc/security/limits.confand 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
/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
/usr/lib/systemd/system/elasticsearch.serviceand make sure
LimitMEMLOCKis uncommented and set to infinity
1 2 3 4
su $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
Hope this helps someone!