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)
相关推荐
YangYang9YangYan16 小时前
2026高职大数据与会计专业学数据分析的技术价值分析
大数据·数据挖掘·数据分析
AI智能探索者1 天前
揭秘大数据领域特征工程的核心要点
大数据·ai
做cv的小昊1 天前
【TJU】信息检索与分析课程笔记和练习(8)(9)发现系统和全文获取、专利与知识产权基本知识
大数据·笔记·学习·全文检索·信息检索
AC赳赳老秦1 天前
DeepSeek 私有化部署避坑指南:敏感数据本地化处理与合规性检测详解
大数据·开发语言·数据库·人工智能·自动化·php·deepseek
C7211BA1 天前
通义灵码和Qoder的差异
大数据·人工智能
三不原则1 天前
银行 AIOps 实践拆解:金融级故障自愈体系如何搭建
大数据·运维
大厂技术总监下海1 天前
数据湖加速、实时数仓、统一查询层:Apache Doris 如何成为现代数据架构的“高性能中枢”?
大数据·数据库·算法·apache
新诺韦尔API1 天前
手机三要素验证不通过的原因?
大数据·智能手机·api
成长之路5141 天前
【数据集】分地市全社会用电量统计数据(2004-2022年)
大数据
InfiSight智睿视界1 天前
门店智能体技术如何破解美容美发连锁的“标准执行困境”
大数据·运维·人工智能