Ubuntu - elasticsearch - Error: Cannot allocate memory

走远了吗. 提交于 2019-12-04 05:03:00
Nello

Looks like you're trying to start ElasticSearch with the default options, which attempt to set a stack size of 2Go. If you don't have that free... kaboom (silently).

Have a look in /etc/elasticsearch/jvm.options and modify the lines:

-Xms2g
-Xmx2g

to something that will fit in your available memory. But be aware that ElasticSearch is a great big memory hog and wants it all. You may not get a useful system under the 2Go limit.

First of all, Elasticsearch uses a hybrid mmapfs / niofs directory. The operating system limits on mmap counts, usually default value is 65536. It may result in out-of-memory exceptions. On Linux, you can increase this default kernel value by running the following command as root:

sysctl -w vm.max_map_count=262144

Or permanently, by updating the vm.max_map_count setting in /etc/sysctl.conf. You can also change by the following command:

echo 262144 > /proc/sys/vm/max_map_count

For more info, please check Linux kernel documentation:

max_map_count: This file contains the maximum number of memory map areas a process may have. Memory map areas are used as a side-effect of calling malloc, directly by mmap and mprotect, and also when loading shared libraries. While most applications need less than a thousand maps, certain programs, particularly malloc debuggers, may consume lots of them, e.g., up to one or two maps per allocation. The default value is 65536.

The second thing you should take into account is JVM minimum heap size and maximum heap size. You can change this values on your machine in /etc/elasticsearch/jvm.options. To choose suitable values, you can find good rules of thumbs on Elastic set JVM heap size page.

This answer worked for me.

I changed the initial size of the total heap space and maximum size of the total heap space by changing below values of

/etc/elasticsearch/jvm.options

From
-Xms1g
-Xmx1g

To
-Xms256m
-Xmx256m

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!