Manage consistency groups


This document describes how to manage consistency groups. Consistency groups are resource policies that align replication across multiple disks in the same region or zone.

To learn more about consistency groups, see About Persistent Disk Asynchronous Replication.

Limitations

  • Consistency groups aren't supported for disks in sole-tenant nodes.
  • Consistency groups can have a maximum of 128 disks.
  • All disks in a consistency group must be in the same project as the consistency group resource policy.
  • All disks in a consistency group must be in the same zone, for zonal disks, or in the same pair of zones, for regional disks.
  • A consistency group can contain primary disks or secondary disks, but not both.
  • You can't add or remove a primary disk to or from a consistency group while the disk is replicating. If you want to add or remove a primary disk to or from a consistency group, you must first stop replication. You can add or remove secondary disks to or from consistency groups at any time.
  • You can attach a maximum of 16 disks that are in different consistency groups, or disks that aren't in a consistency group to a VM. Disks that are in the same consistency group count as one disk towards the 16 disk limit.

Before you begin

  • If you haven't already, 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 as follows.

    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

    1. Install the Google Cloud CLI, then initialize it by running the following command:

      gcloud init
    2. 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

Create a consistency group

If you need to align replication across multiple disks, create a consistency group in the same region as the primary disks. If you need to align disk clones, create a consistency group in the same region as the secondary disks.

Create a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.

Console

Create a consistency group by doing the following:

  1. In the Google Cloud console, go to the Asynchronous replication page.

    Go to Asynchronous replication

  2. Click the Consistency groups tab.

  3. Click Create consistency group.

  4. In the Name field, enter a name for the consistency group.

  5. In the Region field, select the region where your disks are located. If you want to add primary disks to consistency group, select the primary region. If you want to add secondary disks to the consistency group, select the secondary region.

  6. Click Create.

gcloud

Create a consistency group using the gcloud compute resource-policies create disk-consistency-group command:

gcloud compute resource-policies create disk-consistency-group CONSISTENCY_GROUP_NAME \
    --region=REGION

Replace the following:

  • CONSISTENCY_GROUP_NAME: the name for the consistency group.
  • REGION: the region for the consistency group. If you want to add primary disks to consistency group, use the primary region. If you want to add secondary disks to the consistency group, use the secondary region.

REST

Create a consistency group using the resourcePolicies.insert method:

POST https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/REGION/resourcePolicies
{
 "name": "CONSISTENCY_GROUP_NAME",
 "diskConsistencyGroupPolicy": {
  }
}

Replace the following:

  • PROJECT: the project that contains the consistency group.
  • REGION: the region for the consistency group. If you want to add primary disks to consistency group, use the same region as the primary disks. If you want to add secondary disks to the consistency group, use the same region as the secondary disks.
  • CONSISTENCY_GROUP_NAME: the name for the consistency group.

View disks in a consistency group

View disks in a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.

Console

View the disks included in a consistency group by doing the following:

  1. In the Google Cloud console, go to the Asynchronous replication page.

    Go to Asynchronous replication

  2. Click the Consistency groups tab.

  3. Click the name of the consistency group that you want to view the disks for. The Manage consistency group page opens.

  4. View the Consistency group members section to see all disks included in the consistency group.

gcloud

View the disks included in a consistency group using the gcloud compute disks list command:

gcloud compute disks list \
    --LOCATION_FLAG=LOCATION \
    --filter=resourcePolicies=CONSISTENCY_GROUP_NAME

Replace the following:

  • LOCATION_FLAG: the location flag for the disks in the consistency group. If the disks in the consistency group are regional, use --region. If the disks in the consistency group are zonal, use --zone.
  • LOCATION: the region or zone of the disks in the consistency group. For regional disks, use the region. For zonal disks, use the zone.
  • CONSISTENCY_GROUP_NAME: the name of the consistency group.

REST

View the disks in a consistency group by using a query filter with one of the following methods:

  • View zonal disks in a consistency group using the disks.get method:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/ZONE/disks?filter=resourcePolicies%3DCONSISTENCY_GROUP_NAME
    
  • View regional disks in a consistency group using the regionDisks.get method:

    GET https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/REGION/disks?filter=resourcePolicies%3DCONSISTENCY_GROUP_NAME
    

Replace the following:

  • PROJECT: the project that contains the consistency group
  • ZONE: the zone of the disks in the consistency group
  • REGION: the region of the disks in the consistency group
  • CONSISTENCY_GROUP_NAME: the name of the consistency group

Add a disk to a consistency group

If you want to add primary disks to a consistency group, you must add disks to the consistency group before you start replication. You can add secondary disks to a consistency group at any time. All disks in a consistency group must be in the same zone, for zonal disks, or in the same pair of zones, for regional disks.

Add a disk to a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.

Console

Add disks to a consistency group by doing the following:

  1. In the Google Cloud console, go to the Asynchronous replication page.

    Go to Asynchronous replication

  2. Click the Consistency groups tab.

  3. Click the name of the consistency group that you want to add disks to. The Manage consistency group page opens.

  4. Click Assign disks. The Assign disks page opens.

  5. Select the disks that you want to add to the consistency group.

  6. Click Assign disks. When prompted, click Add.

gcloud

Add a disk to a consistency group using the gcloud compute disks add-resource-policiescommand:

gcloud compute disks add-resource-policies DISK_NAME \
    --LOCATION_FLAG=LOCATION \
    --resource-policies=CONSISTENCY_GROUP

Replace the following:

  • DISK_NAME: the name of the disk to add to the consistency group.
  • LOCATION_FLAG: the location flag for the disk. For a regional disk, use --region. For a zonal disk, use --zone.
  • LOCATION: the region or zone of the disk. For regional disks, use the region. For zonal disks, use the zone.
  • CONSISTENCY_GROUP: the URL of the consistency group. For example, projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME.

REST

Add disks to a consistency group using one of the following methods:

  • Add zonal disks to a consistency group using the disks.addResourcePolicies method:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/LOCATION/disks/DISK_NAME/addResourcePolicies
    
    {
    "resourcePolicies": "CONSISTENCY_GROUP"
    }
    
  • Add regional disks to a consistency group using the regionDisks.addResourcePolicies method:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/LOCATION/disks/DISK_NAME/addResourcePolicies
    
    {
    "resourcePolicies": "CONSISTENCY_GROUP"
    }
    

Replace the following:

  • PROJECT: the project that contains the disk.
  • LOCATION: the zone or region of the disk. For zonal disks, use the zone. For regional disks, use the region.
  • DISK_NAME: the name of the disk to add to the consistency group.
  • CONSISTENCY_GROUP: the URL of the consistency group. For example, projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME.

Remove a disk from a consistency group

Before you can remove a disk from a consistency group, you must stop replication for the disk.

Remove a disk from a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.

Console

Remove primary disks from a consistency group by doing the following:

  1. In the Google Cloud console, go to the Asynchronous replication page.

    Go to Asynchronous replication

  2. Click the Consistency groups tab.

  3. Click the name of the consistency group that you want to add disks to. The Manage consistency group page opens.

  4. Select the disks that you want to remove from the consistency group.

  5. Click Remove disks. When prompted, click Remove.

gcloud

Remove a disk from a consistency group using the gcloud compute disks remove-resource-policies command:

gcloud compute disks remove-resource-policies DISK_NAME \
    --LOCATION_FLAG=LOCATION \
    --resource-policies=CONSISTENCY_GROUP

Replace the following:

  • DISK_NAME: the name of the disk to remove from the consistency group.
  • LOCATION_FLAG: the location flag for the disk. For a regional disk, use --region. For a zonal disk, use --zone.
  • LOCATION: the region or zone of the disk. For regional disks, use the region. For zonal disks, use the zone.
  • CONSISTENCY_GROUP: the URL of the consistency group. For example, projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME.

REST

Remove a disk from a consistency group using the disks.removeResourcePolicies method for zonal disks, or the regionDisks.removeResourcePolicies method for regional disks.

  • Remove a zonal disk from a consistency group:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT/zones/LOCATION/disks/DISK_NAME/removeResourcePolicies
    
    {
    "resourcePolicies": "CONSISTENCY_GROUP"
    }
    
  • Remove a regional disk from a consistency group:

    POST https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/LOCATION/disks/DISK_NAME/removeResourcePolicies
    
    {
    "resourcePolicies": "CONSISTENCY_GROUP"
    }
    

Replace the following:

  • PROJECT: the project that contains the disk.
  • LOCATION: the zone or region of the disk. For zonal disks, use the zone. For regional disks, use the region.
  • DISK_NAME: the name of the disk to remove from the consistency group.
  • CONSISTENCY_GROUP: the URL of the consistency group. For example, projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME.

Delete a consistency group

Delete a consistency group using the Google Cloud console, the Google Cloud CLI, or REST.

Console

Delete a consistency by doing the following:

  1. In the Google Cloud console, go to the Asynchronous replication page.

    Go to Asynchronous replication

  2. Click the Consistency groups tab.

  3. Select the consistency group that you want to delete.

  4. Click Delete. The Delete consistency group window opens.

  5. Click Delete.

gcloud

Delete the resource policy using the gcloud compute resource-policies delete command:

gcloud compute resource-policies delete CONSISTENCY_GROUP \
    --region=REGION

Replace the following:

  • CONSISTENCY_GROUP: the name of the consistency group
  • REGION: the region of the consistency group

REST

Delete a consistency using the resourcePolicies.delete method:

DELETE https://compute.googleapis.com/compute/v1/projects/PROJECT/regions/REGION/resourcePolicies/CONSISTENCY_GROUP_NAME

Replace the following:

  • PROJECT: the project that contains the consistency group
  • REGION: the region of the consistency group
  • CONSISTENCY_GROUP: the name of the consistency group

What's next