elasticsearch 备份恢复步骤

1、查看仓库,

bash 复制代码
GET _snapshot

返回, 仓库名是aliyun_auto_snapshot

bash 复制代码
{
  "aliyun_auto_snapshot" : {
    "type" : "oss",
    "settings" : {
      "compress" : "true",
      "base_path" : "fb632b-1241148226163200/xxx",
      "endpoint" : "http://oss-cn-shenzhen-internal.aliyuncs.com"
    }
  }
}

2、查看当前备份文件

bash 复制代码
GET /_cat/snapshots/aliyun_auto_snapshot?v

返回

bash 复制代码
id                                      status start_epoch start_time end_epoch  end_time duration indices successful_shards failed_shards total_shards
es-xxx_20241206030009 SUCCESS 1733425210  19:00:10   1733425218 19:00:18     7.9s       4                13             0           13
es-xxx_20241207030008 SUCCESS 1733511609  19:00:09   1733511615 19:00:15     6.6s       4   

3、备份最新数据。排除系统索引。

bash 复制代码
PUT _snapshot/aliyun_auto_snapshot/aliyun_auto_snapshot_2024012121614
{"indices":"*,-.*"}

4、查看备份

bash 复制代码
GET /_cat/snapshots/aliyun_auto_snapshot?v

5、恢复备份的方法,恢复之前关闭索引(如果是增量恢复),或者清空索引数据。

bash 复制代码
POST _snapshot/aliyun_auto_snapshot/aliyun_auto_snapshot_2024012121614/_restore 
{"indices":"*,-.*","ignore_unavailable":"true"}

如果是增量恢复关闭索引的方法

bash 复制代码
POST *,-.*/_close  

如果需要把备份备份到自定义仓库中,以oss为例子,创建方法

bash 复制代码
PUT _snapshot/my_es_snapshot_from_oss/
{
    "type": "oss",
    "settings": {
        "endpoint": "oss-cn-shenzhen-internal.aliyuncs.com",
        "access_key_id": "xxx",
        "secret_access_key": "xxx",
        "bucket": "es-snapshot-qianyi",
        "compress": true,
        "chunk_size": "500mb",
        "base_path": "my_es_snapshot_from_oss/"
    }
}

加速快照恢复的方法

bash 复制代码
GET _cluster/settings?flat_settings&include_defaults


PUT _cluster/settings
{
  "persistent": {
    "cluster.routing.allocation.node_concurrent_recoveries": "4",
    "indices.recovery.max_bytes_per_sec": "100mb"
  }
}
bash 复制代码
修改分片迁移的配置,以便在rebalance或者recovery时更快恢复集群。

indices.recovery.max_bytes_per_sec:恢复时单个节点的总进出流量限制。(默认40mb)

indices.recovery.max_concurrent_file_chunks:恢复时可并发拷贝的文件块数量。(默认2)

cluster.routing.allocation.cluster_concurrent_rebalance:整个集群范围内允许同时rebalance的shard数。(默认2)

cluster.routing.allocation.node_initial_primaries_recoveries:单个节点主分片并行恢复的数据。(默认4)

cluster.routing.allocation.node_concurrent_recoveries:单个节点允许同时接收、传出恢复的shard数,(默认2)
相关推荐
PaperData11 分钟前
2000-2023年地级市数字基础设施评价指标体系
大数据·网络·数据库·人工智能·数据分析·经管
Blockchain Learning22 分钟前
去中心化身份(DID)模型解析:区块链如何重塑身份管理?
大数据·去中心化·区块链
有一个好名字1 小时前
Agent Loop —— 一切从那个 while 循环开始
前端·javascript·chrome
xcbrand1 小时前
政府事业机构品牌策划公司哪家可靠
大数据·人工智能·python
程序鉴定师1 小时前
如何选择合适的深圳小程序开发公司?
大数据·小程序
x-cmd1 小时前
agent-browser 源码分析(四):Chrome 进程管理与多 Backend
chrome·appium·进程管理·webdriver·agent-browser
晨启AI2 小时前
GPT-5.5 来了!OpenAI 最新提示词指南深度解读
大数据·人工智能·ai·提示词
地球资源数据云2 小时前
中国陆地生态系统主要植物功能特征空间分布数据
大数据·数据库·人工智能·机器学习
金智维科技官方2 小时前
AI智能体在7×24客服场景中的真实表现评估
大数据·人工智能·ai·rpa·智能体
WL_Aurora3 小时前
MapReduce经典例题【第二期】
大数据·mapreduce