This document describes how to configure Persistent Disk Asynchronous Replication (PD Async Replication). PD Async Replication is useful for low-RPO, low-RTO disaster recovery.
Before you can start replication, you must configure PD Async Replication by setting up a disk replication pair. A disk replication pair consists of a primary and secondary disk.
After you create a disk replication pair, you must start replication to begin replicating data between the primary and secondary disk.
Limitations
Secondary disks must be blank when created. They can't be created from images, snapshots, or other disks.
Before you begin
- Choose a region pair .
- Optionally create a consistency group.
-
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.
-
Set up a disk replication pair
Before you can replicate data between disks, you need to configure replication by completing the following tasks:
- Choose a region pair and your primary and secondary regions.
- Optional: If you need to coordinate replication across a group of disks, create a consistency group in the primary region. You must add primary disks to a consistency group before you start replication.
- Create or select the primary disks. You can optionally add these disks to the consistency group.
- Create new, blank secondary disks.
Disk requirements
Disks must meet the following requirements to be used as primary or secondary disks for PD Async Replication:
- Disk type:
balanced persistent disk (
pd-balanced
) or performance (SSD) persistent disk (pd-ssd
). - Size: less than or equal to 32 TiB.
- Encryption type: Google-owned and Google-managed keys or customer-managed encryption keys (CMEK).
- Read/write mode: must be in read-write mode and can't have multi-writer mode (Preview) enabled.
- Location: located in a supported region (or a zone within a supported region).
Create or select a primary disk
The primary disk is the boot or data disk that is attached to the VM where the workload runs. You can use any pre-existing disk that meets the disk requirements as a primary disk, or you can create a new disk. If you want to use an existing disk as a primary disk, you don't need to perform any additional configuration on the disk. Proceed to create a secondary disk to complete PD Async Replication configuration.
Create a primary disk
Create a primary disk using the methods described in one of the following documents.
Create a primary boot disk while creating a VM. Optionally add the disk to a consistency group by creating the VM using the gcloud CLI or REST and specifying one of the following:
If you create the VM using the gcloud CLI, specify the
--create-disk
flag:--create-disk=disk-resource-policy=projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
If you create the VM using REST, specify the
resourcePolicies
property:"disks": { … "resourcePolicies": "projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME" }
Create a primary data disk while creating a VM. Optionally add the disk to a consistency group by creating the VM using the gcloud CLI or REST and specifying one of the following:
If you create the VM using the gcloud CLI, specify the
--create-disk
flag:--create-disk=disk-resource-policy=projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
If you create the VM using REST, specify the
resourcePolicies
property:"disks": { … "resourcePolicies": "projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME" }
Create a primary data disk without creating a VM. Optionally add the disk to a consistency group by creating the VM using the Google Cloud console, gcloud CLI, or REST and specifying one of the following:
If you create the disk using the Google Cloud console, select the consistency group from the Consistency group dropdown.
If you create the disk using the gcloud CLI, specify the
--resource-policies
flag:--resource-policies=projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME
If you create the disk using REST, specify the
resourcePolicies
property:"disks": { … "resourcePolicies": "projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME" }
Replace the following:
PROJECT
: the project that contains the consistency groupREGION
: the region that the consistency group is location inCONSISTENCY_GROUP_NAME
: the name of the consistency group to add the disk to
Create a secondary disk
The secondary disk is a data disk in a separate region from the primary disk, that receives and writes replicated data from the primary disk. When configuring PD Async Replication, you must create a new, blank secondary disk that references the primary disk.
To create a secondary disk with the same properties as the primary disk, follow the steps in Create a secondary disk identical to the primary disk. The secondary disk inherits the primary disk's properties, such as its boot configuration and labels.
To create a secondary disk that differs from the primary disk, see Create a custom secondary disk.
Create a secondary disk identical to the primary disk
This section describes how to create a secondary disk identical to the primary disk.
You can create a secondary disk with the Google Cloud console, the gcloud CLI, or REST.
Console
Create a secondary disk and start replication by doing the following:
In the Google Cloud console, go to the Disks page.
Click the name of the primary disk. The Manage disk page opens.
Click Create secondary disk.
In the Name field, enter a name for the disk.
In the Location section, do one of the following:
To create a regional disk:
- Select Regional.
- In the Region field, select a region that corresponds with the primary disk's region.
- In the Zone field, select the primary zone.
- In the Replica zone field, select the replica zone.
To create a zonal disk:
- Select Single zone.
- In the Region field, select a region that corresponds with the primary disk's region.
- In the Zone field, select a zone.
Click Create. Compute Engine creates the disk and starts replication.
gcloud
Create a secondary disk using the
gcloud compute disks create
command:
gcloud compute disks create SECONDARY_DISK_NAME \ --SECONDARY_LOCATION_FLAG=SECONDARY_LOCATION \ --size=SIZE \ --primary-disk=PRIMARY_DISK_NAME \ --PRIMARY_DISK_LOCATION_FLAG=PRIMARY_LOCATION \ --primary-disk-project=PRIMARY_DISK_PROJECT
To create a regional secondary disk, additionally specify the
--replica-zones
flag:
--replica-zones=ZONE_1,ZONE_2
Replace the following:
SECONDARY_DISK_NAME
: the name for the secondary disk.SECONDARY_LOCATION_FLAG
: the location flag for the secondary disk. To create a regional secondary disk, use--region
. To create a zonal secondary disk, use--zone
.SECONDARY_LOCATION
: the region or zone for the secondary disk.- To create a regional disk, use the region that corresponds with the primary disk's region.
- To create a zonal disk, use a zone within the region that corresponds with the primary disk's region.
SIZE
: the size, in GB, of the new disk. The size must be the same as the size of the primary disk. Acceptable sizes range, in 1 GB increments, from 10 GB to 2000 GB.PRIMARY_DISK_NAME
: the name of the primary disk that the secondary disk receives data from.PRIMARY_LOCATION_FLAG
: the location flag for the primary disk.- For a regional primary disk, use
--primary-disk-region
. - For a zonal primary disk, use
--primary-disk-zone
.
- For a regional primary disk, use
PRIMARY_LOCATION
: the primary disk's region or zone.- For a regional disk, use the region.
- For a zonal disks use the zone.
PRIMARY_PROJECT
: the project that contains the primary disk.ZONE_1
: one of the zones that the regional disk is replicated to. Must be a zone within the specified region and must be different thanZONE_2
.ZONE_2
: one of the zones that the regional disk is replicated to. Must be a zone within the specified region and must be different thanZONE_1
.
REST
Create a zonal or regional secondary disk using one of the following methods:
To create a zonal secondary disk, use the
disks.insert
method:POST https://compute.googleapis.com/compute/v1/projects/SECONDARY_DISK_PROJECT/zones/SECONDARY_DISK_LOCATION/disks { "name": "SECONDARY_DISK_NAME", "sizeGb": "DISK_SIZE", "type": "DISK_TYPE" "asyncPrimaryDisk": { "disk": "projects/PRIMARY_DISK_PROJECT/PRIMARY_DISK_LOCATION_PARAMETER/PRIMARY_DISK_LOCATION/disks/PRIMARY_DISK_NAME" } }
To create a regional secondary disk, use the
regionDisks.insert
method:POST https://compute.googleapis.com/compute/v1/projects/SECONDARY_DISK_PROJECT/regions/SECONDARY_DISK_LOCATION/disks { "name": "SECONDARY_DISK_NAME", "sizeGb": "DISK_SIZE", "type": "DISK_TYPE" "asyncPrimaryDisk": { "disk": "projects/PRIMARY_DISK_PROJECT/PRIMARY_DISK_LOCATION_PARAMETER/PRIMARY_DISK_LOCATION/disks/PRIMARY_DISK_NAME" } }
Replace the following:
SECONDARY_DISK_PROJECT
: the project for the secondary disk.SECONDARY_DISK_LOCATION
: the region or zone for the secondary disk.- For a regional disk, use the region.
- For a zonal disk, use the zone.
SECONDARY_DISK_NAME
: the name for the secondary disk.DISK_SIZE
: the size of the secondary disk. Must be the same as the size of the primary disk.SECONDARY_DISK_TYPE
: the disk type. Must be one ofpd-ssd
orpd-balanced
.PRIMARY_DISK_PROJECT
: the project that contains the primary disk.PRIMARY_DISK_LOCATION_PARAMETER
: the location parameter for the primary disk.- For a regional primary disk, use
regions
. - For a zonal primary disk, use
zones
.
- For a regional primary disk, use
PRIMARY_DISK_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 that the secondary disk receives data from.
Create a custom secondary disk
This section discusses how to create a custom secondary disk, that is, a secondary disk whose properties differ from the primary disk.
If the primary disk is a boot disk, you can't change or remove any of the primary disk's guest OS features. You can only add more guest OS features. For more information, see Secondary disk customization.
You can create a custom secondary disk with the gcloud CLI or REST. You can't customize the secondary disk from the Google Cloud console.
gcloud
To create a custom secondary disk, use the
gcloud compute disks create
command
as described in Create a secondary disk identical to the primary disk.
Use additional flags to customize the secondary disk's properties.
The following are examples of how to customize the secondary disk:
- To specify additional guest OS features, use the
--guest-os-features
parameter. You don't have to include the guest OS features of the primary disk. The secondary disk automatically inherits the guest OS features of the primary disk.--guest-os-features=UEFI_COMPATIBLE,GVNIC,MULTI_IP_SUBNET
- To assign additional labels to the secondary disk, use the
--labels
parameter. You don't have to include the labels of the primary disk. The secondary disk automatically inherits the labels of the primary disk.--labels=secondary-disk-for-replication=yes
REST
To create a custom secondary disk, use the same method described in Create a secondary disk identical to the primary disk. Specify additional fields to customize the secondary disk's properties.
The following are examples of how to customize the secondary disk:
- To specify additional guest OS features, use the
guestOsFeatures
field. You don't need to include the guest OS features of the primary disk. The secondary disk automatically inherits the guest OS features of the primary disk."guestOsFeatures": [ { "type": "NEW_FEATURE_ID_1" }, { "type": "NEW_FEATURE_ID_1" } ]
- To assign additional labels to the secondary disk, use the
labels
field. You don't need to include the labels of the primary disk. The secondary disk automatically inherits the labels from the primary disk."labels": [ { "key": "value" }, ]
Start replication
After you create a primary and secondary disk, you must start replication to begin replicating data from the primary disk to the secondary disk.
What's next
- Learn how to manage disks that use PD Async Replication.
- Learn how to manage replication.
- Learn how to manage consistency groups.
- Learn how to monitor Persistent Disk Asynchronous Replication performance.