es实战-数据备份snapshot

2022-02-25  本文已影响0人  caster

灾备相关知识点

RPO:最多可能丢失的数据的时长,即我们可以将数据恢复到什么时候,并且越接近现在(崩溃/丢失点)越好。
RTO:从灾难发生到整个系统恢复正常所需要的最大时长。

好的RPO实现:频繁增量备份
好的RTO实现:加快从快照恢复数据速度

ES snapshot 注意事项

  1. 查看快照仓库下全部快照信息:
GET /_snapshot/test_backup/_all
  1. 查看快照仓库下正在制作快照信息:
GET /_snapshot/test_backup/_current
  1. 获取快照运行详细状态信息:
GET /_snapshot/_status
GET /_snapshot/test_backup/_status
GET /_snapshot/test_backup/snapshot_1/_status
  1. 查看 SLM 运行状态及计划:
GET /_slm/policy?human
  1. 立刻执行一次 SLM 计划:
POST _slm/policy/nightly-snapshots/_execute
  1. 使用删除快照 API 删除或取消快照制作:
DELETE /_snapshot/test_backup/my_snapshot
  1. 清理仓库删除无用快照文件:
POST /_snapshot/test_backup/_cleanup
  1. SLM 定期清理策略执行时间:每天凌晨5点执行一小时
PUT _cluster/settings
{
    "persistent": {
        "slm.retention_schedule": "0 0 21 * * ?",
        "slm.retention_duration":"1h"
    }
}
  1. 跨集群数据迁移只读集群配置:
PUT _snapshot/test_backup
{
    "type": "hdfs",
    "settings": {
        "path": "/user/quantum_social/es-snapshot/mz_bia_social/test_backup",
        "uri": "hdfs://10.11.1.1:8020",
        "readonly":true
    }
}
  1. 恢复快照到集群使用自定义索引名:
    将 my_snapshot 快照中的 caster 索引恢复为 test_caster 索引
POST /_snapshot/test_backup/my_snapshot/_restore
{
    "indices": "caster",
    "ignore_unavailable": true,
    "include_global_state": false,
    "rename_pattern": "(.+)",
    "rename_replacement": "test_$1",
    "include_aliases": false
}
  1. 查看索引的恢复状态
GET /caster/_recovery?human
GET /_cat/shards/caster?v&s=state&h=index,shard,p,state,node,unassigned.reason
GET /_cluster/allocation/explain //查看分片未恢复的原因

快照相关集群设置:

snapshot.max_concurrent_operations
快照创建和删除并发操作数限制

创建仓库时可配置参数:

max_snapshot_bytes_per_sec
节点级别快照制作速率限制,默认40mb。
max_restore_bytes_per_sec
节点级别快照恢复速率限制,默认无限制;同时受indices.recovery.max_bytes_per_sec参数影响,默认40mb,7集群当前配置120mb。
compress
是否压缩元数据,默认为false
readonly
是否设置存储库为只读,默认为false

restore 速度相关配置参数:

es 的 snapshot restore 操作由 snapshot 线程池控制的。这个线程池控制并发snapshot或者restore的线程的数量。一个shard需要绑定一个thread来进行操作。此线程池大小受3个因素影响:

FAQ:

上一篇 下一篇

猜你喜欢

热点阅读