elkstack管理

一、ES集群中unassigned_shards的故障


(一)、现象

  1. es集群状态异常

    # Elasticsearch red unassigned_shards 恢复 replicas 节点恢复
    
  2. 查看es集群状态

    # 查看集群健康状态
    curl -XGET http://localhost:9200/_cluster/health?pretty
    
    # 1 status 状态
    red green yellow
    # 2 unassigned_shards 数量
    
  3. 查看unassigned_shards

    # 查看所有
    curl -s "http://localhost:9200/_cat/shards/" | grep UNASSIGNED
    # 查看正则表达式test-*下
    curl -s "http://localhost:9200/_cat/shards/test-*" | grep UNASSIGNED | wc
    

(二)、措施

  1. 强制删除掉replica shards

    # 将test-*所有的replica shards删除
    curl -H "Content-type: application/json" -X PUT -d '{"index":{"number_of_replicas":0}}' http://localhost:9200/test-*/_settings
    # 如果test-*的UNASSIGNED不为0,需要删除索引
    curl -XDELETE http://localhost:9200/test-xxxx.xx.xx
    
  2. 恢复配置

    # test-*的UNASSIGNED为0
    curl -H "Content-type: application/json" -X PUT -d '{"index":{"number_of_replicas":1}}' http://localhost:9200/test-*/_settings
    
posted @ 2021-01-21 10:32  qms19  阅读(73)  评论(0编辑  收藏  举报