Elasticsearch: Max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

192,207

Solution 1

Vivek's answer

sysctl -w vm.max_map_count=262144

is correct, however, the setting will only last for the duration of the session. If the host reboots, the setting will be reset to the original value.

If you want to set this permanently, you need to edit /etc/sysctl.conf and set vm.max_map_count to 262144.

When the host reboots, you can verify that the setting is still correct by running sysctl vm.max_map_count

Solution 2

For MS Windows users, using wsl subsystem

Open powershell, run

wsl -d docker-desktop

then

sysctl -w vm.max_map_count=262144

Solution 3

Insert the new entry into the /etc/sysctl.conf file with the required parameter:

vm.max_map_count = 262144

it make changes permanent.

Also run:

sysctl -w vm.max_map_count=262144

change current state of kernel.

If you use docker to take effect you should restart it:

systemctl restart docker

Solution 4

See the Elasticsearch documentation about virtual memory. On Centos you can do with following command:

sysctl -w vm.max_map_count=262144

Solution 5

This is not an answer per se but a clarification/shortcut for anyone having the op's problem from a docker container perspective. I had this problem from an application running in a docker container. And as explained here by nishant

You don’t need to increase the virtual memory for Elasticsearch at the container level, you can do it for the host machine by running this command:

sudo sysctl -w vm.max_map_count=262144

and then restart your docker-containers.

As explained by val above setting this max_map_count this way won't persist upon the restart of the machine on which is running the docker container. and so you will need to save it in a more persistent manner as explained by him above.

Share:
192,207

Related videos on Youtube

casibbald
Author by

casibbald

Updated on April 05, 2022

Comments

  • casibbald
    casibbald about 2 years

    I have an issue with a systemd config for ElasticSearch.

    [Unit]
    Description=platform-elasticsearch
    After=syslog.target network.target remote-fs.target nss-lookup.target
    
    [Service]
    User={{ app_user }}
    Group={{ app_group }}
    Environment=ES_PATH_CONF=/platform/opt/elasticsearch-{{ elasticsearch.version }}/config
    Environment=JAVA_HOME=/platform/opt/jdk{{ jdk.major_version }}_{{ jdk.minor_version }}
    LimitAS=infinity
    LimitRSS=infinity
    LimitCORE=infinity
    LimitNOFILE=100000
    LimitMEMLOCK=100000
    StandardOutput=syslog
    StandardError=syslog
    WorkingDirectory=/platform/var/app/elasticsearch
    ExecStart=/platform/opt/elasticsearch-{{ elasticsearch.version }}/bin/elasticsearch
    ExecReload=/bin/kill -s HUP $MAINPID
    ExecStop=/bin/kill -s -TERM $MAINPID
    TimeoutStopSec=60
    # When a JVM receives a SIGTERM signal it exits with code 143
    SuccessExitStatus=143 0
    Type=simple
    Restart=on-failure
    RestartSec=10
    PIDFile=/platform/var/run/elasticsearch.pid
    
    [Install]
    WantedBy=multi-user.target
    

    This does not seem to let me configure the vm.max_map_count setting.

    Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,359][INFO ][o.e.b.BootstrapChecks    ] [1oQJNUK] bound or publishing to a non-loopback     address, enforcing bootstrap checks
    Jul 20 14:53:46 scratchpad elasticsearch: ERROR: [1] bootstrap checks failed
    Jul 20 14:53:46 scratchpad elasticsearch: [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,376][INFO ][o.e.n.Node               ] [1oQJNUK] stopping ...
    Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,414][INFO ][o.e.n.Node               ] [1oQJNUK] stopped
    Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,414][INFO ][o.e.n.Node               ] [1oQJNUK] closing ...
    Jul 20 14:53:46 scratchpad elasticsearch: [2018-07-20T14:53:46,445][INFO ][o.e.n.Node               ] [1oQJNUK] closed
    Jul 20 14:53:46 scratchpad systemd: platform-elasticsearch.service: main process exited, code=exited, status=78/n/a
    

    The specific issue is the following:

    Jul 20 14:53:46 scratchpad elasticsearch: [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
    

    I have been able to start elastic search on the commandline with the following:

    sudo su -c 'echo 262144 > "/proc/sys/vm/max_map_count"' && \ 
    export JAVA_HOME=/platform/opt/jdk1.8.0_181 && \
    export ES_PATH_CONF=/platform/opt/elasticsearch-6.3.1/config && \
    /platform/opt/elasticsearch-6.3.1/bin/elasticsearch 
    

    can anyone tell me why LimitMEMLOCK=100000 does not work, and how I can effectively set max_map_count from within systemd.

    I have also tried to set the following:

    cat /etc/security/limits.d/30_elastic_limits.conf
    
    vagrant       hard    nofile     500000
    vagrant       hard    memlock     262144
    

    but this seems to be totally ignored by systemd.

  • hybaken
    hybaken almost 6 years
    Do not forget to reboot or: sysctl --system
  • xiaojueguan
    xiaojueguan over 3 years
    if you are not root user you should make sure you have sudo right and use sudo before execute above.
  • xiaojueguan
    xiaojueguan over 3 years
    if you use docker-compose to run containers on host, you can also run this command sysctl -w vm.max_map_count=262144 with root privilege to solve this problem.
  • Mustafa Salih ASLIM
    Mustafa Salih ASLIM about 3 years
    note that if you restart the machine that configuration will be gone, so this method is not permanent.
  • dexter2305
    dexter2305 about 3 years
    Use sysctl vm.max_map_count=262144 (iwithout -w) and this way the change is available only till shutdown of OS. It is a dev machine. So, i did not want to change permanently.
  • user1653042
    user1653042 over 2 years
    This worked for me on Windows 10 machine. Last step would be to enter exit in order to kick out of wsl.
  • Yunnosch
    Yunnosch over 2 years
    What is the additional insight which your post provides in addition to existing answer? Especially compared to the most upvoted answer and the one it refers to. Try to avoid the impression that you create answers by using info from other answers to the same question, especially when even the summary is already there...
  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
  • thevoyager
    thevoyager over 2 years
    worked just fine, thank you very much! pitty I had to copy the command to power shell
  • Mr. T
    Mr. T over 2 years
    This doesn't seem to be a "sticky" change in Docker Desktop -- you have to run the command every time you restart Docker, which is really obnoxious.
  • Ytzvan Mastino
    Ytzvan Mastino over 2 years
    Thanks! Worked as expected
  • MonkeyDreamzzz
    MonkeyDreamzzz about 2 years
    To persist the change, you can add vm.max_map_count = 262144 to /etc/sysctl.conf
  • Gravity API
    Gravity API about 2 years
    This solution works. It is also the official solution from Elastic. Thank you!