前言

  • 环境

    Elasticsearch 7.10.1
    ES 所在服务器操作系统为 Ubuntu 20.04
    Windows 服务器版本为 Windows Server 2019
  • 已将 Windows//172.31.19.143/es_snapshot 共享目录挂载到 ES 服务器的 /mnt/winshare 目录
  • Linux 挂载 Windows 共享目录参见: Ubuntu 20.04 读写 Windows 10 共享目录
  • 注意挂载目录时的 Linux 账号要用运行 Elasticsearch 的账号。如果不是 deb 包安装直接运行 Elasticsearch,账号不是 elasticsearch

修改 ES 服务配置

  • elasticsearch.yml 文件中添加如下配置,并重启 ES 服务

    path.repo:
    - /mnt/winshare

注册快照仓库

  • 官方文档: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/...

    PUT /_snapshot/my_backup
    {
    "type": "fs",
    "settings": {
      "location": "/mnt/winshare/es_snapshot"
    }
    }
  • 查看所有注册的快照仓库

    GET _snapshot/_all
  • 调整集群恢复分片速度和并发数

    PUT _cluster/settings
    {
    "transient": {
      "indices.recovery.max_bytes_per_sec": "200mb",  # 默认 40mb
      "cluster.routing.allocation.node_concurrent_recoveries": "5"    # 默认 2
    }
    }
  • 查看集群配置(包括默认配置)

    GET _cluster/settings?flat_settings&include_defaults

创建快照

  • 官方文档: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/...

    PUT /_snapshot/my_backup/snapshot_zt
    {
    "indices": "zt_product_doc_index_20210223_3"
    }
  • 查看一个my_backup仓库下的所有快照

    GET _snapshot/my_backup/_all
  • 查看 snapshot_zt 快照的概要状态

    GET _snapshot/my_backup/snapshot_zt
  • 查看 snapshot_zt 快照的详细状态

    GET _snapshot/my_backup/snapshot_zt/_status

恢复快照

  • 官方文档: https://www.elastic.co/guide/en/elasticsearch/reference/7.10/...

    POST /_snapshot/my_backup/snapshot_zt/_restore
    {
    "indices": "zt_product_doc_index_20210223_3",
    "index_settings": {
      "index.number_of_replicas": 0
    },
    "rename_pattern": "zt_product_doc_index_20210223_3",
    "rename_replacement": "zt_product_doc_index_20210223_3_restore"
    }
  • 增加副本

    PUT zt_product_doc_index_20210223_3_restore/_settings
    {
    "index.number_of_replicas" : "1"
    }
本文出自 qbit snap

qbit
268 声望279 粉丝