現象
集羣有3個索引分片無法分配,查看原因:
{
"index": "brock**********************000_7",
"shard": 0,
"primary": true,
"current_state": "unassigned",
"unassigned_info": {
"reason": "DANGLING_INDEX_IMPORTED",
"at": "2020-05-05T22:32:38.904Z",
"last_allocation_status": "no_valid_shard_copy"
},
"can_allocate": "no_valid_shard_copy",
"allocate_explanation": "cannot allocate because a previous copy of the primary shard existed but can no longer be found on the nodes in the cluster",
"node_allocation_decisions": [ ... ]
分析
DANGLING_INDEX_IMPORTED:殭屍索引/懸空索引:磁盤中存在,而集羣狀態中不存在的索引;
github上關於懸空索引的文章,https://github.com/elastic/ela … 18250
可能產生原因:
- 直接在物理機上刪除了某個索引的UUID數據目錄;
- 有節點長時間離線,索引已經刪除了,但節點重新加入集羣后,還保存有這個索引的信息;
- 從別的集羣拷貝了一個索引的數據目錄到當前集羣;
- …
解決方案
1、在集羣中刪除殭屍索引;
2、如果步驟1執行後,殭屍索引又重新出現,則只能從物理機上硬刪了