Lok*_*wal 8 memory ram elasticsearch elasticsearch-5
弹性搜索占用超过 25 GB 的 RAM。我为弹性搜索索引提供的数据大约为 1 GB。为什么弹性搜索需要这么多空间?
小智 12
每当 Elastic Search 以默认设置启动时,它都会消耗大约 1 GB RAM,因为它们的堆空间分配默认为 1 GB 设置。
确保检查“jvm.options”文件
对于 Ubuntu Linux 操作系统:- {如果使用 debian 文件安装} 文件位置:- /etc/elasticsearch/
或者
对于 Windows 操作系统:- 文件位置是提取的文件夹位置 {extacted_folder_path/config/jvm.options}
在 jvm.options 文件中,您需要配置 JVM Heap 的一些设置
-Xms1g
-Xmx1g
-Xms1g 设置为在启动弹性搜索时获取 1 GB 的初始 RAM 大小。-Xmx1g 定义了最大内存分配给 Elastic Search JVM Heap。
您需要将这两个参数调整为 4 GB 或任何适合您需要的参数。
-Xms4g
-Xmx4g
注意:- 不要设置超过 32 GB 的 Java 堆空间,它不会带来任何好处。
由于某种原因,“elasticsearch”默认使用了我 24G 内存的 53%,如果你问我,这很疯狂。也许是因为它是自动配置的,如下文所述。无论如何,要设置自定义JVM堆大小,应该在jvm.options.d目录中创建一个文件“jvm.options”并添加默认“jvm.options”文件中所述的自定义值:
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
Run Code Online (Sandbox Code Playgroud)
我已将内存使用量设置为 1G,因此文件如下所示:
-Xms1g
-Xmx1g
Run Code Online (Sandbox Code Playgroud)
然后您应该重新启动“elasticsearch”服务,您可以使用以下命令检查内存使用情况:
sudo service elasticsearch status
Elasticsearch 和 jvm 版本:
版本:7.11.0,构建:default/deb/8ced7813d6f16d2ef30792e2fcde3e755795ee04/2021-02-08T22:44:01.320463Z,JVM.15.0