I have enabled the
bootstrap.memory_lock: true setting in
elasticsearch.yml; however, Elasticsearch refuses to start due to failure during bootstrap check because it cannot lock the memory. The log advised the following:
[2020-03-13T11:39:56,299][WARN ][o.e.b.JNANatives ] [hostname] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory [2020-03-13T11:39:56,303][WARN ][o.e.b.JNANatives ] [hostname] This can result in part of the JVM being swapped out. [2020-03-13T11:39:56,304][WARN ][o.e.b.JNANatives ] [hostname] Increase RLIMIT_MEMLOCK, soft limit: 16777216, hard limit: 16777216 [2020-03-13T11:39:56,305][WARN ][o.e.b.JNANatives ] [hostname] These can be adjusted by modifying /etc/security/limits.conf, for example: # allow user 'elasticsearch' mlockall elasticsearch soft memlock unlimited elasticsearch hard memlock unlimited [2020-03-13T11:39:56,306][WARN ][o.e.b.JNANatives ] [hostname] If you are logged in interactively, you will have to re-login for the new limits to take effect. [2020-03-13T11:40:08,428][INFO ][o.e.b.BootstrapChecks ] [hostname] bound or publishing to a non-loopback address, enforcing bootstrap checks [2020-03-13T11:40:08,474][ERROR][o.e.b.Bootstrap ] [hostname] node validation exception  bootstrap checks failed : memory locking requested for elasticsearch process but memory is not locked
/etc/security/limits.conf and added the configuration as instructed, but Elasticsearch still fails the bootstrap check due to failure to lock the memory even after a system reboot.
How do I solve this?
Elasticsearch 7.6.1 on Ubuntu 18.04.