This document describes how to start and stop Persistent Disk Asynchronous Replication (PD Async Replication).
PD Async Replication is useful for low-RPO, low-RTO disaster recovery. To learn more about asynchronous replication, see About Persistent Disk Asynchronous Replication.
Limitations
- A primary disk can only replicate to one secondary disk at a time.
- After replication stops, you can't resume replication to the same disk. You must create a new secondary disk and restart replication.
- Secondary disks can't be attached, deleted, or snapshotted while they are in the process of replication.
- If you use a regional disk as a secondary disk and a zonal outage occurs in one of the secondary disk's zones, replication from the primary disk to the secondary disk fails.
Before you begin
- If you need to align replication across multiple disks, create a consistency group.
- Create a primary disk.
- Create a secondary disk.
-
If you haven't already, then set up authentication.
Authentication is
the process by which your identity is verified for access to Google Cloud services and APIs.
To run code or samples from a local development environment, you can authenticate to
Compute Engine by selecting one of the following options:
Select the tab for how you plan to use the samples on this page:
Console
When you use the Google Cloud console to access Google Cloud services and APIs, you don't need to set up authentication.
gcloud
-
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
- Set a default region and zone.
REST
To use the REST API samples on this page in a local development environment, you use the credentials you provide to the gcloud CLI.
Install the Google Cloud CLI, then initialize it by running the following command:
gcloud init
For more information, see Authenticate for using REST in the Google Cloud authentication documentation.
-
Start replication
Start replication using the Google Cloud console, Google Cloud CLI, or REST.
Console
In the Google Cloud console, go to the Asynchronous replication page.
Click the name of the secondary disk that you want to start replication to.
Click Start replication. The Start replication window opens.
Click Start replication.
gcloud
Start replication using the
gcloud compute disks start-async-replication
command:
gcloud compute disks start-async-replication PRIMARY_DISK_NAME \ --PRIMARY_LOCATION_FLAG=PRIMARY_LOCATION \ --secondary-disk=SECONDARY_DISK_NAME \ --SECONDARY_LOCATION_FLAG=SECONDARY_LOCATION \ --secondary-disk-project=SECONDARY_PROJECT
Replace the following:
PRIMARY_DISK_NAME
: the name of the primary disk.PRIMARY_LOCATION_FLAG
: the location flag for the primary disk. For regional disks, use--region
. For zonal disks, use--zone
.PRIMARY_LOCATION
: The primary disk's region or zone. For regional disks, use the region. For zonal disks, use the zone.SECONDARY_DISK_NAME
: the name of the secondary disk.SECONDARY_LOCATION_FLAG
: the location flag for the secondary disk. For regional disks, use--secondary-disk-region
. For zonal disks, use--secondary-disk-zone
.SECONDARY_LOCATION
: the secondary disk's region or zone. For regional disks, use the region. For zonal disks, use the zone.SECONDARY_PROJECT
: the project that contains the secondary disk.
REST
Start replication using one of the following methods:
Start replication for zonal disks using the
disks.startAsyncReplication
method:POST https://compute.googleapis.com/compute/v1/projects/PRIMARY_DISK_PROJECT/zones/PRIMARY_LOCATION/disks/PRIMARY_DISK_NAME/startAsyncReplication { "asyncSecondaryDisk": "projects/SECONDARY_DISK_PROJECT/SECONDARY_LOCATION_PARAMETER/SECONDARY_LOCATION/disks/SECONDARY_DISK_NAME" }
Start replication for regional disks using the
regionDisks.startAsyncReplication
method:POST https://compute.googleapis.com/compute/v1/projects/PRIMARY_DISK_PROJECT/regions/PRIMARY_LOCATION/regionDisks/PRIMARY_DISK_NAME/startAsyncReplication { "asyncSecondaryDisk": "projects/SECONDARY_DISK_PROJECT/SECONDARY_LOCATION_PARAMETER/SECONDARY_LOCATION/disks/SECONDARY_DISK_NAME" }
Replace the following:
PRIMARY_DISK_PROJECT
: the project that contains the primary disk.PRIMARY_LOCATION
: The primary disk's region or zone. For regional disks, use the region. For zonal disks, use the zone.PRIMARY_DISK_NAME
: the name of the primary disk.SECONDARY_DISK_PROJECT
: the project that contains the secondary disk.SECONDARY_LOCATION_PARAMETER
: the location parameter for the secondary disk. For regional disks, useregions
. For zonal disks, usezones
.SECONDARY_LOCATION
: The secondary disk's region or zone. For regional disks, use the region. For zonal disks, use the zone.SECONDARY_DISK_NAME
: the name of the secondary disk.
Stop replication
You can stop replication for a single primary or secondary disk, or for all disks in a consistency group. If you stop replication for a single disk in a consistency group, the replication time for that disk becomes out of sync with the other disks in the consistency group.
Stopping replication is performed in failover and failback scenarios. If you stop replication, you can't restart replication to the same secondary disk. If you want to restart replication, you must create a new secondary disk and start again.
When you stop replication on a disk, the disk's replication state changes to
STOPPED
. The replication state of the other disk in the disk's replication
pair (the corresponding primary or secondary disk) updates to
STOPPED
at a later time. If you want to avoid the time gap and update the
replication state of the other disk to STOPPED
immediately, you must manually
stop replication on the other disk as well. Stopping replication on both disks
doesn't affect the time at which replication stops, it only
affects the disks' replication states.
Stop replication for a single disk
Stop replication for a single disk using the Google Cloud console, the Google Cloud CLI, or REST.
Console
Stop replication by doing the following:
In the Google Cloud console, go to the Asynchronous replication page.
Click the name of primary or secondary disk for which you want to stop replication. The Manage disk page opens.
Click Terminate replication. The Terminate replication window opens.
Click Terminate replication.
gcloud
Stop replication using the
gcloud compute disks stop-async-replication
command:
gcloud compute disks stop-async-replication DISK_NAME \ --LOCATION_FLAG=LOCATION
Replace the following:
DISK_NAME
: the name of the disk.LOCATION_FLAG
: the location flag for the disk. For a regional disk, use--region
. For a zonal disk, use--zone
.LOCATION
: the disk's region or zone. For regional disks, use the region. For zonal disks, use the zone.
REST
Stop replication using one of the following methods:
Stop replication for zonal disks using the
disks.stopAsyncReplication
method:POST https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/LOCATION/disks/DISK_NAME/stopAsyncReplication { }
Stop replication for regional disks using the
regionDisks.stopAsyncReplication
method:POST https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/LOCATION/regionDisks/DISK_NAME/stopAsyncReplication { }
Replace the following:
PROJECT
: the project that contains the disk.DISK_NAME
: the name of the disk.LOCATION
: the zone or region of the disk. For zonal disks, use the zone. For regional disks, use the region.
Stop replication for a consistency group
Stop replication for all disks in a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.
Console
Stop replication for all disks in a consistency group by doing the following:
In the Google Cloud console, go to the Asynchronous replication page.
Click the Consistency groups tab.
Click the name of the consistency group for which you want to stop replication. The Manage consistency group page opens.
Click Terminate replication. The Terminate replication window opens.
Click Terminate replication.
gcloud
Stop replication for all disks in a consistency group using the
gcloud compute disks stop-group-async-replication
command:
gcloud compute disks stop-group-async-replication CONSISTENCY_GROUP \ --LOCATION_FLAG=LOCATION
Replace the following:
CONSISTENCY_GROUP
: the URL of the consistency group. For example,projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
.LOCATION_FLAG
: the location flag for the disks in the consistency group. For regional disks, use--region
. For zonal disks, use--zone
.LOCATION
: the disk's region or zone. For regional disks, use the region. For zonal disks, use the zone.
REST
Stop replication for all disks in a consistency group using one of the following methods:
Stop replication for zonal disks using the
disks.stopGroupAsyncReplication
method:POST https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/LOCATION/disks/stopGroupAsyncReplication { "resourcePolicy": "CONSISTENCY_GROUP" }
Stop replication for regional disks using the
regionDisks.stopGroupAsyncReplication
method:POST https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/LOCATION/regionDisks/DISK_NAME/stopAsyncReplication { "resourcePolicy": "CONSISTENCY_GROUP" }
Replace the following:
DISK_NAME
: the name of the diskLOCATION
: the zone or region of the disk. For zonal disks, use the zone. For regional disks, use the region.CONSISTENCY_GROUP
: the URL of the consistency group. For example,projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
.
What's next
- Learn how to failover and failback.
- Learn how to monitor Persistent Disk Asynchronous Replication performance.