本頁說明如何設定及執行 Google Distributed Cloud (GDC) 氣隙式區塊儲存空間磁碟區的非同步複製作業。
非同步複製功能可用於將資料從一個 GDC 可用區複製到另一個可用區。如果來源區域中的資料無法使用,您可以在容錯移轉情境中使用這項複製資料。請注意,建立容錯移轉後,原始磁碟區就無法設定為複製到相同目的地磁碟區。而是必須建立新的複寫關係。
事前準備
如要使用非同步區塊複製功能,基礎架構營運商 (IO) 必須先在需要複製的兩個區域之間設定儲存空間基礎架構。具體來說,他們必須先對接各區域的相關儲存空間叢集。接著,他們需要對等互連與佈建區塊儲存空間的機構相關聯的儲存空間虛擬機器。
然後,請確認您具備 volume-replication-admin-global
角色,可管理 VolumeReplicationRelationship 資源。如果無法使用全域 API,則可使用 app-volume-replication-admin
角色直接修改區域 VolumeReplicationRelationshipReplica 資源。
設定複製作業
VolumeReplicationRelationship 自訂資源 (CR) 會提供非同步區塊複製 API。這則罐頭回應存在於全域管理 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 所在的叢集名稱。
規格的 source
和 destination
欄位分別指出資料的來源和目的地。在本例中,資料會從 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 伺服器。如果是第 1 版機構,這會是機構管理員叢集。舉例來說,如果建立 VolumeReplicationRelationship 時指定 xx-xxxx-zone2
為目的地區域,且 PVC 存在於 my-org
機構中,則 VolumeFailover CR 會在 xx-xxxx-zone2
的 my-org
管理平面中建立。這會中斷兩個區域之間的複寫關係,並允許工作負載掛接目的地區域中的 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 時,系統會代表使用者建立該磁碟區)。