解决elasticsearch出现的maximum shards open问题

问题出现:

        今天发现elk日志系统没有最新日志了,从filebeat到logstash都看了一遍,没发现问题。最后在看elasticsearch日志时发现如下错误:

org.elasticsearch.xpack.monitoring.exporter.ExportException: org.elasticsearch.common.ValidationException: Validation Failed: 1: this action would add [1] total shards, but this cluster currently has [3000]/[3000] maximum shards open;

        这是因为集群最大shard(分片)数不足引起的。查询资料得知:集群中的每个节点默认限制1000个分片。

解决思路

1、调整索引或分片分配策略

        根据设备配置情况,如果已经基本满负荷,可以考虑此类方案,删除不必要索引或分片。

2、调整集群最大分片数

        2.1 在elasticsearch.yml中定义

cluster.max_shards_per_node: 10000

        2.2 在kibana控制台执行

临时增加分片数(重启后会失效)

PUT _cluster/settings
{
  "transient":{
    "cluster":{
      "max_shards_per_node": 1500
    }
  }
}

# 永久增加分片数

PUT /_cluster/settings
{
  "persistent": {
    "cluster": {
      "max_shards_per_node":1500
    }
  }
}

        2.3  通过http接口

        通过http接口和在kibana中方法类似,但它不需要依赖环境。命令如下:

curl -XPUT http://127.0.0.1:9200/_cluster/settings \
-u user:password \
-H "Content-Type: application/json" \
-d '{"transient":{"cluster":{"max_shards_per_node":1500}}}' 

         2.4查看设置结果

GET _cluster/settings?pretty 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值