【问题标题】:Elasticsearch restore snapshot in a new single node clusterElasticsearch 在新的单节点集群中恢复快照
【发布时间】:2021-09-27 21:17:59
【问题描述】:

我已使用默认设置制作了快照:

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 的这些人即使是简单的备份恢复操作也设法过度复杂化。

我认为错误的索引是系统索引。如果是这样,我可以在创建系统索引之前恢复我的快照吗?

如何恢复我的快照?

弹性搜索 7.14.1


我也尝试过使用:

POST /_snapshot/backup/snapshot-2021.09.23/_restore
{
  "include_global_state":false,
  "feature_states":[]
}

但同样的错误显示。

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    如果您阅读了错误消息,应该很清楚:

    [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
    }
    

    但是既然我们说的是系统索引,就有点不一样了,你需要换一种方式,通过feature states恢复索引:

    POST /_snapshot/backup/snapshot-2021.09.23/_restore
    {
      "feature_states":[ "geoip" ]
    }
    

    为不同的用例增加灵活性并不过分复杂:-)

    【讨论】:

    • DELETE .geoip_databases 错误:illegal_argument_exception: Indices [.geoip_databases] use and access is reserved for system operationsclose op 的相同错误。越来越复杂:)
    • 也许我不明白。你想恢复那个索引还是跳过它,因为它是一个系统索引并且它是不允许的?你的目标是什么?
    • 我想将我的单节点es实例状态恢复到之前的快照状态。备份-删除-恢复。
    • 所以基本上,删除所有内容,然后使用全局状态和所有内容恢复快照......只是您能够删除除系统索引之外的所有索引。我说的对吗?
    • 我创建了一个没有数据的新 es 实例(与旧实例无关),并且想要恢复我的快照。
    【解决方案2】:

    已打开 github 问题:https://github.com/elastic/elasticsearch/issues/78320

    作为一种解决方法,我设法通过选择带有通配符的索引来恢复我的快照,以便它排除有问题的系统索引:

    POST /_snapshot/my_repository/snapshot_2/_restore?wait_for_completion=true
    {
      "indices": "my-index-*,my-other-index-*",
    }
    

    【讨论】:

      猜你喜欢
      • 2021-09-25
      • 2016-07-08
      • 1970-01-01
      • 2017-09-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-28
      • 1970-01-01
      相关资源
      最近更新 更多