最近 维护的公司的集群 出现过几次不健康的分片 现在整理下 处理过程如下 (大佬不要喷,提升都是点滴积累)
首先看下集群有几个分片不正常

curl -XGET 'http://10.230.129.207:9200/_cat/health?v&pretty'

检查具体是那些分片有问题

curl -XGET 'http://10.230.129.207:9200/_cat/shards?v&pretty' | grep UNASSIGNED

查看分片不正常的原因

curl noahes.isec.oa.com/_cluster/allocation/explain?pretty -d '{"index":"index-name","shard":0,"primary":true}'

不过大部分原因的处理方式都是一样重新分配

curl -XPOST http://10.230.129.207:9200/_cluster/reroute -d "{\"commands\" : [{\"allocate_stale_primary\" : {\"index\" : \"text\", \"shard\" : 8,\"node\" : \"10.230.129.207\",\"accept_data_loss\":true}}]}"

这都是一些基本套路
下面补充一些最近得到的参数