• elasticsearch系列(六)备份


    快照备份

    1.创建文件仓库

    1.1 在$ELASTICSEARCH_HOME/config/elasticsearch.yaml中增加配置

    #这个路径elasticsearch必须有权限访问,这个路径是所有快照仓库的根路径

    path.repo: your_path

    1.2 调用rest api

    // nlp_defect是你仓库的名称

    put url/_snapshot/nlp_defect

    {

      "type": "fs",

      "settings": {

        "location": "/home/elasticsearch/nlp"

      }

    }

    回复

    {

      "acknowledged":true

    }

    表示创建成功

    2.配置仓库

    max_snapshot_bytes_per_sec

    当快照数据进入仓库时,这个参数控制这个过程的限流情况。默认是每秒20mb。

    max_restore_bytes_per_sec

    当从仓库恢复数据时,这个参数控制什么时候恢复过程会被限流以保障你的网络不会被占满。默认是每秒 `20mb`。

    post _snapshot/nlp_defect

    {

      "type": "fs",

      "settings": {

        "location": "/home/elasticsearch/nlp",

        "max_snapshot_bytes_per_sec": "50mb",

        "max_restore_bytes_per_sec": "50mb"

      }

    }

    回复

    {

      "acknowledged":true

    }

    表示修改成功

    3.指定备份索引

    put _snapshot/nlp_defect/snapshot_20170613

    {

      "indices": "defect"

    }

    回复

    {

      "accepted":true

    }

    表示快照成功

    备注

    可以增加wait_for_completion=true来阻塞至操作结束再返回

    4.查看快照信息

    get _snapshot/nlp_defect/snapshot_20170613

    回复

    {

        "snapshots": [

            {

                "snapshot": "snapshot_20170613",

                "uuid": "YKVFEaTjTE-7XWl27O38Ew",

                "version_id": 5020299,

                "version": "5.2.2",

                "indices": [

                    "defect"

                ],

                "state": "SUCCESS",

                "start_time": "2017-06-13T06:17:18.585Z",

                "start_time_in_millis": 1497334638585,

                "end_time": "2017-06-13T06:17:19.038Z",

                "end_time_in_millis": 1497334639038,

                "duration_in_millis": 453,

                "failures": [],

                "shards": {

                    "total": 5,

                    "failed": 0,

                    "successful": 5

                }

            }

        ]

    }

    5.删除快照

    delete _snapshot/nlp_defect/snapshot_20170613

    回复

    {

      "acknowledged":true

    }

    表示成功 

    快照恢复

    从快照恢复

    //默认恢复,恢复之后和之前的一样

    post _snapshot/nlp_defect/snapshot_20170613/_restore

    //辅助配置

    {

        "indices": "defect",

        "rename_pattern": "defect",

        "rename_replacement": "defect_1"

    }

    跨集群恢复

    原集群创建快照仓库repository,创建快照snapshot,完成后把snapshot拷贝至新集群,

    新集群创建快照仓库repository_1,repository_1与repository名称最好一样,把snapsot解压到该仓库下,执行,ok

    _snapshot/$repository_1/$snapshot/_restore

    当然也可以自定义配置,这个和同集群一样

    参考资料

    //官网备份指导

    https://www.elastic.co/guide/cn/elasticsearch/guide/cn/backing-up-your-cluster.html

    //官方恢复指导

    https://www.elastic.co/guide/cn/elasticsearch/guide/cn/_restoring_from_a_snapshot.html

  • 相关阅读:
    Cannot retrieve the latest commit at this time.
    Github上搭建个人博客记录
    ESPCN超分辨率汇总
    ESPCN处理彩色图像代码
    配置caffe过程中,生成解决方案出错。无法打开包括文件: “gpu/mxGPUArray.h”
    未定义变量 "caffe" 或类 "caffe.reset_all"
    windows下caffe安装配置、matlab接口
    Python3:pyecharts数据可视化插件
    Django:用户登录实例
    Django:提交表单时遇到403错误:CSRF verification failed
  • 原文地址:https://www.cnblogs.com/ulysses-you/p/7003022.html
Copyright © 2020-2023  润新知