问题描述
我有一个默认配置为 Elasticsearch 的 Apache 服务器,一切正常,除了默认配置的最大大小为 1GB.
I have an Apache server with a default configuration of Elasticsearch and everything works perfectly, except that the default configuration has a max size of 1GB.
我在Elasticsearch中没有那么多文档要存储,所以我想减少内存.
I don't have such a large number of documents to store in Elasticsearch, so I want to reduce the memory.
我已经看到我必须更改Java配置中的-Xmx
参数,但我不知道如何.
I have seen that I have to change the -Xmx
parameter in the Java configuration, but I don't know how.
我已经看到我可以执行这个:
I have seen I can execute this:
bin/ElasticSearch -Xmx=2G -Xms=2G
但是当我必须重新启动 Elasticsearch 时,这将丢失.
But when I have to restart Elasticsearch this will be lost.
当 Elasticsearch 作为服务安装时,是否可以更改最大内存使用量?
Is it possible to change max memory usage when Elasticsearch is installed as a service?
推荐答案
在 ElasticSearch >= 5 中的文档有 已更改,这意味着以上答案都不适合我.
In ElasticSearch >= 5 the documentation has changed, which means none of the above answers worked for me.
我尝试在 /etc/default/elasticsearch
和 /etc/init.d/elasticsearch
中更改 ES_HEAP_SIZE
,但是当我运行时ps 辅助 |grep elasticsearch
输出仍然显示:
I tried changing ES_HEAP_SIZE
in /etc/default/elasticsearch
and in /etc/init.d/elasticsearch
, but when I ran ps aux | grep elasticsearch
the output still showed:
/usr/bin/java -Xms2g -Xmx2g # aka 2G min and max ram
我必须在以下方面进行这些更改:
/etc/elasticsearch/jvm.options
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms1g
-Xmx1g
# the settings shipped with ES 5 were: -Xms2g
# the settings shipped with ES 5 were: -Xmx2g
这篇关于如何更改 Elasticsearch 最大内存大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!