Configure virtual memory for Elasticsearch on Kubernetes
By default, Elasticsearch uses the mmapfs
directory to store its indices. The limits on mmap
are low on the default operating system. Therefore, before deploying Elasticsearch, you must configure its virtual memory by setting the vm.max_map_count
limit to 262144 or higher on each Kubernetes node of the target cluster. Without this configuration, Elasticsearch pods will not be ready and the logs will contain the following error:
bootstrap check failure [1] of [1]: max virtual memory areas vm.max_map_count [XXX] is too low, increase to at least [262144]
To set the vm.max_map_count
limit on Linux:
-
Get all names of the nodes running in the cluster:
kubectl get nodes -o name
-
Get
ssh
access in to each Kubernetes node:kubectl node-shell <node-name>
-
Increase the limit as
root
:sysctl -w vm.max_map_count=262144
To set this limit permanently, run the following command:
grep -q vm.max_map_count /etc/sysctl.conf &&
sed -i 's/vm\.max_map_count=.*/vm\.max_map_count=262144/' /etc/sysctl.conf ||
echo "vm.max_map_count=262144" >> /etc/sysctl.conf
In EKS, the vm.max_map_count
limit is set to 262144 by default. So, you need not perform this configuration in EKS. See Prerequisites for all the supported Kubernetes versions in PDS.