我们线上项目的新闻搜索用的是es的搜索引擎,这两天突然发现一些新闻搜不到了,登上es的head插件页面看了一眼发现
集群不健康了,百度谷歌水军了一番,终于找到解决方案:
1.查看集群的健康状态:
curl -XGET 'http://localhost:9200/_cluster/health?pretty'
看到集群的状态是红色的
2.查看集群的整体情况
curl -XGET 'http://localhost:9200/_nodes/stats?pretty'
注意红框内的集群的id,下面脚本要用
3.重新分配节点
curl -XPOST 'localhost:9200/_cluster/reroute' -d '{
"commands" : [ {
"allocate" : {
"index" : "xxxx",
"shard" : 3,
"node" : "mHbd9k9bT_e06OieycC84A",
"allow_primary" : true
}
}
]
}'
其中index:索引的名字
shard:head中还存在的节点
node:就是刚才红框中的id
运行成功,查看head中的节点信息,正常使用