Bootstrap.memory_lock issues

I'm running ElasticSearch using Docker and I'm starting it using Docker compose with bootstrap.memory_lock=true:

version: '3'

	  - 'bootstrap.memory_lock=true'
	  - '9200:9200'
	  - '9300:9300'

But I get this error:

[WARN ][o.e.b.JNANatives         ] Unable to lock JVM Memory: error=12, reason=Cannot allocate memory
[WARN ][o.e.b.JNANatives         ] This can result in part of the JVM being swapped out.
[WARN ][o.e.b.JNANatives         ] Increase RLIMIT_MEMLOCK, soft limit: 65536, hard limit: 65536
[WARN ][o.e.b.JNANatives         ] These can be adjusted by modifying /etc/security/limits.conf, for example:
	 # allow user 'elasticsearch' mlockall
	 elasticsearch soft memlock unlimited
	 elasticsearch hard memlock unlimited
[WARN ][o.e.b.JNANatives         ] If you are logged in interactively, you will have to re-login for the new limits to take effect.

I've added the lines to the file on both my host OS (Ubuntu Server) and the into the container and I've restarted the host OS. How can I fix this issue?

Good Morning @dhrm :wink:

Does the instance in question use swap? In general, this option needs to be enabled only when the swap is configured on the machine.

Another option is to execute the "swapoff" or else use the sysctl swapiness to control this for you. When you enable "bootstrap.memory_lock" it prevents the memory pages used by Elasticsearch from being sent to swap.

By default the memory pages have 4k, so you need to check how many pages the user has configured through ulimit -a, I assume it's 64 pages. That is 4k x 64 should be the equivalent of the amount of memory you are allocating in the heap.

To solve this you need to leave this unlimited. You can resolve this by using the limits.conf file or within the Elasticsearch boot file itself: "MAX_LOCKED_MEMORY = unlimited" or simply leave this commented option in elasticsearch.yml


This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.