elkstack管理
一、ES集群中unassigned_shards的故障
(一)、现象
-
es集群状态异常
# Elasticsearch red unassigned_shards 恢复 replicas 节点恢复
-
查看es集群状态
# 查看集群健康状态 curl -XGET http://localhost:9200/_cluster/health?pretty # 1 status 状态 red green yellow # 2 unassigned_shards 数量
-
查看unassigned_shards
# 查看所有 curl -s "http://localhost:9200/_cat/shards/" | grep UNASSIGNED # 查看正则表达式test-*下 curl -s "http://localhost:9200/_cat/shards/test-*" | grep UNASSIGNED | wc
(二)、措施
-
强制删除掉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
-
恢复配置
# test-*的UNASSIGNED为0 curl -H "Content-type: application/json" -X PUT -d '{"index":{"number_of_replicas":1}}' http://localhost:9200/test-*/_settings