Ceph RBD Mirroring wang

1.​Ceph采用的是强一致性同步模型。
2.​RBD Mirror是Ceph Jewel版本引入的新功能,因此RBD Mirror要求Ceph版本为Jewel或后续版本。
3.​RBD Mirror是基于Journanling Feature来实现的。
4.RBD Mirror需要在备份端部署mirror守护进程。
5.I/O会写入主集群的Image Journal。
6.Journal写入成功后,RBD再把数据写入主集群回复响应。
7.备份集群的mirror进程发现主集群的Journal有更新后,从主集群的Journal读取数据,写入备份集群。
8.备份集群写入成功后,会更新主集群Journal中的元数据,表示该I/O的Journal已经同步完成。
9.主集群会定期检查,删除已经写入备份集群的Journal数据。
10.由于需要进行集群间通信,RBD Mirror守护线程必须能够同时连接两个Ceph集群。
11.每个Ceph集群只能运行一个RBD Mirror。
12.一旦同步出现脑裂情况,RBD Mirror将中止同步操作。
13.RBD Image journaling特性会顺序的记录发生的修改事件。
14.根据备份方式的不同,rbd-mirror可以在单个集群上或者伙伴的两个集群上运行。
15.​目前ceph支持两种模式的Mirroring,分别为pool或image。
16.​备份的RBD image存在两种状态:primary(镜像属性可以更改)或non-primary(镜像属性不可更改)。
17.当第一次对rbd镜像进行mirroring时,image自动晋升为primary。
18.内核3.10版本的rbd模块仅支持layering feature,不支持exclusive-lock和journaling feature。
19.journaling feature依赖于exclusive-lock feature。
20.在Ceph配置文件中增加如下配置所有的新镜像启用journaling:rbd default features = 125

# 创建用于同步的用户
# ceph auth get-or-create client.{username} mon 'profile rbd' osd 'profile rbd'
ceph auth get-or-create client.mirror mon 'profile rbd' osd 'profile rbd' --cluster local
ceph auth get-or-create client.mirror mon 'profile rbd' osd 'profile rbd' --cluster remore

# 管理RBD Mirror进程
systemctl enable ceph-rbd-mirror@rbd-mirror
systemctl restart ceph-rbd-mirror@rbd-mirror

# 启用RBD Mirroring功能
# rbd mirror pool enable {pool-name} {mode}
rbd --cluster local mirror pool enable image-pool pool  # 存储池模式
rbd --cluster remote mirror pool enable image-pool pool  # 存储池模式
rbd --cluster local mirror pool enable image-pool image  # 镜像模式
rbd --cluster remote mirror pool enable image-pool image  # 镜像模式

# 禁用RBD Mirroring功能
# rbd mirror pool disable {pool-name}
rbd --cluster local mirror pool disable image-pool
rbd --cluster remote mirror pool disable image-pool

# 增加Cluster Peer
# rbd mirror pool peer add {pool-name} {client-name}@{cluster-name}
rbd --cluster local mirror pool peer add image-pool client.mirror@remote
rbd --cluster remote mirror pool peer add image-pool client.mirror@local

# 删除Cluster Peer
# rbd mirror pool peer remove {pool-name} {peer-uuid}
rbd --cluster local mirror pool peer remove image-pool 5f450171-07c3-4c81-9450-4216a394bb6f
rbd --cluster remote mirror pool peer remove image-pool f28bcf3d-60bc-4f56-814c-1d1673d747ee

# 启用Journaling特性
rbd create image-pool/image-1 --image-feature exclusive-lock,journaling  # 创建时启用
rbd --cluster local feature enable image-pool/image-1 journaling  # 对已存在的image动态启用journal特性

# 镜像存储池启用mirroring
# rbd mirror image enable {pool-name}/{image-name}
rbd --cluster local mirror image enable image-pool/image-1

# 镜像存储池禁用mirroring
# rbd mirror image disable {pool-name}/{image-name}
rbd --cluster local mirror image disable image-pool/image-1

​# 降级或升级指定的RBD镜像
# rbd mirror image demote {pool-name}/{image-name}  # 降级为non-primary
# rbd mirror image promote [--force] {pool-name}/{image-name} # 升级为primary
rbd --cluster local mirror image demote image-pool/image-1
rbd --cluster remote mirror image promote image-pool/image-1

# 降级或升级存储池所有的RBD镜像
# rbd mirror pool demote {pool-name}  # 降级为non-primary
# rbd mirror pool promote [--force] {pool-name} # 升级为primary
rbd --cluster local mirror pool demote image-pool
rbd --cluster remote mirror pool promote image-pool

# ​请求与镜像重新同步(脑裂恢复)
# rbd morror image resync {pool-name}/{image-name}
rbd mirror image resync image-pool/image-1

# ​获取备份镜像或存储池的状态
# rbd mirror image status {pool-name}/{image-name} [--verbose]
# rbd mirror pool status {pool-name} [--verbose]
rbd mirror image status image-pool/image-1
rbd mirror pool status image-pool
原文地址:https://www.cnblogs.com/wang-hongwei/p/15718581.html