【问题标题】:Restore elasticsearch cluster onto another cluster将 elasticsearch 集群恢复到另一个集群
【发布时间】:2021-11-01 12:08:04
【问题描述】:

您好,我有 3 个节点 elasticsearch 集群(源),我有快照调用 从源集群获取的快照 1 我还有另一个 6 节点弹性搜索集群(目标)集群

当我使用此命令从快照 1 恢复我的目标集群时

curl -X POST -u elastic:321 "192.168.2.15:9200/snapshot/snapshot_repository/snapshot-1/_restore?pretty" -H 'Content-Type: application/json' -d'

> {
> "indices": "*",
> "ignore_unavailable": true,
> "include_global_state": false,
> "rename_pattern": ".security(.+)",
> "rename_replacement": "delete_$1",
> "include_aliases": false
> }
> '
{

我得到了这个错误

"error" : {

"root_cause" : [

  {

    "type" : "snapshot_restore_exception",

    "reason" : "[snapshot:snapshot-1 yjg/mHsYhycHQsKiEhWVhBywxQ] cannot restore index [.ilm-history-0003] 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"

  }


如您所见,索引 .ilm-history-0003 已存在于集群中,但我如何仅使用 1 个 rename_pattern 对 security、.ilm、.slm、.transfrom 索引进行重命名替换? 喜欢这个

"rename_pattern": ".security(.+)",

【问题讨论】:

    标签: elasticsearch


    【解决方案1】:

    根据我的经验,重命名模式不需要太花哨,因为您可能会

    a) 删除索引(正如您的重命名模式所建议的那样)或

    b) 将数据从恢复的索引重新索引到新的索引。在这种情况下,恢复索引的命名无关紧要。

    这就是的建议:

    使用以下重命名模式来包含所有索引。同样,根据我的经验,您的首要目标是恢复旧数据。之后,您必须管理重新索引等。

    POST /_snapshot/REPOSITORY_NAME/SNAPSHOT_NAME/_restore
    {
      "indices": "*",
      "ignore_unavailable": true,
      "include_aliases": false,
      "include_global_state": false,
      "rename_pattern": "(.+)",
      "rename_replacement": "restored_$1"
    }
    

    这会将restored_ 添加到实际索引名称之前,从而生成以下恢复的索引:

    • restored_security
    • 已恢复_.ilm*
    • 已恢复_.slm*
    • restored_.transfrom*

    希望能帮到你。

    【讨论】:

      【解决方案2】:

      用这种方法解决

      curl -X POST -u elastic:321 "192.168.2.15:9200/snapshot/snapshot_repository/snapshot-1/_restore?pretty" -H 'Content-Type: application/json' -d'
      

      有回应:

      {
        "indices": "*,-.slm*,-,ilm*,-.transfrom*,-security*",
        "ignore_unavailable": true,
        "include_global_state": false,
        "include_aliases": false
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2013-07-26
        • 2020-06-15
        • 2016-12-07
        • 2015-12-10
        • 1970-01-01
        • 2014-06-26
        • 1970-01-01
        • 2022-07-11
        相关资源
        最近更新 更多