failure in bulk execution: reason=[parent] Data too large, data for [indices:data/write/bulk[s]]

本文详细解析了Elasticsearch在批量插入数据时遇到的内存溢出问题,包括异常现象、原因分析及解决策略。提供了调整JVM堆内存、优化配置文件等实用技巧。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

问题场景:

elasticsearch批量插入数据的时候出现下列异常

failure in bulk execution:
[4]: index [*******], type [_doc], id [61890005], message [ElasticsearchException[Elasticsearch exception [type=circuit_breaking_exception, reason=[parent] Data too large, data for [indices:data/write/bulk[s]] would be [988794778/942.9mb], which is larger than the limit of [986932838/941.2mb], real usage: [982212384/936.7mb], new bytes reserved: [6582394/6.2mb], usages [request=0/0b, fielddata=9899078/9.4mb, in_flight_requests=20259132/19.3mb, accounting=452320/441.7kb]]]]
[6]: index [*******], type [_doc], id [61890007], message [ElasticsearchException[Elasticsearch exception [type=circuit_breaking_exception, reason=[parent] Data too large, data for [indices:data/write/bulk[s]] would be [988794778/942.9mb], which is larger than the limit of [986932838/941.2mb], real usage: [982212384/936.7mb], new bytes reserved: [6582394/6.2mb], usages [request=0/0b, fielddata=9899078/9.4mb, in_flight_requests=20259132/19.3mb, accounting=452320/441.7kb]]]]

主要原因是Data too large和which is larger than the limit of [986932838/941.2mb], real usage: [982212384/936.7mb],就是我的数据太大了然后内存爆了OOM。

解决办法:

①及时清理缓存(不现实,每次都要去清理,谁会这么闲)

②增加es的启动内存:

1、6版本前的启动方式:

./elasticsearch -Xms10g -Xmx10g(最好不要超过机器总内存的50%)

  -Xms10g 表示JVM Heap(堆内存)最小为10g,初始化内存大小

  -Xmx10g表示应用JVM最大允许分配的堆内存,程序能够使用的最大内存数

这两个参数最好设置一样,可以避免每次GC后调整堆大小。

如果这样设置还会出问题可以在elasticsearch.yml配置indices.breaker.fielddata.limit,默认大小为60%,可以根据实际情况调整大小,修改完成重新启动集群。

还可以配置indices.fielddata.cache.size清除旧数据占用的filedata,让新的数据可以加载进来。避免在查询中查不到新插入的数据

2、6版本之后的启动方式

ES_JAVA_OPTS="-Xms2g -Xmx2g"./bin/elasticsearch

参考官网地址:https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值