Unable to change vm.max_map_count for elasticsearch

Valentina asked:


I have elasticsearch and SugarCRM7 running on CentOS 6.5. Every day I face the same problem: java outOfMemory error. That happens because of small vm.max_map_count value, 65530 only when 262144 is recommended.


The problem is that vm.max_map_count seems unchangeable:

  1. Changing under root

    sudo sysctl -w vm.max_map_count=262144


    error: permission denied on key ‘vm.max_map_count’


    ps aux | grep java

    Returns only the grep process

  2. Changing on elasticsearch startup

    sudo service elasticsearch start

    Returns error, too

    error: permission denied on key ‘vm.max_map_count’

    Starting elasticsearch: [ OK ]

  3. Manual changes via file (dirty-dirty hack):

    sudo vi /proc/sys/vm/max_map_count

    Does not work either:

    “/proc/sys/vm/max_map_count” [readonly] 1L, 6C

    — INSERT — W10: Warning: Changing a readonly file

    E45: ‘readonly’ option is set (add ! to override)

    “/proc/sys/vm/max_map_count” E212: Can’t open file for writing


    ls -la /proc/sys/vm/ | grep max_map_count


    -rw-r–r– 1 root root 0 Apr 10 09:36 max_map_count

    (But I guess this can be normal for linux talking about /proc directory)

So how can I change this variable’s value? Restarting elasticsearch every night is not a good idea… Or at least may be someone knows why this error happens?

My answer:

I think your “virtual machine” is actually an OpenVZ container (which you can verify this by running virt-what).

In this case, you can’t change vm.max_map_count sysctl or many others. The values are fixed.

This is a well known issue with elasticsearch (issue #4978). It’s not just Elasticsearch. Java apps are well known to perform poorly on various OpenVZ providers, mainly because the hosts are often poorly tuned and there’s nothing you can do about it. One commenter on that issue echoed what would be my recommendation exactly:

joshuajonah commented on Oct 20, 2015
This is insane. I guess I’m going to change over to a KVM VPS.

View the full question and any other answers on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.