Elasticsearch OpenSearch Bootstrap.Memory_Lock is Set to False

By Opster Team

Updated: Oct 19, 2023

| 2 min read

Before you dig into the details of this technical guide, have you tried asking OpsGPT?

You'll receive concise answers that will help streamline your Elasticsearch/OpenSearch operations.


Try OpsGPT now for step-by-step guidance and tailored insights into your Elasticsearch/ OpenSearch operation.

Before you dig into the details of this guide, have you tried asking OpsGPT? You’ll receive concise answers that will help streamline your OpenSearch/Elasticsearch operation.

Try OpsGPT now for step-by-step guidance and tailored insights into your search operation.

To easily resolve issues in your deployment and locate their root cause, try AutoOps for OpenSearch. It diagnoses problems by analyzing hundreds of metrics collected by a lightweight agent and offers guidance for resolving them. Try AutoOps for free.

Overview

OpenSearch performance can be heavily penalised if the node is allowed to swap memory to disk. OpenSearch can be configured to automatically prevent memory swapping on its host machine by adding the bootstrap memory_lock true setting to opensearch.yml. If bootstrap checks are enabled, Elasticsearch will not start if memory swapping is not disabled. You can learn more about bootstrap checks here: Bootstraps Check in OpenSearch – A Detailed Guide With Examples.

Note: It may be perfectly valid to have 

bootstrap.memory_lock: false

In your configuration if you have taken alternative steps to stop memory swapping. See Other ways of Preventing Memory Swapping below.

How to resolve it

Edit opensearch.yml to include the following setting:

bootstrap.memory_lock: true

You can check whether the setting has worked by running:

GET _nodes?filter_path=**.mlockall

You should see true in the output.

{
  "nodes" : {
"ifU4SFrKTcCaR5Om0uFFbw" : {
  "process" : {
    "mlockall" : true
  }
}
  }
}

If on the other hand you see false, then further configuration is necessary.

RPM and Debian SystemD installations

sudo systemctl edit opensearch 

Add the following:

[Service]
LimitMEMLOCK=infinity
sudo systemctl daemon-reload

.zip and .tar.gz installations

Add the following line to  /etc/security/limits.conf

opensearch  -  nofile  65535

Other ways of preventing memory swapping

There are other ways of preventing memory swapping other than using 

bootstrap.memory_lock: false

Turn off all swapping on Linux option 1

sudo swapoff -a

This doesn’t require a restart of OpenSearch.

To disable permanently (upon restart) edit /etc/fstab file

Comment out any lines containing “swap” below is just an example

#/dev/mapper/ubuntu--vg-swap_1 none        swap sw          0  

Turn off all swapping on Linux using sysctl option 2

Edit /etc/sysctl.conf

vm.swappiness=1

Checking memory swapping is effective

Run:

GET _nodes/stats/os

You should see the following in the response for each of the nodes:

"swap" : {
      "total_in_bytes" : 0,
      "free_in_bytes" : 0,
      "used_in_bytes" : 0
    },

How helpful was this guide?

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?


Related log errors to this OS concept


Failed to load settings from resourceName
Reroute after update settings failed
Unexpected token while parsing source settings
Failed to load settings from
Failed to get setting group for settingPrefix setting prefix and setting
Secure settings cannot be updated cluster wide when TLS for the transport layer
Cannot determine current memory usage due to JDK-8207200
GetFreePhysicalMemorySize is not available
Exception retrieving free physical memory
GetTotalPhysicalMemorySize is not available
Exception retrieving total physical memory
Unable to retrieve resource limits

< Page: 2 of 7 >

Get expert answers on Elasticsearch/OpenSearch