es 错误处理(this cluster currently has [3002]/[3000] maximum shards open)

问题:ES 又莫名其妙宕机了

查看 Elasticsearch 日志如下

[2022-03-22T09:00:02,430][WARN ][o.e.x.m.e.l.LocalExporter] [aibee-devops-es03] unexpected error while indexing monitoring document
org.elasticsearch.xpack.monitoring.exporter.ExportException: [.monitoring-es-7-2022.03.22] IndexCreationException[failed to create index [.monitoring-es-7-2022.03.22]]; nested: ValidationException[Validation Failed: 1: this action would add [2] total shards, but this cluster currently has [3002]/[3000] maximum shards open;];
        at org.elasticsearch.xpack.monitoring.exporter.local.LocalBulk.lambda$throwExportException$2(LocalBulk.java:125) ~[x-pack-monitoring-7.1.1.jar:7.1.1]

说明:ElasticSearch 7.x 开始,集群默认的分片数是 1000 个

根据错误提示显然是分片数限制,无法再增加新的分片,导致 ElasticSearch down 掉了

我们可以通过 ElasticSearch API 来增大分片数限制

curl \
-X PUT \
-H "Content-Type:application/json" \
-u elastic:password \
-d '{
        "transient":{
            "cluster":{
                "max_shards_per_node":90000
            }
        }
    }'  
'http://localhost:9200/_cluster/settings'

通过 Kibana 来修改(推荐)

# 临时增加分片数(重启es会设置时效)
PUT /_cluster/settings
{
  "transient": {
    "cluster": {
      "max_shards_per_node":900000
    }
  }
}

# 永久增加分片数(推荐)
PUT /_cluster/settings
{
  "persistent": {
    "cluster": {
      "max_shards_per_node":900000
    }
  }
}

查看分片数

GET /_cluster/settings?pretty

结果

{
  "persistent" : {
    "cluster" : {
      "max_shards_per_node" : "900000"
    },
    "xpack" : {
      "monitoring" : {
        "collection" : {
          "enabled" : "true"
        }
      }
    }
  },
  "transient" : {
    "cluster" : {
      "max_shards_per_node" : "900000"
    }
  }
}

参考

https://www.elastic.co/guide/en/elasticsearch/reference/7.1/modules-cluster.html
https://www.elastic.co/guide/en/elasticsearch/reference/7.1/cluster-update-settings.html
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值