Elasticsearch集群Red,分片无法恢复:cannot allocatebecause all found copies of the shard are either stale or c
問題
在多次重啟節點時,主副分片0出現了無法分配的問題。
elasticsearch 使用 Allocation IDs 的概念,這是區分不同分片的唯一標識(UUIDS)。
Allocation IDs存儲在 shard 級元信息中,每個 shard 都有自己的Allocation ID,同時集群級元信息中記錄了一個被認為是最新shard 的Allocation ID集合,這個集合稱為 in-sync allocation IDs。
如果由于網絡或者其他原因,主副shard沒有同步,那么副本的shard會將被從in-sync allocation IDs踢出。
猜想可能是出現了上述的問題。
解決
使用下面的命令進行查看:
GET /_cluster/allocation/explain
explain API 告訴我們為什么主分片處于未分配狀態,同時還提供了基于每個節點上的更詳細的分配信息。主節點在集群當前可用節點中無法找到同步的(in-sync)分片副本。
{"index" : "my_index","shard" : 0,"primary" : true,"current_state" : "unassigned","unassigned_info" : {"reason" : "NODE_LEFT","at" : "2017-01-26T09:20:24.054Z","last_allocation_status" : "no_valid_shard_copy"},"can_allocate" : "no_valid_shard_copy","allocate_explanation" : "cannot allocate because all found copies of the shard are either stale or corrupt","node_allocation_decisions" : [{"node_id" : "0ZJS1ffpRg-E_5L0Q0NnDA","node_name" : "data5-3","transport_address" : "192.168.1.108:9303","node_decision" : "no","store" : {"found": false}},{"node_id" : "0ZJS1ffpRg-E_5L0Q0NnDA","node_name" : "data5-3","transport_address" : "192.168.1.108:9303","node_decision" : "no","store" : {"found": false}},..............{"node_id" : "JSofMo_0TSieKnfI4HmEcQ","node_name" : "data6","transport_address" : "192.168.1.109:9300","node_decision" : "no","store" : {"in_sync" : false,"allocation_id" : "J3gygIvYT06tKSW5rYkGtw"}}] }cannot allocate because all found copies of the shard are either stale or corrupt
從上面的結果中,可以看到在data6節點上可用的分片副本是陳舊的( store.in_sync = false )。啟動擁有in-sync 分片副本的那個節點將使集群重新變為 green。如果那個節點永遠都回來了呢?
reroute API 提供了一個子命令 allocate_stale_primary ,用于將一個陳舊的分片分配為主分片。使用此命令意味著丟失給定分片副本中缺少的數據。如果同步分片只是暫時不可用,使用此命令意味著在同步副本中最近更新的數據。應該把它看作是使群集至少運行一些數據的最后一種措施。在所有分片副本都不存在的情況下,還可以強制Elasticsearch使用空分片副本分配主分片,這意味著丟失與該分片相關聯的所有先前數據。 不言而喻,allocate_empty_primary 命令只能用于最糟糕的情況,其含義很好理解。
使用命令進行恢復:
POST _cluster/reroute?pretty {"commands": [{"allocate_stale_primary": {"index": "my_index","shard": 0,"node": "data6","accept_data_loss": true}}] } 與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的Elasticsearch集群Red,分片无法恢复:cannot allocatebecause all found copies of the shard are either stale or c的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 6 期免息:iQOO Neo8 手机 1
- 下一篇: centos7磁盘挂载