【问题标题】:Elastic search snapshot restore another cluster弹性搜索快照恢复另一个集群
【发布时间】:2019-07-03 01:38:00
【问题描述】:

如何恢复弹性搜索快照另一个集群?没有 repository-s3、repository-hdfs、repository-azure、repository-gcs。

【问题讨论】:

    标签: elasticsearch kibana snapshot elasticsearch-plugin


    【解决方案1】:

    最后我找到了解决方案。它工作正常。请仔细阅读并执行。 如果您有任何问题,请联系我 waruna94kithruwan@gmail.com。

    我有两个弹性搜索集群。我想要将 elastic_01 数据迁移到 elastic_02。 我的意思是 elastic_01 快照恢复到 elastic_02。我们走吧。

    重要

    (01) 设置 elastic_01 快照设置

    $ curl -XPUT '/_snapshot/first_backup' -H 'Content-Type: application/json' -d '{ “类型”:“fs”, “设置”:{ "位置": "/home/snapshot/", “压缩”:真 } }'

    (2) 将快照位置添加到 elasticsearch.yml (elastic_01) 编辑 elasticsearch.yml 文件并添加此代码行并保存。

    $ path.repo: ["/home/snapshot/"]

    (03) 创建快照 (elastic_01)

    $ curl -XPUT "/_snapshot/first_backup/snapshot_1?wait_for_completion=true"

    (04) 设置 elastic_02 快照设置

    $ curl -XPUT '/_snapshot/first_backup' -H 'Content-Type: application/json' -d '{ “类型”:“fs”, “设置”:{ "位置": "/home/snapshot/", “压缩”:真 } }'

    (05) 将快照位置添加到 elasticsearch.yml (elastic_02) 编辑 elasticsearch.yml 文件并添加此代码行并保存。

    $ path.repo: ["/home/snapshot/"]

    (06) 创建快照 (elastic_02)

    $ curl -XPUT "/_snapshot/first_backup/snapshot_1?wait_for_completion=true"

    (07) 将 elastic_01 快照复制到 >>>> elastic_02

    • 删除 elastic_02 快照文件夹内容 $ rm -rf /home/snapshot/*
    • 将elastic_01快照文件夹内容复制到elastic_02快照文件夹

    (08) 列表快照

    $ curl -XGET '/_snapshot/first_backup/_all?pretty'

    • 它将显示备份索引和快照相关数据

    (09) 恢复弹性搜索快照

    $ curl -XPOST "/_snapshot/first_backup/snapshot_1/_restore?wait_for_completion=true"

    【讨论】:

      【解决方案2】:

      注意:我们需要将参数“include_global_state”设置为“true”以根据链接“https://www.elastic.co/guide/en/elasticsearch/client/curator/current/option_include_gs.html"”恢复模板

      curl -X POST "localhost:9200/_snapshot/my_backup/snapshot_1/_restore?pretty" -H 'Content-Type: application/json' -d' { “include_global_state”:真 } '

      { “接受”:真 }

      【讨论】:

        【解决方案3】:

        这个答案是弹性搜索7.14。因此,可以在 NFS 上托管快照存储库。由于您希望将一个集群的快照还原到另一个集群,因此您需要满足以下先决条件:

        1. 应该可以从源集群和目标集群访问 NFS。
        2. 源集群和目标集群的版本应该相同。目标集群最多可以比源集群高 1 个主要版本。例如:您可以恢复 5.x 快照。到 6.x 集群,但不是 7.x 集群。
        3. 确保共享 NFS 目录归 uid:gid = 1000:0(elasticsearch 用户)所有,并授予适当的权限(chmod -R 777 <appropriate NFS directory>elasticsearch 用户)

        现在,我将详细说明您复制数据可以采取的步骤。

        1. 在源集群上创建fs 类型的注册表:
        PUT http://10.29.61.189:9200/_snapshot/registry1
        {
            "type": "fs",
            "settings": {
                "location": "/usr/share/elasticsearch/snapshotrepo",
                "compress": true
            }
        }
        
        1. 在创建的注册表上拍摄快照:
        PUT http://10.29.61.189:9200/_snapshot/registry1/snapshot_1?wait_for_completion=true
            {
              "indices": "employee,manager",
              "ignore_unavailable": true,
              "include_global_state": false,
              "metadata": {
                "taken_by": "binita",
                "taken_because": "test snapshot restore"
              }
            }
        
        1. 在目标集群上创建url 类型的注册表。键入 url 将确保相同的注册表(就共享 NFS 路径而言)在目标集群中是只读的。目标集群只能恢复/读取快照信息,不能写入快照。

        输入http://10.29.59.165:9200/_snapshot/registry1

        {
          "type": "url",
          "settings": {
            "url": "file:/usr/share/elasticsearch/snapshotrepo"
          }
        } 
        
        1. 将从源集群(在第 2 步中)生成的快照恢复到目标集群。

        发布http://10.29.59.165:9200/_snapshot/registry1/snapshot_1/_restore

        更多信息,请参考:https://www.elastic.co/guide/en/elasticsearch/reference/current/snapshots-restore-snapshot.html

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2021-10-18
          • 1970-01-01
          • 1970-01-01
          • 2016-12-07
          相关资源
          最近更新 更多