[英]Elasticsearch restore snapshot in a new single node cluster
我使用默認設置制作了快照:
PUT /_snapshot/backup/%3Csnapshot-%7Bnow%2Fd%7D%3E?wait_for_completion=true
刪除舊數據,嘗試在新的 elasticsearch 單節點集群上恢復它:
POST /_snapshot/backup/snapshot-2021.09.23/_restore
,但出現錯誤:
"type" : "snapshot_restore_exception",
"reason" : "[backup:snapshot-2021.09.23/esJtA1MeRcenJbz3tkIL2A] cannot restore index [.geoip_databases] because an open index with same name already exists in the cluster. Either close or delete the existing index or restore the index under a different name by providing a rename pattern and replacement name"
我想做一個簡單的快照恢復...ES 的這些人設法使簡單的備份恢復操作過於復雜。
我認為錯誤的索引是系統索引。 如果是這樣,我可以在創建系統索引之前恢復我的快照嗎?
如何恢復我的快照?
Elasticsearch 7.14.1
我也試過使用:
POST /_snapshot/backup/snapshot-2021.09.23/_restore
{
"include_global_state":false,
"feature_states":[]
}
但同樣的錯誤顯示。
如果您閱讀錯誤消息,它應該很清楚:
[backup:snapshot-2021.09.23/esJtA1MeRcenJbz3tkIL2A] 無法恢復索引 [.geoip_databases]因為集群中已存在同名的開放索引。 關閉或刪除現有索引或通過提供重命名模式和替換名稱以不同的名稱恢復索引”
所以你有三個選擇:
A. 恢復前先刪除索引
DELETE index-name
POST /_snapshot/backup/snapshot-2021.09.23/_restore
B. 恢復前關閉索引,恢復完成后自動重新打開
POST index-name/_close
POST /_snapshot/backup/snapshot-2021.09.23/_restore
C. 以不同的名稱恢復索引
POST /_snapshot/backup/snapshot-2021.09.23/_restore
{
"indices": "index-name",
"ignore_unavailable": true,
"include_global_state": false,
"rename_pattern": "(.+)",
"rename_replacement": "$1_restored",
"include_aliases": false
}
但是由於我們談論的是系統索引,它有點不同,您需要以不同的方式進行並通過功能狀態恢復索引:
POST /_snapshot/backup/snapshot-2021.09.23/_restore
{
"feature_states":[ "geoip" ]
}
為不同的用例增加靈活性並不過分復雜:-)
開github issue: https://github.com/elastic/elasticsearch/issues/78320
作為一種解決方法,我設法通過選擇帶有通配符的索引來恢復我的快照,以便它排除有問題的系統索引:
POST /_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true
{
"indices": "my-index-*,my-other-index-*",
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.