Elasticsearch OutOfMemoryError Java 堆空间
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27359885/
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
Elasticsearch OutOfMemoryError Java heap space
提问by B.P
I am running an 8 cores, 32g RAM elasticsearch node with 5 shards, 400 million (small) documents.
我正在运行一个 8 核、32g RAM、具有 5 个分片、4 亿(小)文档的弹性搜索节点。
Everything works great until I run an agg search, then shards start failing with:
一切正常,直到我运行 agg 搜索,然后分片开始失败:
java.lang.OutOfMemoryError: Java heap space
I have changed heap sizewith:
export ES_HEAP_SIZE=16g
(also ES_MAX_MEM
and ES_MIN_MEM
to same)
我已经改变了堆大小有:
export ES_HEAP_SIZE=16g
(也ES_MAX_MEM
并ES_MIN_MEM
以相同的)
also changed the yml
file for elasticsearch:
还更改了yml
elasticsearch的文件:
bootstrap.mlockall: true
and even (recommended by install documents):
甚至(安装文档推荐):
sudo sysctl -w vm.max_map_count=262144
Restart service and still no no impact, still java.lang.OutOfMemoryError: Java heap space
重启服务还是没有影响,还是 java.lang.OutOfMemoryError: Java heap space
Any other suggestions? other than don't run agg queries?
还有其他建议吗?除了不运行 agg 查询?
query is:
查询是:
https://localhost:9200/my_index_name/_search?search_type=count
{
"aggs": {
"distinct_hostname": {
"cardinality": {
"field": "hostname"
}
}
}
}
回答by B.P
I think I have discovered the error. I was using 'service' to run elasticsearch and therefore my environment variables got stripped. I had to update the /etc/default/elasticsearch
file with the correcct env variables (specifically the ES_HEAP_SIZE=16g
).
我想我已经发现了错误。我使用'service'来运行elasticsearch,因此我的环境变量被剥离了。我必须/etc/default/elasticsearch
使用正确的环境变量(特别是ES_HEAP_SIZE=16g
)更新文件。
So far it's running well and app is not erroring.
到目前为止,它运行良好,应用程序没有出错。
回答by Craig
The correct way to update Java heap size for Elasticsearch 5 is not EXPORT _JAVA_OPTIONS
or EXPORT ES_HEAP_SIZE
or using command line parameters. As far as I can tell, all of these are overridden by a configuration file in your Elasticsearch install directory, config/jvm.options
. To change these settings you need to edit these lines in that file:
正确的方法来更新Java堆大小为Elasticsearch 5不是EXPORT _JAVA_OPTIONS
或EXPORT ES_HEAP_SIZE
或使用命令行参数。据我所知,所有这些都被 Elasticsearch 安装目录中的配置文件覆盖config/jvm.options
。要更改这些设置,您需要编辑该文件中的这些行:
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
-Xms2g
-Xmx2g