Java Elasticsearch 内存问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29447434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-11 08:00:13  来源:igfitidea点击:

Elasticsearch memory problems

javaubuntumemoryelasticsearch

提问by amachado

When I'm trying too start the elasticsearch in my Ubuntu the startup script gives me the following error:

当我也尝试在我的 Ubuntu 中启动 elasticsearch 时,启动脚本给了我以下错误:

Java HotSpot(TM) Client VM warning: INFO: os::commit_memory(0x74800000, 201326592, 0) failed; error='Cannot allocate memory' (errno=12)
#
# There is insufficient memory for the Java Runtime Environment to continue.
# Native memory allocation (malloc) failed to allocate 201326592 bytes for committing reserved memory.

I try already to search by this and I couldn't find the solution for this. If I restart the machine everything work well for a day and then the elasticsearch goes down and appear this error.

我已经尝试通过此搜索,但找不到解决方案。如果我重新启动机器,一切正常运行一天,然后 elasticsearch 出现故障并出现此错误。

I already setup the property bootstrap.mlockall: true in the elasticsearch.yml file, and also the properties in the default elasticsearch file:

我已经在 elasticsearch.yml 文件中设置了属性 bootstrap.mlockall: true ,以及默认 elasticsearch 文件中的属性:

ES_HEAP_SIZE=512 (I have 1GB of RAM)
MAX_LOCKED_MEMORY=unlimited

Someone know what I need to do?

有人知道我需要做什么吗?

Thanks

谢谢

采纳答案by Yasir

You have configured a virtual machine with 1 GB of RAM, but elastic is trying to start with 2 GB of RAM (default for Elasticsearch version 5.X)

您已为虚拟机配置了 1 GB 的 RAM,但 elastic 尝试以 2 GB 的 RAM 启动(Elasticsearch 5.X 版的默认设置)

Either give more memory to your VM, or change Elasticsearch JVM settings/etc/elasticsearch/jvm.optionsand lower the values of the following parameters: -Xms512m -Xmx512m

要么为您的 VM 提供更多内存,要么更改 Elasticsearch JVM 设置/etc/elasticsearch/jvm.options并降低以下参数的值:-Xms512m -Xmx512m

回答by user3359139

You need to start elasticsearch by the following parameters: ./bin/elasticsearch -Xmx512m -Xms512

您需要通过以下参数启动elasticsearch: ./bin/elasticsearch -Xmx512m -Xms512

However it seems your memory (1G) is too low for running elasticsearch.

但是,您的内存 (1G) 似乎太低,无法运行 elasticsearch。

回答by SebaGra

For the current version of elastic (5.X)you can configure jvm startup optionsin the jvm.optionsfile usually located under directory /etc/elasticsearch/jvm.options:

对于当前版本的elastic (5.X),您可以在通常位于目录下的文件中配置jvm 启动选项jvm.options/etc/elasticsearch/jvm.options

-Xms1g -Xmx1g

Hope it helps.

希望能帮助到你。

回答by rajdeepbs29

Ideally elastic search jvm needs more memory for faster processing and querying multiple shards. However, the jvm size should not be more than the system memory size. Change the memory for elastic search as per your configuration in

理想情况下,弹性搜索 jvm 需要更多内存才能更快地处理和查询多个分片。但是,jvm 大小不应大于系统内存大小。根据您的配置更改弹性搜索的内存

/etc/elasticsearch/jvm.options:

/etc/elasticsearch/jvm.options:

-Xms4g (Minimum memory) -Xmx4g (Maximum memory)

-Xms4g(最小内存) -Xmx4g(最大内存)

Set it to the exactly half of the machine memory for ideal use

将其设置为机器内存的一半以实现理想使用

回答by willer quintanilha

In windowsyou can edit C:\ProgramData\Elastic\ElastiSearch\config\jvm.optionfile to change the size of JVM Heap (arguments: -Xms15g-Xmx15g), reducing the memory consumption.

windows下你可以编辑C:\ProgramData\Elastic\ElastiSearch\config\jvm.option文件来改变JVM Heap的大小(参数:-Xms15g -Xmx15g),减少内存消耗。