关于数据库:KunlunDB备份和恢复

6次阅读

共计 3029 个字符,预计需要花费 8 分钟才能阅读完成。

全局一致性物理备份 & 复原基本概念

物理备份:数据库的物理文件(数据文件,交易日志文件,参数文件)的备份。物理备份又能够分为脱机备份(冷备份)和联机备份(热备份)。

KunlunDB 集群反对联机备份,备份过程中,数据库处于运行状态,应用程序读写不会阻塞,因为备份操作产生在主从节点的从节点上,对应用程序的性能根本没有影响。

一、备份复原架构

备份复原指标:存储集群和元数据集群

备份复原调度核心:Cluster manager

备份数据保留:备份存储池

集群备份执行单元:Node Manager

二、基本原理

KunlunDB 集群备份 & 复原工作原理

2.1 备份数据指标

在 kunlunDB 分布式数据库集群中的元数据集群寄存整个集群的节点信息、表构造信息、事务信息、备份复原信息等,是集群失常运行的根底,元数据集群采纳一主两从的高可用架构。

存储集群负责寄存业务数据,数据分布在数据分片中(shards),存储集群由多个分片组成,每个分片有多个正本。

计算节点的数据是元数据集群数据的子集,计算节点自身无状态,不须要独自备份。

全局一致性备份能够对整个集群的数据全副备份(备份全副的元数据和存储集群数据),也能够只备份局部数据,如只备份某个存储分片。

2.2 全局一致性备份和复原

备份:在执行备份的开始阶段,备份复原管理器从元数据库获取整个集群的全局事务信息,而后启动备份,对每个备份指标,同时须要备份指标数据的数据文件和交易日志。数据库文件和备份期间的交易日志被集中寄存到备份资源池(存储),所有文件复制实现后,备份完结。备份信息记录在元数据库中。备份期间集群失常运行,不须要停业务。

复原:在执行复原的开始阶段,备份复原管理器从元数据库获取以后可用的备份信息,而后从备份资源池复制数据到复原的指标,数据复制实现后,依据交易日志执行事务的回滚或前滚,从而将整个集群复原到统一状态。

2.3 备份类型

齐全备份:备份备份指标的全副数据(数据文件及交易日志),是增量备份的根底。

增量备份:备份上次备份以来的增量数据及交易日志。

全副备份:备份整个集群的数据(元数据及全副的存储集群数据)。

局部备份:只备份某个分片的数据。

2.4 复原类型

全副复原:复原整个集群

局部复原:只复原某个分片

基于工夫的复原:复原到某个工夫点

基于事务的复原:基于某个事务编号的复原

三、执行步骤

备份

3.1 设置备份策略

确定备份对象,备份类型,备份指标存储筹备。

3.2 执行备份

通过命令行或 UI(kunlunDB 提供 Web 界面)调度备份

[kunlun@kunlun-test6 util]$ backup --help
Usage of backup:
  -HdfsNameNodeService string
        specify the hdfs name node service, hdfs://ip:port
  -backuptype string
        back up storage node or 'compute' node,default is 'storage' (default "storage")
  -clustername string
        name of the cluster to be backuped
  -coldstoragetype string
        specify the coldback storage type: hdfs .. (default "hdfs")
  -etcfile string
        path to the etc file of the mysql instance to be backuped,
        if port is specified and the related instance is running,
        the tool will determine the etcfile path
  -port string
        the port of mysql or postgresql instance which to be backuped
  -shardname string
        name of the current shard
  -workdir string
        where store the backup data locally for temp use (default "./data")

3.3 查看备份后果,确认备份胜利

复原

3.4 设置复原策略

确定复原对象,备份类型,备份指标存储筹备

3.5 执行复原

复原操作指令:

[kunlun@kunlun-test6 util]$ restore --help
Usage of restore:
  -HdfsNameNodeService string
        specify the hdfs name node service, hdfs://ip:port
  -enable-globalconsistent
        whether restore the new mysql under global consistent restrict
  -metaclusterconnstr string
        current meta cluster connection string e.g. user:pass@tcp(ip:port)/mysql
  -mysqletcfile string
        etc file of the mysql which to be restored, if port is provied and mysqld is alive ,no need
  -origclustername string
        source cluster name to be restored or backuped
  -origmetaclusterconnstr string
        orig meta cluster connection string e.g. user:pass@tcp(ip:port)/mysql
  -origshardname string
        source shard name to be restored
  -port string
        the port of mysql/postgresql instance which to be restored and needed to be running state
  -restoretime string
        time point the new mysql restore to
  -restoretype string
        restore storage node or 'compute' node,default is 'storage' (default "storage")
  -workdir string
        temporary work path to store the coldback or other type files if needed (default "./data")

3.6 查看复原后果,确认复原胜利

四、集群备份复原演示

演示如何在 kunlunDB UI 界面做集群的备份和复原

环境信息:

须要备份的集群由一个计算节点,一个 shard (每个 shard 由一主两从三个节点组成)及元数据集群组成(一主两从)

备份前数据状态:

第一步:启动备份

备份操作:点击集群治理界面的备份按钮,启动备份。

第二步:查看备份状态

依据执行工夫,备份胜利后,能够看到:backupcluster succeed 信息。

第三步:复原集群

抉择复原的工夫点,而后确定复原。

集群进入复原状态:

复原实现后,零碎会在可用的资源区内创立一个新的集群,并且复原备份的数据。

复原状态:

复原的集群:

进入复原的集群计算节点,查看复原的数据:

集群复原后,相应的数据也正确复原。

*KunlunDB 我的项目已开源

【GitHub:】
https://github.com/zettadb

【Gitee:】
https://gitee.com/zettadb

END

正文完
 0