我有一个ES集群,其中的pod有时会出现故障。
我检查了群集的运行状况,发现群集中有太多未分配的分片
{
"cluster_name" : "elasticsearch",
"status" : "red",
"timed_out" : false,
"number_of_nodes" : 5,
"number_of_data_nodes" : 2,
"active_primary_shards" : 274,
"active_shards" : 274,
"relocating_shards" : 0,
"initializing_shards" : 8,
"unassigned_shards" : 8568,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 16,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 56344,
"active_shards_percent_as_number" : 3.096045197740113
}
我尝试使用命令
删除未分配的分片curl -X GET 'elasticsearch-qna:9200/_cat/shards?pretty' | grep UNASSIGNED | awk {'print $1'} | xargs -i curl -XDELETE 'elasticsearch-qna:9200/{}'
但是,尝试删除表单时出现“找不到索引异常”。
{
"acknowledged" : true
}
{
"error" : {
"root_cause" : [
{
"type" : "index_not_found_exception",
"reason" : "no such index",
"index_uuid" : "_na_",
"resource.type" : "index_or_alias",
"resource.id" : "ResourceID",
"index" : "en-data-service"
}
],
"type" : "index_not_found_exception",
"reason" : "no such index",
"index_uuid" : "_na_",
"resource.type" : "index_or_alias",
"resource.id" : "NA",
"index" : "en-data-service"
},
"status" : 404
}
从JSON中删除了资源ID和索引。
任何帮助将不胜感激。
答案 0 :(得分:0)
我认为问题出在使用xargs。 请使用此解决方案,让我知道它是否有效。
curl -X GET 'elasticsearch-qna:9200/_cat/indices?pretty' | grep -i red | awk 'print $3'> indices-for-delete
for i in `cat indices-for-delete` ; do echo $i ; curl -XDELETE 'elasticsearch-qna:9200/$i' ; done
请注意,我将_cat / shards更改为_cat / indices,并尝试查找不是未分配的碎片的红色索引。因为未分配的副本可能存在未分配的分片。