备份恢复对接 CDM

概要描述

本文档是基于 CDM 存储的平凯数据库使用存储备份和恢复功能的操作文档。

环境准备

  • IDC 环境下的平凯数据库集群
  • CDM 系统
  • tiup、br、pd-ctl 等二进制工具包

备份操作流程

停止 GC,查询并且停止调度,获取当前集群的一致性 TS。

  1. 查询并记录当前集群的调度参数。

    pd-ctl --pd=${PD}:${port} config show | grep merge-schedule-limit pd-ctl --pd=${PD}:${port} config show | grep region-schedule-limit pd-ctl --pd=${PD}:${port} config show | grep replica-schedule-limit pd-ctl --pd=${PD}:${port} config show | grep hot-region-schedule-limit
  2. 停止当前集群的调度。

    pd-ctl --pd=${PD}:${port} config set merge-schedule-limit 0 pd-ctl --pd=${PD}:${port} config set region-schedule-limit 0 pd-ctl --pd=${PD}:${port} config set replica-schedule-limit 0 pd-ctl --pd=${PD}:${port} config set hot-region-schedule-limit 0
  3. 关闭集群 GC。

    SET GLOBAL tidb_gc_enable=FALSE;
  4. 获取集群的 resolved-ts。

    ./pd-ctl min-resolved-ts -u ${PD}:${port}
  5. CBT 备份。

    使用 CDM 系统对 TiKV 依赖的存储做数据快照。

  6. 备份集群恢复 GC。

    SET GLOBAL tidb_gc_enable=TRUE;
  7. 备份集群恢复调度。

    ./pd-ctl --pd=${PD}:${port} config set merge-schedule-limit ${value} ./pd-ctl --pd=${PD}:${port} config set region-schedule-limit ${value} ./pd-ctl --pd=${PD}:${port} config set replica-schedule-limit ${value} ./pd-ctl --pd=${PD}:${port} config set hot-region-schedule-limit ${value}

恢复操作流程

  1. 部署全新集群,集群的 TOP 结构和备份集群一致。

    tiup cluster deploy ${restore-cluster} <version> <topology.yaml>
  2. 清空集群集群。

    tiup cluster clean ${restore-cluster} --all
  3. 启动 pd-server。

    tiup cluster start ${restore-cluster} -R pd
  4. 所有节点拷贝 TiKV 数据到数据目录。

    此步骤将备份阶段中 TiKV 存储的快照数据拷贝到恢复集群的 TiKV 节点上,或直接将快照数据挂载到 TiKV 节点。

  5. 设置 PD 进入 recover 模式。

    curl "${PD}:${port}/pd/api/v1/admin/cluster/markers/snapshot-recovering" -XPOST

    检查 recover 模式是否设置成功:

    curl "${PD}:${port}/pd/api/v1/admin/cluster/markers/snapshot-recovering"
  6. 启动 TiKV 集群。

    tiup cluster start ${restore-cluster} -R tikv
  7. 运行 br restore 将数据恢复到一致性点。

    ./br restore full --type=idc --pd=${PD}:${PORT} --skip-aws=true --send-credentials-to-tikv=false --restored-ts=${resolved-ts} --storage=${local_path} --check-requirements=false
  8. 退出 recovery 模式。

    curl "${PD}:${port}/pd/api/v1/admin/cluster/markers/snapshot-recovering" -XDELETE
  9. 重启 TiKV。

    tiup cluster restart ${restore-cluster} -R tikv
  10. 启动服务。

    tiup cluster start ${restore-cluster} -R tidb

到这里,集群的数据恢复操作完成。

使用限制条件

使用本功能的限制条件如下:

  • 当存储节点 TiKV 使用单个 Volumn(即日志和数据放在同一个卷上)时,功能没有问题。
  • 当存储节点 TiKV 上使用多个 Volumn(即日志和数据放置于不同的卷上)时,要求 CDM 系统可以对单点上的多个卷同时创建快照,即单点可以创建一致性快照。