线上有3台es组成集群,其他有两台非正常关机了,早上过来发现集群状态为红色,提示"24 UNASSIGNED shareds":
1)查看集群相关信息:
curl ‘localhost:9200/_nodes/process?pretty‘
记下这个node的id号;
2)然后找出UNASSIGNED 的相关信息,方便后续修改!
# curl -XGET http://localhost:9200/_cat/shards|grep UNASSIGNED
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 30528 100 30528 0 0 705k 0 --:--:-- --:--:-- --:--:-- 745k
graylog_83 1 p UNASSIGNED
graylog_83 1 r UNASSIGNED
graylog_83 0 p UNASSIGNED
graylog_83 0 r UNASSIGNED
graylog_82 1 p UNASSIGNED
graylog_82 1 r UNASSIGNED
graylog_85 2 p UNASSIGNED
graylog_85 2 r UNASSIGNED
graylog_85 1 p UNASSIGNED
graylog_85 1 r UNASSIGNED
graylog_84 0 p UNASSIGNED
graylog_84 0 r UNASSIGNED
graylog_87 1 p UNASSIGNED
graylog_87 1 r UNASSIGNED
graylog_86 3 p UNASSIGNED
graylog_86 3 r UNASSIGNED
graylog_86 1 p UNASSIGNED
graylog_86 1 r UNASSIGNED
graylog_89 3 p UNASSIGNED
graylog_89 3 r UNASSIGNED
graylog_88 1 p UNASSIGNED
graylog_88 1 r UNASSIGNED
graylog_88 0 p UNASSIGNED
graylog_88 0 r UNASSIGNED
3)然后依次修改以上UNASSIGNED ,命令为:
curl -XPOST ‘localhost:9200/_cluster/reroute‘ -d ‘{
"commands" : [ {
"allocate" : {
"index" : "graylog_83",
"shard" : 1,
"node" : "Auq82gfGQVWgOBw6S7ajRQ",
"allow_primary" : true
}
}]
}‘
PS:
index就是索引的名称:也就是graylog_88,graylog_86,graylog_87.....
node:就是在哪个节点上执行;
shared:分片的编号!