异步复制卷

本页介绍了如何设置和执行 Google Distributed Cloud (GDC) 气隙式块存储卷的异步复制。

异步复制用于将数据从一个 GDC 可用区复制到另一个可用区。如果源可用区中的数据不可用,则可以在故障切换方案中使用此复制的数据。请注意,创建故障切换后,无法将原始卷设置为复制到同一目标卷。而是必须创建新的复制关系。

准备工作

如需使用异步块复制,您的基础架构运维者 (IO) 必须先在需要复制的两个可用区之间设置存储基础架构。具体而言,他们首先需要对每个可用区的相关存储集群进行对等互连。接下来,他们需要对与预配了块存储的组织相关联的存储虚拟机进行对等互连。

之后,确保您拥有 volume-replication-admin-global 角色来管理 VolumeReplicationRelationship 资源。如果全局 API 不可用,可以使用 app-volume-replication-admin 角色直接修改区域 VolumeReplicationRelationshipReplica 资源。

设置复制

VolumeReplicationRelationship 自定义资源 (CR) 用于提供异步块复制 API。此 CR 存在于全局管理 API 中。如需为给定的块设备启用复制,需要在全局管理 API 上创建 VolumeReplicationRelationship CR:

apiVersion: storage.global.gdc.goog/v1
kind: VolumeReplicationRelationship
metadata:
  name: my-pvc-repl
  namespace: my-project
spec:
  source:
    pvc:
      clusterRef: my-pvc-cluster
      pvcRef: my-block-pvc
    zoneRef: xx-xxxx-zone1
 destination:
    pvc:
      clusterRef: my-pvc-cluster
    zoneRef: xx-xxxx-zone2

此示例假定在名为 my-org 的组织中创建了一个名为 my-project 的项目,并且已预配名为 my-block-pvc 的 PVC。clusterRef 是 PVC 所在的集群的名称。

规范的 sourcedestination 字段分别表示数据复制的目标。在此示例中,数据从 xx-xxxx-zone1 复制到 xx-xxxx-zone2

通过从全局 API 中检索 VolumeReplicationRelationship CR 来检查复制关系的状态。请参考以下示例。请注意,为简化起见,输出已被截断:

apiVersion: storage.global.gdc.goog/v1
kind: VolumeReplicationRelationship
metadata:
  name: my-pvc-repl
  namespace: my-project
spec:
  destination:
    pvc:
      clusterRef: my-pvc-cluster
    zoneRef: xx-xxxx-zone2
  source:
    pvc:
      clusterRef: my-pvc-cluster
      pvcRef: my-block-pvc
    zoneRef: xx-xxxx-zone1
status:
  zones:
  - name: xx-xxxx-zone1
    replicaStatus:
      message: SnapMirror relationship has been established. Please check the destination
        zone for relationship state
      replicationID: a096621e-f062-11ef-ad24-00a0b89f23fb
      state: Established
  - name: xx-xxxx-zone2
    replicaStatus:
      exportedSnapshotName: snapmirror.c34f8845-e8c0-11ef-ad24-00a0b89f23fb_2150007868.2025-02-21_150000
      message: SnapMirror relationship has been successfully established
      replicationID: a096621e-f062-11ef-ad24-00a0b89f23fb
      state: Idle

创建故障切换

如果源可用区因任何原因而不可用,可以在目标可用区的组织管理平面中创建 VolumeFailover CR。对于 v2 组织,这将是管理 API 服务器。对于 v1 组织,这将是组织管理员集群。例如,如果创建的 VolumeReplicationRelationship 指定 xx-xxxx-zone2 为目标可用区,并且 PVC 存在于 my-org 组织中,则会在 xx-xxxx-zone2 中的 my-org 管理平面中创建 VolumeFailover CR。这会中断两个可用区之间的复制关系,并允许目标可用区中的 PVC 由工作负载装载:

apiVersion: storage.gdc.goog/v1
kind: VolumeFailover
metadata:
  name: my-pvc-failover
  namespace: my-project
spec:
  volumeReplicationRelationshipRef: my-pvc-repl

之后,CR 的状态会反映出成功的故障切换:

apiVersion: storage.gdc.goog/v1
kind: VolumeFailover
metadata:
  name: my-pvc-failover
  namespace: my-project
spec:
  volumeReplicationRelationshipRef: my-pvc-repl
status:
    state: Completed

创建故障切换后,my-pvc-repl VolumeReplicationRelationship 会转换为 Broken Off 状态。xx-xxxx-zone2 中的 PVC 现在可挂载。

此时,VolumeReplicationRelationship 将与以下示例类似。为简单起见,此输出已截断:

apiVersion: storage.global.gdc.goog/v1
kind: VolumeReplicationRelationship
metadata:
  name: my-pvc-repl
  namespace: my-project
spec:
  destination:
    pvc:
      clusterRef: my-pvc-cluster
    zoneRef: xx-xxxx-zone2
  source:
    pvc:
      clusterRef: my-pvc-cluster
      pvcRef: my-block-pvc
    zoneRef: xx-xxxx-zone1
status:
  zones:
  - name: xx-xxxx-zone1
    replicaStatus:
      message: SnapMirror relationship has been broken off
      replicationID: a096621e-f062-11ef-ad24-00a0b89f23fb
      state: Broken Off
  - name: xx-xxxx-zone2
    replicaStatus:
      exportedSnapshotName: snapmirror.c34f8845-e8c0-11ef-ad24-00a0b89f23fb_2150007868.2025-02-21_150000
      message: SnapMirror relationship has been broken off
      replicationID: a096621e-f062-11ef-ad24-00a0b89f23fb
      state: Broken Off

现在,可以安全地删除 VolumeReplicationRelationship,因为这是唯一可以对该 CR 执行的操作。

调整卷大小

如果源卷在任何时候调整大小,则在创建 VolumeReplicatioRelationship 时代表用户创建的目标可用区中的相应卷也应调整大小以匹配。