Logstash写入Elasticsearch并发问题

本文描述了在使用Logstash将日志数据写入Elasticsearch集群时遇到的并发问题,包括Logstash启动报错、线程池处理不过来以及Elasticsearch节点分片不均匀的问题。通过调整Elasticsearch的threadpool配置和设置index.routing.allocation.total_shards_per_node属性,解决了请求压力集中在单个节点和分片分配不均的问题。
摘要由CSDN通过智能技术生成

Logstash写入Elasticsearch并发问题

              公司项目是通过Logstash采集日志存入Elasticsearch集群中,Logstash通过配置文件启动的时候报如下错误:

   

[2017-03-11T10:08:11,390][ERROR][Logstash.outputs.elasticsearch] Action
[2017-03-11T10:08:11,391][ERROR][Logstash.outputs.elasticsearch] Action
[2017-03-11T10:08:11,393][INFO][logstash.outputs.elasticsearch]retrying failed 
action with response code:429 ({"type" => "es_rejected_execution_exception", "reason" => "rejected" execute of org.elasticsearch.transport.TransportService$6@1046foc on EsThreadPoolExecutor [bulk.queue.capacity=50, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@e2e35f2 [Runing, pool size = 32, active threads = 32 queue.capacity=50, completed tasks=1041050369"]}

      以为是资源不够,通过停了所有Logstash进程再重新启动,同样报这个错误。确认不是集群资源问题。通过设置elasticsearch.yml设置纯种池也无法解决问题:

    

  1. threadpool.index.type: fixed  
  2. threadpool.index.size: 100  
  3. threadpool.index.queue_size: 500 

 

线程处理不过来。queue加大到1000也无法解决这个问题。

 

       通过RestAPIs:http://localhost:9002/_cat/thread_pool?pretty查看其拒绝服务的那台机器,正好是分片数量最多的节点。也就是分片没有打散,当前集中有3个分片,导致请求压力都在当前节点上。通过设置模版和索引的index.routing.allocation.total_shards_per_node属性解决这个问题。设置成功后分片会打散至其他节点上。 

        需要特别注意这个属性,如果设置值为1,也就是说每个节点最多保存一个分片,当你分片的总数(包括复本数)大于节点数,会一值报分片的异常。



   

 

   

 

 

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值