5.6. 使用命令行界面配置双向镜像
此流程配置主存储集群和辅助存储集群之间的池的双向复制。
使用双向复制时,您只能在两个存储集群之间镜像。
本节中的示例通过将主镜像作为 site-a 引用主存储集群和您将要复制镜像的辅助存储集群作为 site-b 来区分两个存储集群。这些示例中使用的池名称称为 data。
先决条件
- 至少两个健康状态并运行 Red Hat Ceph Storage 集群。
- 对每个存储集群的 Ceph 客户端节点的根级别访问权限。
- 具有管理员级别功能的 CephX 用户。
- 池中的镜像必须为基于日志的镜像启用 exclusive-lock 和日志记录。
流程
在连接到
site-a存储集群的客户端节点上,以及连接到site-b存储集群的客户端节点上安装rbd-mirror软件包:Red Hat Enterprise Linux 7
[root@rbd-client ~]# yum install rbd-mirrorRed Hat Enterprise Linux 8
[root@rbd-client ~]# dnf install rbd-mirror注意软件包由 Red Hat Ceph Storage 工具存储库提供。
在镜像上启用 exclusive-lock 和 loging 功能。
对于新镜像,使用
--image-feature选项:语法
rbd create IMAGE_NAME --size MEGABYTES --pool POOL_NAME --image-feature FEATURE [,FEATURE]示例
[root@rbd-client ~]# rbd create image1 --size 1024 --pool data --image-feature exclusive-lock,journaling对于现有镜像,请使用
rbd feature enable命令:语法
rbd feature enable POOL_NAME/IMAGE_NAME FEATURE [,FEATURE]示例
[root@rbd-client ~]# rbd feature enable data/image1 exclusive-lock,journaling要默认在所有新镜像上启用专用锁定和日志记录功能,请在 Ceph 配置文件中添加以下设置:
rbd_default_features = 125
选择镜像模式,可以是池或镜像模式。
重要使用镜像模式进行基于快照的镜像功能。
启用 池模式 :
语法
rbd mirror pool enable POOL_NAME MODE示例
[root@rbd-client ~]# rbd mirror pool enable data pool这个示例启用对名为
data的完整池进行镜像。启用 镜像模式 :
语法
rbd mirror pool enable POOL_NAME MODE示例
[root@rbd-client ~]# rbd mirror pool enable data image这个示例在名为
data的池上启用镜像模式镜像。验证镜像是否已成功启用:
语法
rbd mirror pool info POOL_NAME示例
[root@rbd-client ~]# rbd mirror pool info data Mode: image Site Name: 94cbd9ca-7f9a-441a-ad4b-52a33f9b7148 Peer Sites: none
在
site-a集群中,完成以下步骤:在 Ceph 客户端节点上,创建一个用户:
语法
ceph auth get-or-create client.PRIMARY_CLUSTER_NAME mon 'profile rbd-mirror' osd 'profile rbd' -o /etc/ceph/ceph.PRIMARY_CLUSTER_NAME.keyring示例
[root@rbd-client-site-a ~]# ceph auth get-or-create client.rbd-mirror.site-a mon 'profile rbd-mirror' osd 'profile rbd' -o /etc/ceph/ceph.client.rbd-mirror.site-a.keyring将密钥环复制到
site-b集群:语法
scp /etc/ceph/ceph.PRIMARY_CLUSTER_NAME.keyring root@SECONDARY_CLUSTER:_PATH_示例
[root@rbd-client-site-a ~]# scp /etc/ceph/ceph.client.rbd-mirror.site-a.keyring root@rbd-client-site-b:/etc/ceph/在 Ceph 客户端节点上,引导存储集群对等点。
将存储集群对点注册到池:
语法
rbd mirror pool peer bootstrap create --site-name LOCAL_SITE_NAME POOL_NAME > PATH_TO_BOOTSTRAP_TOKEN示例
[root@rbd-client-site-a ~]# rbd mirror pool peer bootstrap create --site-name rbd-mirror.site-a data > /root/bootstrap_token_rbd-mirror.site-a注意此示例 bootstrap 命令创建
client.rbd-mirror-peerCeph 用户。将 bootstrap 令牌文件复制到
site-b存储集群。语法
scp PATH_TO_BOOTSTRAP_TOKEN root@SECONDARY_CLUSTER:/root/示例
[root@rbd-client-site-a ~]# scp /root/bootstrap_token_site-a root@ceph-rbd2:/root/
在
site-b集群中,完成以下步骤:在客户端节点上,创建用户:
语法
ceph auth get-or-create client.SECONDARY_CLUSTER_NAME mon 'profile rbd-mirror' osd 'profile rbd' -o /etc/ceph/ceph.SECONDARY_CLUSTER_NAME.keyring示例
[root@rbd-client-site-b ~]# ceph auth get-or-create client.rbd-mirror.site-b mon 'profile rbd-mirror' osd 'profile rbd' -o /etc/ceph/ceph.client.rbd-mirror.site-b.keyring将密钥环复制到
站点(Ceph 客户端节点)中:语法
scp /etc/ceph/ceph.SECONDARY_CLUSTER_NAME.keyring root@PRIMARY_CLUSTER:_PATH_示例
[root@rbd-client-site-b ~]# scp /etc/ceph/ceph.client.rbd-mirror.site-b.keyring root@rbd-client-site-a:/etc/ceph/导入 bootstrap 令牌:
语法
rbd mirror pool peer bootstrap import --site-name LOCAL_SITE_NAME --direction rx-tx POOL_NAME PATH_TO_BOOTSTRAP_TOKEN示例
[root@rbd-client-site-b ~]# rbd mirror pool peer bootstrap import --site-name rbd-mirror.site-b --direction rx-tx data /root/bootstrap_token_rbd-mirror.site-a注意--direction参数是可选的,因为在 bootstrapping peers 时双向镜像是默认设置。
在主客户端和次要客户端节点上启用并启动
rbd-mirror守护进程:语法
systemctl enable ceph-rbd-mirror.target systemctl enable ceph-rbd-mirror@rbd-mirror.CLIENT_ID systemctl start ceph-rbd-mirror@rbd-mirror.CLIENT_ID将
CLIENT_ID替换为前面创建的 Ceph 用户。示例
[root@rbd-client-site-a ~]# systemctl enable ceph-rbd-mirror.target [root@rbd-client-site-a ~]# systemctl enable ceph-rbd-mirror@rbd-mirror.site-a [root@rbd-client-site-a ~]# systemctl start ceph-rbd-mirror@rbd-mirror.site-a [root@rbd-client-site-a ~]# systemctl enable ceph-rbd-mirror@rbd-mirror.site-b [root@rbd-client-site-a ~]# systemctl start ceph-rbd-mirror@rbd-mirror.site-b在上例中,用户在主集群
site-a中被启用示例
[root@rbd-client-site-b ~]# systemctl enable ceph-rbd-mirror.target [root@rbd-client-site-b ~]# systemctl enable ceph-rbd-mirror@rbd-mirror.site-a [root@rbd-client-site-b ~]# systemctl start ceph-rbd-mirror@rbd-mirror.site-a [root@rbd-client-site-b ~]# systemctl enable ceph-rbd-mirror@rbd-mirror.site-b [root@rbd-client-site-b ~]# systemctl start ceph-rbd-mirror@rbd-mirror.site-b在上例中,用户在第二个集群
site-b中启用重要每个
rbd-mirror守护进程必须具有唯一的客户端 ID。要验证镜像状态,请从
site-a和site-b集群中的 Ceph Monitor 节点运行以下命令:语法
rbd mirror image status POOL_NAME/IMAGE_NAME示例
基于日志的镜像:
[root@mon-site-a ~]# rbd mirror image status data/image1 image1: global_id: 08027096-d267-47f8-b52e-59de1353a034 state: up+stopped1 description: local image is primary last_update: 2021-04-22 13:45:31基于快照的镜像:
[root@mon-site-a ~]# rbd mirror image status data/image1 image1: global_id: 47fd1aae-5f19-4193-a5df-562b5c644ea7 state: up+stopped1 description: local image is primary service: admin on ceph-rbd1-vasi-43-5hwia4-node2 last_update: 2022-01-20 12:42:54 peer_sites: name: rbd-mirror.site-b state: up+replaying description: replaying, {"bytes_per_second":0.0,"bytes_per_snapshot":0.0,"local_snapshot_timestamp":1642693094,"remote_snapshot_timestamp":1642693094,"replay_state":"idle"} last_update: 2022-01-20 12:42:59 snapshots: 5 .mirror.primary.47fd1aae-5f19-4193-a5df-562b5c644ea7.dda146c6-5f21-4e75-ba93-660f6e57e301 (peer_uuids:[bfd09289-c9c9-40c8-b2d3-ead9b6a99a45])示例
基于日志的镜像:
[root@mon-site-b ~]# rbd mirror image status data/image1 image1: global_id: 7d486c3f-d5a1-4bee-ae53-6c4f1e0c8eac state: up+replaying1 description: replaying, master_position=[object_number=3, tag_tid=1, entry_tid=3], mirror_position=[object_number=3, tag_tid=1, entry_tid=3], entries_behind_master=0 last_update: 2021-04-22 14:19:27基于快照的镜像:
[root@mon-site-b ~]# rbd mirror image status data/image1 image1: global_id: 06acc9e6-a63d-4aa1-bd0d-4f3a79b0ae33 state: up+replaying1 description: replaying, {"bytes_per_second":0.0,"bytes_per_snapshot":0.0,"local_snapshot_timestamp":1642689843,"remote_snapshot_timestamp":1642689843,"replay_state":"idle"} service: admin on ceph-rbd2-vasi-43-5hwia4-node2 last_update: 2022-01-20 12:41:57注意根据站点之间的连接,镜像可能需要很长时间才能同步镜像。
其它资源
- 如需了解更多详细信息,请参阅 Red Hat Ceph Storage 块设备指南中的 Ceph 块设备镜像部分。
- 有关 Ceph 用户的更多详细信息,请参见 Red Hat Ceph Storage 管理指南中的用户管理一节。