诊断
GET _cat/indices/threateventGET _cat/shards/threateventGET _cluster/allocation/explainGET /_cluster/allocation/explain{"index": "threatevent","shard": 3,"primary": true}
https://blog.csdn.net/laoyang360/article/details/109699085
修复方案
REOPEN 分片
[root@sh ~]# curl -s -XPOST localhost:9200/Twitter/_close?pretty{"acknowledged": true}[root@sh ~]# curl -s -XPOST localhost:9200/Twitter/_open?pretty{"acknowledged": true,"shards_acknowledged": true}
分配陈腐分片
如果 reopen 索引无法使分片上线, 则需要考虑使用 reroute API 分配 stale primary. 执行这个 API 之前, 我们需要得到一些信息:
索引名称和分片 ID 可以通过 explain API 直观看到;
节点名称可以通过 unassigned_info.details 得到.
根据这些信息, 我们就可以执行 reroute API 了
[root@sh ~]# curl -s -H "Content-Type:application/json" -XPOST "localhost:9200/_cluster/reroute?pretty" -d '{"commands": [{"allocate_stale_primary": {"index": "{索引名称}","shard": "{分片 ID}","node": "{节点名称}","accept_data_loss": true}}]}
丢弃分片
如果分配陈腐的分片也无法使分片上线, 为了不影响索引读写请求, 就只能丢弃掉损坏的分片了, 这是最糟糕的情况(会造成数据丢失):
[root@sh ~]# curl -s -H "Content-Type:application/json" -XPOST "localhost:9200/_cluster/reroute?pretty" -d '{"commands" : [{"allocate_empty_primary" : {"index" : "{索引名称}","shard" : "{分片 ID}","node" : "{节点名称}","accept_data_loss": true}}]}'
部分已知问题
TranslogCorruptedException
https://blog.csdn.net/jiao_fuyou/article/details/79997292
