PolarDB for PostgreSQL allows you to create multi-zone clusters. Compared with single-zone clusters, multi-zone clusters can enhance disaster recovery capabilities and withstand data center-level faults. This topic describes how to create a multi-zone cluster and change the primary zone of a cluster.
Prerequisites
The region in which you want to deploy the multi-zone cluster contains at least two zones.
The zones have sufficient computing resources.
Multi-zone cluster architecture
In a multi-zone cluster, data is distributed across the zones. You must deploy compute nodes only in the primary zone. PolarDB reserves sufficient resources in the secondary zones to ensure a successful failover when the primary zone fails. The following figure shows the multi-zone cluster deployment architecture.
Billing
You can use multi-zone deployment for a cluster free of charge.
You can upgrade a single-zone cluster to a multi-zone cluster free of charge.
Set up a multi-zone cluster architecture
If the prerequisites are met, a multi-zone cluster is automatically created when you create a cluster.
You can upgrade an existing single-zone cluster to a multi-zone cluster. The upgrade is automatically completed by online data migration, and does not affect your business.
View the zones of a cluster
Log on to the PolarDB console.
In the upper-left corner of the PolarDB console, select the region in which the cluster is deployed.
Click the ID of the cluster.
On the Basic Information page of the cluster, view the value of the Zones parameter.
Change the primary zone
You can change the primary zone of a PolarDB cluster. This feature allows you to migrate the compute nodes of a cluster to a different zone. This feature is suitable for scenarios such as disaster recovery or when an Elastic Compute Service (ECS) instance needs to access the cluster in a nearby zone.
For a PolarDB for PostgreSQL cluster for which hot standby is enabled, you cannot change the primary zone after you enable tiered storage for cold data for the cluster. To change the primary zone in such cases, contact us.
Log on to the PolarDB console.
In the upper-left corner, select the region where the cluster to which you want to connect is deployed.
Find the cluster and click its ID.
On the Basic Information page of the cluster, click Change Primary Zone.
In the dialog box that appears, configure the Destination Zone and Destination vSwitch parameters, and then configure the Effective Time parameter based on your business requirements.
NoteIf the destination zone is a secondary zone, data migration is not required. The system migrates only the compute nodes. The average time required to migrate a node across data centers is 5 minutes. In most cases, the operation is performed during disaster recovery drills.
If the destination zone is not a secondary zone, data must be migrated. The time required to migrate data varies based on the amount of data. If the amount of data is excessively large, the operation may require several hours to complete. Proceed with caution. In most cases, this operation is performed to adjust the distribution of applications and databases among zones for applications to access databases from the nearest zone.
In the message that appears, click OK.
ImportantAfter the primary zone is changed, the primary endpoint and the cluster endpoints of the cluster remain unchanged. However, the vSwitch and IP address may be changed. This operation may disrupt your database service for less than 60 seconds. Proceed with caution.