搜索

6.3. 使用命令行界面配置双向镜像

download PDF

此流程配置主存储集群和辅助存储集群之间的池的双向复制。

注意

使用双向复制时,您只能在两个存储集群之间镜像。

注意

本节中的示例通过将主镜像作为 site-a 引用主存储集群和您将要复制镜像的辅助存储集群作为 site-b 来区分两个存储集群。这些示例中使用的池名称称为 data

先决条件

  • 至少两个健康状态并运行 Red Hat Ceph Storage 集群。
  • 对每个存储集群的 Ceph 客户端节点的根级别访问权限。
  • 具有管理员级别功能的 CephX 用户。

流程

  1. 在两个站点上登录到 cephadm shell:

    示例

    [root@site-a ~]# cephadm shell
    [root@site-b ~]# cephadm shell

  2. site-a 主集群中运行以下命令:

    示例

    [ceph: root@site-a /]# ceph orch apply rbd-mirror --placement=host01

    注意

    nodename 是您要配置镜像的主机。

  3. site-b 上,调度在二级集群中部署 mirror 守护进程:

    语法

    ceph orch apply rbd-mirror --placement=NODENAME

    示例

    [ceph: root@site-b /]# ceph orch apply rbd-mirror --placement=host04

    注意

    nodename 是要在二级集群中配置镜像的主机。

  4. site-a 上的镜像上启用日志功能。

    1. 对于新镜像,使用 --image-feature 选项:

      语法

      rbd create IMAGE_NAME --size MEGABYTES --pool POOL_NAME --image-feature FEATURE FEATURE

      示例

      [ceph: root@site-a /]# rbd create image1 --size 1024 --pool data --image-feature exclusive-lock,journaling

      注意

      如果已经启用了 exclusive-lock,则使用 journaling 作为唯一参数,否则会返回以下错误:

      one or more requested features are already enabled
      (22) Invalid argument
    2. 对于现有镜像,请使用 rbd feature enable 命令:

      语法

      rbd feature enable POOL_NAME/IMAGE_NAME FEATURE, FEATURE

      示例

      [ceph: root@site-a /]# rbd feature enable data/image1 exclusive-lock, journaling

    3. 要默认在所有新镜像中启用日志,请使用 ceph config set 命令设置配置参数:

      示例

      [ceph: root@site-a /]# ceph config set global rbd_default_features 125
      [ceph: root@site-a /]# ceph config show mon.host01 rbd_default_features

  5. 在两个存储集群中选择 mirroring 模式(池模式或镜像模式)。

    1. 启用 池模式

      语法

      rbd mirror pool enable POOL_NAME MODE

      示例

      [ceph: root@site-a /]# rbd mirror pool enable data pool
      [ceph: root@site-b /]# rbd mirror pool enable data pool

      这个示例启用对名为 data 的完整池进行镜像。

    2. 启用 镜像模式

      语法

      rbd mirror pool enable POOL_NAME MODE

      示例

      [ceph: root@site-a /]# rbd mirror pool enable data image
      [ceph: root@site-b /]# rbd mirror pool enable data image

      这个示例在名为 data 的池上启用镜像模式镜像。

      注意

      要在池中为特定镜像启用镜像功能,请参阅 Red Hat Ceph Storage 块设备指南中的 启用镜像镜像 部分。

    3. 验证两个站点都已成功启用了镜像:

      语法

      rbd mirror pool info POOL_NAME

      示例

      [ceph: root@site-a /]# rbd mirror pool info data
      Mode: pool
      Site Name: c13d8065-b33d-4cb5-b35f-127a02768e7f
      
      Peer Sites: none
      
      [ceph: root@site-b /]# rbd mirror pool info data
      Mode: pool
      Site Name: a4c667e2-b635-47ad-b462-6faeeee78df7
      
      Peer Sites: none

  6. 在 Ceph 客户端节点上,引导存储集群对等点。

    1. 创建 Ceph 用户帐户,并将存储集群对等注册到池:

      语法

      rbd mirror pool peer bootstrap create --site-name PRIMARY_LOCAL_SITE_NAME POOL_NAME > PATH_TO_BOOTSTRAP_TOKEN

      示例

      [ceph: root@rbd-client-site-a /]# rbd mirror pool peer bootstrap create --site-name site-a data > /root/bootstrap_token_site-a

      注意

      这个示例 bootstrap 命令创建 client.rbd-mirror.site-aclient.rbd-mirror-peer Ceph 用户。

    2. 将 bootstrap 令牌文件复制到 site-b 存储集群。
    3. site-b 存储集群中导入 bootstrap 令牌:

      语法

      rbd mirror pool peer bootstrap import --site-name SECONDARY_LOCAL_SITE_NAME --direction rx-tx POOL_NAME PATH_TO_BOOTSTRAP_TOKEN

      示例

      [ceph: root@rbd-client-site-b /]# rbd mirror pool peer bootstrap import --site-name site-b --direction rx-tx data /root/bootstrap_token_site-a

      注意

      --direction 参数是可选的,因为在 bootstrapping peers 时双向镜像是默认设置。

  7. 要验证镜像状态,请从主站点和次要站点的 Ceph monitor 节点运行以下命令:

    语法

    rbd mirror image status POOL_NAME/IMAGE_NAME

    示例

    [ceph: root@mon-site-a /]# rbd mirror image status data/image1
    image1:
      global_id:   a4c667e2-b635-47ad-b462-6faeeee78df7
      state:       up+stopped
      description: local image is primary
      service:     host03.glsdbv on host03.ceph.redhat.com
      last_update: 2021-09-16 10:55:58
      peer_sites:
        name: a
        state: up+stopped
        description: replaying, {"bytes_per_second":0.0,"entries_behind_primary":0,"entries_per_second":0.0,"non_primary_position":{"entry_tid":3,"object_number":3,"tag_tid":1},"primary_position":{"entry_tid":3,"object_number":3,"tag_tid":1}}
        last_update: 2021-09-16 10:55:50

    在这里,up 表示 rbd-mirror 守护进程正在运行,stopped 意味着此镜像不是从另一个存储集群复制的目标。这是因为镜像是这个存储集群的主要部分。

    示例

    [ceph: root@mon-site-b /]# rbd mirror image status data/image1
    image1:
      global_id:   a4c667e2-b635-47ad-b462-6faeeee78df7
      state:       up+replaying
      description: replaying, {"bytes_per_second":0.0,"entries_behind_primary":0,"entries_per_second":0.0,"non_primary_position":{"entry_tid":3,"object_number":3,"tag_tid":1},"primary_position":{"entry_tid":3,"object_number":3,"tag_tid":1}}
      service:     host05.dtisty on host05
      last_update: 2021-09-16 10:57:20
      peer_sites:
        name: b
        state: up+stopped
        description: local image is primary
        last_update: 2021-09-16 10:57:28

    如果镜像处于 up+replaying 状态,则镜像可以正常工作。在这里,up 表示 rbd-mirror 守护进程正在运行,replaying 表示此镜像是从另一个存储集群复制的目标。

    注意

    根据站点之间的连接,镜像可能需要很长时间才能同步镜像。

其它资源

  • 如需了解更多详细信息,请参阅 Red Hat Ceph Storage 块设备指南中的 Ceph 块设备镜像 部分。
  • 有关 Ceph 用户 的更多详细信息,请参见 Red Hat Ceph Storage 管理指南中的用户管理一节
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.