RBD快照灾备方案

时间:2022-07-22
本文章向大家介绍RBD快照灾备方案,主要内容包括其使用实例、应用技巧、基本知识点总结和需要注意事项,具有一定的参考价值,需要的朋友可以参考一下。

一、说明

从主集群定期的导出最近两个快照之差,然后导入到备集群。

二、Ceph生成差量文件的方式

2.1 导出某个image从创建到此刻的变化

2.1.1 导出快照

rbd export-diff test_pool/test_image testimage_now

2.1.2 导入快照

rbd import-diff testimage_now test_pool/test_image

2.1.3 流程图

2.2 导出image从创建到快照时刻的变化

2.2.1 创建快照

echo "v0.log" >> /mnt/ceph_lihang/v0.log
 
#create snap v1
rbd snap create test_pool/test_image@v1
echo "v1.log" >> /mnt/ceph_lihang/v1.log
 
#create snap v2
rbd snap create test_pool/test_image@v2
echo "v2.log" >> /mnt/ceph_lihang/v2.log
 
#create snap v3
rbd snap create test_pool/test_image@v3
echo "v3.log" >> /mnt/ceph_lihang/v3.log
 
#create snap v4
rbd snap create test_pool/test_image@v4
echo "v4.log" >> /mnt/ceph_lihang/v4.log
 
#create snap v5
rbd snap create test_pool/test_image@v5
echo "v5.log" >> /mnt/ceph_lihang/v5.log

2.2.2 导出快照

#export snap v1
rbd export-diff  test_pool/test_image@v1 testimage_v1
 
#export snap v2
rbd export-diff  test_pool/test_image@v2 testimage_v2
 
#export snap v3
rbd export-diff  test_pool/test_image@v3 testimage_v3
 
#export snap v4
rbd export-diff  test_pool/test_image@v4 testimage_v4
 
#export snap v5
rbd export-diff  test_pool/test_image@v5 testimage_v5

2.2.3 导入快照

#import snap v1
rbd import-diff testimage_v1 test_pool/test_image
 
#import snap v2
rbd import-diff testimage_v2 test_pool/test_image
 
#import snap v3
rbd import-diff testimage_v3 test_pool/test_image
 
#import snap v4
rbd import-diff testimage_v4 test_pool/test_image
 
#import snap v5
rbd import-diff testimage_v5 test_pool/test_image

2.2.4 流程图

2.3 导出image两个快照之间的差异变化

2.3.1 创建快照

echo "v0.log" >> /mnt/ceph_lihang/v0.log
 
#create snap v1
rbd snap create test_pool/test_image@v1
echo "v1.log" >> /mnt/ceph_lihang/v1.log
 
#create snap v2
rbd snap create test_pool/test_image@v2
echo "v2.log" >> /mnt/ceph_lihang/v2.log
 
#create snap v3
rbd snap create test_pool/test_image@v3
echo "v3.log" >> /mnt/ceph_lihang/v3.log
 
#create snap v4
rbd snap create test_pool/test_image@v4
echo "v4.log" >> /mnt/ceph_lihang/v4.log
 
#create snap v5
rbd snap create test_pool/test_image@v5
echo "v5.log" >> /mnt/ceph_lihang/v5.log

2.3.2 导出快照

#首次导出 export v1
rbd export-diff  test_pool/test_image@v1 testimage_v1
 
#export (snap v1 - snap v2)
rbd export-diff  test_pool/test_image@v2 --from-snap v1 testimage_v1_v2
 
#export (snap v2 - snap v3)
rbd export-diff  test_pool/test_image@v3 --from-snap v2 testimage_v2_v3
 
#export (snap v3 - snap v4)
rbd export-diff  test_pool/test_image@v4 --from-snap v3 testimage_v3_v4
 
#export (snap v4 - snap v5)
rbd export-diff  test_pool/test_image@v5 --from-snap v4 testimage_v4_v5

2.3.3 导入快照

#import snap v1
rbd import-diff testimage_v1 test_pool/test_image
 
#import (snap v1 - snap v2)
rbd import-diff testimage_v1_v2 test_pool/test_image
 
#import (snap v2 - snap v3)
rbd import-diff testimage_v2_v3 test_pool/test_image
 
#import (snap v3 - snap v4)
rbd import-diff testimage_v3_v4 test_pool/test_image
 
#import (snap v4 - snap v5)
rbd import-diff testimage_v4_v5 test_pool/test_image

2.3.4 流程图

三、总结

最终选择方案三定期的备份增量文件,达到增量备份。

3.1 备份流程图

3.1.2 首次备份

1.在主集群创建Image的快照 2.导出主集群Image的全量快照 3.将导出的全量快照文件传输到备集群 4.备集群创建对应的pool/image 5.导入全量快照文件到备集群中 6.完成备份

3.1.3 非首次备份

1.在主集群查找最近的快照文件,并且确认备集群是否存在同名的快照 2.在主集群创建Image的快照 3.导出最近快照文件和刚创建快照文件的差量文件。(导出每次diff,实现增量备份) 4.将导出的差量快照文件传输到备集群 5.导入全量快照文件到备集群中 6.完成备份

3.2 总结

  • 定期的每天导出增量的数据文件,在做恢复的时候,就从第一个快照导入,然后按顺序导入增量的快照即可。
  • 定期做一个快照,导出完整的快照数据,以防中间的增量快照漏了。
  • 定期清理快照