当前位置: 首页 > news >正文

Elasticsearch 索引备份

快照仓库

注册快照存储库

POST _snapshot/my_backup 
{"type": "fs", "settings": {"location": "/mount/backups/my_backup","max_snapshot_bytes_per_sec" : "50mb", "max_restore_bytes_per_sec" : "50mb"}
}POST _snapshot/search_user_v6
{"type": "fs","settings": {"location": "search_user_v6","max_restore_bytes_per_sec": "60mb","compress": "true","max_snapshot_bytes_per_sec": "60mb"}}
  • my_backup 仓库的名字
  • max_snapshot_bytes_per_sec:当快照数据进入仓库时,这个参数控制这个过程的限流情况。默认是每秒 20mb
  • max_restore_bytes_per_sec:当从仓库恢复数据时,这个参数控制什么时候恢复过程会被限流以保障你的网络不会被占满。默认是每秒 20mb

查看所有快照仓库

GET /_snapshot/_all

删除快照仓库

DELETE /_snapshot/my_repository

快照

创建快照

备份单个索引

备份 index_1,index_2 索引到my_repository 仓库下,命名为:status_v7_snapshot

PUT /_snapshot/my_repository/status_v7_snapshot
{"indices":"index_1,index_2","ignore_unavailable":true,"include_global_state":true
}

备份所有索引

备份所有打开的索引到 my_backup 仓库下命名为:snapshot_1

PUT _snapshot/my_backup/snapshot_1?wait_for_completion=true
  • wait_for_completion:这个会阻塞调用直到快照完成。注意大型快照会花很长时间才返回。

查看备份信息

GET _snapshot/my_backup/snapshot_2

返回结果

{"snapshots": [{"snapshot": "snapshot_1","indices": [".marvel_2014_28_10","index1","index2"],"state": "SUCCESS","start_time": "2014-09-02T13:01:43.115Z","start_time_in_millis": 1409662903115,"end_time": "2014-09-02T13:01:43.439Z","end_time_in_millis": 1409662903439,"duration_in_millis": 324,"failures": [],"shards": {"total": 10,"failed": 0,"successful": 10}}]
}

查看 my_backup 仓库中所有快照

GET _snapshot/my_backup/_all

删除快照

删除 my_backup 仓库中 snapshot_2 备份

DELETE _snapshot/my_backup/snapshot_2

监控快照进度

_status API 立刻返回

GET _snapshot/my_backup/snapshot_3/_status

返回结果

{"snapshots": [{"snapshot": "snapshot_3","repository": "my_backup",
1.         "state": "IN_PROGRESS", "shards_stats": {"initializing": 0,
2.            "started": 1, "finalizing": 0,"done": 4,"failed": 0,"total": 5},"stats": {"number_of_files": 5,"processed_files": 5,"total_size_in_bytes": 1792,"processed_size_in_bytes": 1792,"start_time_in_millis": 1409663054859,"time_in_millis": 64},"indices": {"index_3": {"shards_stats": {"initializing": 0,"started": 0,"finalizing": 0,"done": 5,"failed": 0,"total": 5},"stats": {"number_of_files": 5,"processed_files": 5,"total_size_in_bytes": 1792,"processed_size_in_bytes": 1792,"start_time_in_millis": 1409663054859,"time_in_millis": 64},"shards": {"0": {"stage": "DONE","stats": {"number_of_files": 1,"processed_files": 1,"total_size_in_bytes": 514,"processed_size_in_bytes": 514,"start_time_in_millis": 1409663054862,"time_in_millis": 22}},...
  1. 一个正在运行的快照会显示 IN_PROGRESS 作为状态。
  2. 这个特定快照有一个分片还在传输(另外四个已经完成)。

取消一个快照

取消正在备份的快照:直接删除就可以了。

DELETE _snapshot/my_backup/snapshot_3

从快照恢复

恢复

默认将快照里所有的索引都恢复

POST _snapshot/my_backup/snapshot_1/_restore

指定恢复索引

这个会恢复 index_1 到你及群里,但是重命名成了 restored_index_1

POST /_snapshot/my_backup/snapshot_1/_restore
{
1    "indices": "index_1", 
2    "rename_pattern": "index_(.+)", 
3    "rename_replacement": "restored_index_$1" 
}
  1. 只恢复 index_1 索引,忽略其他索引。
  2. 模式能匹配上的正在恢复的索引。
  3. 然后把它们重命名成替代的模式。

监控

监控 restored_index_3 索引恢复情况

GET restored_index_3/_recovery

查看你集群里所有索引

GET /_recovery/

返回结果

{"restored_index_3" : {"shards" : [ {"id" : 0,
1      "type" : "snapshot", "stage" : "index","primary" : true,"start_time" : "2014-02-24T12:15:59.716","stop_time" : 0,"total_time_in_millis" : 175576,
2      "source" : { "repository" : "my_backup","snapshot" : "snapshot_3","index" : "restored_index_3"},"target" : {"id" : "ryqJ5lO5S4-lSFbGntkEkg","hostname" : "my.fqdn","ip" : "10.0.1.7","name" : "my_es_node"},"index" : {"files" : {"total" : 73,"reused" : 0,"recovered" : 69,
3          "percent" : "94.5%" },"bytes" : {"total" : 79063092,"reused" : 0,"recovered" : 68891939,"percent" : "87.1%"},"total_time_in_millis" : 0},"translog" : {"recovered" : 0,"total_time_in_millis" : 0},"start" : {"check_index_time" : 0,"total_time_in_millis" : 0}} ]}
}
  1. type 字段告诉你恢复的本质;这个分片是在从一个快照恢复。
  2. source 哈希描述了作为恢复来源的特定快照和仓库。
  3. percent 字段让你对恢复的状态有个概念。这个特定分片目前已经恢复了 94% 的文件;它就快完成了。

取消恢复

取消正在备份的快照:直接删除就可以了。

DELETE /restored_index_3

http://www.mrgr.cn/news/46933.html

相关文章:

  • 神经网络
  • ctf竞赛
  • 【Unity-Animator】通过 StateMachineBehaviour 实现回调
  • Vue进阶之AI智能助手项目(二)——ChatGPT的调用和开发
  • 《Java核心技术II》网络使用telnet
  • 系统思考—战略共识
  • python xml的读取和写入
  • 【centos 虚拟机】kvm权限报错解决 gid:107
  • Unity3D 动画回调函数详解
  • 怎么把mov格式的视频转换mp4?视频格式转换就看这5招!(值得收藏)
  • 喜讯!华秋电子宣布完成新一轮3.1亿元融资
  • 引领数字化转型新潮流:The Open Group 2024生态系统架构·可持续发展年度大会邀您共襄盛举
  • 从零开始搭建一个node.js后端服务项目
  • 二叉树搜索
  • 解决 MySQL 连接数过多导致的 SQLNonTransientConnectionException 问题
  • 负载均衡(Load Balancing)
  • 华为OD机试真题-最佳对手-2024年OD统一考试(E卷)
  • 【docker】存储之目录挂载和卷映射
  • mysql主从配置
  • SpringCloud 集成 OpenFeign 实战指南
  • 数据库迁移中的权限问题及解决方法——以Error 1142为例
  • 深入理解HTTP Cookie
  • FineReport报表查询初始化直接显示表头内容
  • 基于SSM的民宿管理系统【附源码】
  • 基于SpringBoot vue的CSGO赛事管理系统设计与实现
  • Python 静态方法与类方法详解