"Unable to lock JVM Memory: error=12, reason=Cannot allocate memory"

I have enabled
bootstrap.memory_lock: true

ERROR: [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch.
bootstrap check failure [1] of [1]: memory locking requested for Elasticsearch process but memory is not locked

I am deploying elastic cluster on kubernetes

initContainers:
      - name: sysctl
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sysctl", "-w", "vm.max_map_count=262144"]
        securityContext:
          privileged: true
      - name: swapiness
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sysctl", "-w", "vm.swappiness=1"]
        securityContext:
          privileged: true
      # Increase the max number of open file descriptors.
      - name: increase-fd-ulimit
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ["sh", "-c", "ulimit -n 65535 && ulimit -u 4096 && ulimit -l unlimited"]
        securityContext:
          privileged: true

i have tried populating in dockerfile as well

USER root
RUN echo "Add limits settings ...\n"\
    && echo -e "DefaultLimitNOFILE=65536\nDefaultLimitNPROC=32000\nDefaultLimitMEMLOCK=infinity" >> /etc/systemd/user.conf \
    && echo -e "* soft nofile 65536\n* hard nofile 65536\n* soft nproc 32000\n* hard nproc 32000\n* hard memlock unlimited\n* soft memlock unlimited" >> /etc/security/limits.conf \
    && echo -e "DefaultLimitNOFILE=65536\nDefaultLimitNPROC=32000\nDefaultLimitMEMLOCK=infinity" >> /etc/systemd/system.conf

but still not working

Did you check below thread ?

yeah i have checked this thread
how to check if my system supports it or not?

Hi,

Check this ,

https://gemfire.docs.pivotal.io/97/geode/managing/heap_use/lock_memory.html

i have followed this approach even with Elasticsearch user and * . But still it doesn't work

Hi, I am facing the same issue even after making all the suggested changes. Did you happen to find any solution?

i see some system doesn't support memory lock as mentioned in few post in community. I went with disabling swap rather than setting bootstrap.memory_lock: true. I have higher ram nodes with 31gb heap size. so there is now swap happening for me now.

I am using CentOS 7. I even tried swapoff -a to disable swap altogether, which doesn't work either.

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