elasticsearchTemplate 批量插入数据时,报错es节点拒绝插入。

错误信息:

org.springframework.data.elasticsearch.ElasticsearchException: Bulk indexing has failures. Use ElasticsearchException.getFailedDocuments() for detailed messages [{970893=RemoteTransportException[[node-1][127.0.0.1:9300][indices:data/write/bulk[s][p]]]; nested: EsRejectedExecutionException[rejected execution of org.elasticsearch.transport.TransportService$7@4e8e5243 on EsThreadPoolExecutor[bulk, queue capacity = 200, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@78ffd538[Running, pool size = 1, active threads = 1, queued tasks = 200, completed tasks = 1104226]]];,

解决方法:

查看各节点线程池配置
GET /ES地址/_nodes/thread_pool/

执行上述命令查看线程池配置:

{"_nodes":{"total":1,"successful":1,"failed":0},"cluster_name":"my-application","nodes":{"OKYdCPdRQMSCUWaXn-RXuA":{"name":"node-1","transport_address":"127.0.0.1:9300","host":"127.0.0.1","ip":"127.0.0.1","version":"6.0.0","build_hash":"8f0685b","roles":["master","data","ingest"],"thread_pool":{"force_merge":{"type":"fixed","min":1,"max":1,"queue_size":-1},"fetch_shard_started":{"type":"scaling","min":1,"max":2,"keep_alive":"5m","queue_size":-1},"listener":{"type":"fixed","min":1,"max":1,"queue_size":-1},"index":{"type":"fixed","min":1,"max":1,"queue_size":200},"refresh":{"type":"scaling","min":1,"max":1,"keep_alive":"5m","queue_size":-1},"generic":{"type":"scaling","min":4,"max":128,"keep_alive":"30s","queue_size":-1},"warmer":{"type":"scaling","min":1,"max":1,"keep_alive":"5m","queue_size":-1},"search":{"type":"fixed_auto_queue_size","min":2,"max":2,"queue_size":1000},"flush":{"type":"scaling","min":1,"max":1,"keep_alive":"5m","queue_size":-1},"fetch_shard_store":{"type":"scaling","min":1,"max":2,"keep_alive":"5m","queue_size":-1},"management":{"type":"scaling","min":1,"max":5,"keep_alive":"5m","queue_size":-1},"get":{"type":"fixed","min":1,"max":1,"queue_size":1000},"bulk":{"type":"fixed","min":1,"max":1,"queue_size":200},"snapshot":{"type":"scaling","min":1,"max":1,"keep_alive":"5m","queue_size":-1}}}}}

可以看到我们线程池的配置如下:
“bulk”:{“type”:“fixed”,“min”:1,“max”:1,“queue_size”:200}

下一步:
修改线程池的配置:
PUT /_cluster/settings
{
“transient”: {
“threadpool.bulk.type”: “fixed”,
“threadpool.bulk.queue_size”: 1000,
“threadpool.bulk.size”: 128,
“threadpool.bulk.min”: 128,
“threadpool.bulk.max”: 128
}
}

发现报了如下错误:transient setting [threadpool.bulk.max], not dynamically updateable,
原来是queue_size参数并不能通过api来更改了,需要修改配置文件并且重启机器。
注意 thread_pool.bulk.size 不可以超过cpu核数的2倍,修改配置如下,重启之后就OK。

 thread_pool.bulk.queue_size: 10000
 thread_pool.bulk.size: 16
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值