All Products
Search
Document Center

PolarDB:Create a global domain name

Last Updated:Sep 14, 2024

A global database network (GDN) consists of multiple PolarDB clusters that are deployed in multiple regions within a country. Data is replicated across all clusters in each GDN. If your service is deployed across multiple regions, two endpoints are required to connect to the primary cluster and secondary cluster in the GDN. However, the global domain name feature provides a unified endpoint for the GDN. You can use the global domain name feature to access the nearest cluster and keep the domain name unchanged after the primary cluster is switched. This topic describes how to create and modify a global domain name, and perform a cluster switching test.

How it works

The global domain name feature is based on Private DNS. A domain name in the [gdnid].gdn.rds.aliyuncs.com format is created in the built-in authoritative acceleration zone. It is valid in the VPCs where the primary and secondary clusters are deployed. The resolution record contains the internal cluster endpoints of the primary and secondary clusters. Then, you can access the nearest cluster at the region level. After the primary cluster is forcibly switched, the global domain name settings are modified so that you can still access the new primary cluster.

Prerequisites

Important

The CIDR blocks in the VPCs do not overlap. If not, the CIDR blocks in the vSwitches do not overlap.

Precautions

  • You can create global domain names only for Enterprise Edition clusters.

  • If you want to switch VPCs and vSwitches, you must connect the new VPC with the existing VPC.

  • When you create a global domain name, the AliyunServiceRoleForPolarDB service-linked role is automatically created.

  • The global domain name feature only balance traffic at the region level. If multiple clusters exist in the same region, service requests are randomly sent among clusters.

Billing

  • The global domain name feature is based on Private DNS. For more information about the billing rules, see Pricing.

  • After the primary cluster is switched and if the original primary cluster and the new primary cluster are in different regions, you are charged for cross-region data transmission. For more information about the billing rules, see Overview of VPC peering connections.

Create a global domain name

Important

Make sure that your primary cluster is of Enterprise Edition. The settings are displayed only when you select an Enterprise Edition cluster as the primary cluster.

  1. Create a GND. Specify whether to create a global domain name in this step.

    image

  2. Create a secondary cluster

  3. Create a VPC peering connection. If multiple clusters exist, make sure that a peering connection is created between any two of the VPCs where the clusters are deployed. This ensures that cross-VPC access is supported after the primary cluster is forcibly switched.

  4. Verify that the VPC peering connection is valid.

    Note

    After you switch the VPCs of the clusters, you can perform a cluster switching test to check whether the clusters are connected.

    Assume that the primary cluster is in China (Beijing) and the secondary cluster is in China (Shanghai). You can add the ECS instance IP address in the China (Shanghai) VPC to the whitelist of the primary cluster. Connect the ECS instance in China (Beijing) VPC to the internal endpoint of the cluster in China (Shanghai) by using the MySQL tool. If they are connected, the VPC peering connection from the China (Beijing) VPC to the China (Shanghai) VPC is valid. The same way can be used to check whether the VPC peering connection from the China (Shanghai) VPC to the China (Beijing) VPC is valid.

    mysql -hpc-xxxxxxxx.rwlb.rds.aliyuncs.com  -P3306 -uxxxx -pxxxx
  5. Verify that the nearest cluster can be accessed.

    Assume that the primary cluster is in China (Beijing) and the secondary cluster is in China (Shanghai). You use an ECS instance in the China (Beijing) VPC to perform ping operations to examine the internal endpoint and global domain name of the primary cluster. If the resolved IP address points to the global domain name, the global domain name is used and the nearest cluster IP address can be returned. The same way can be used to verify the secondary cluster.

Modify a global domain name

  1. Log on to the PolarDB console.

  2. In the left-side navigation pane, click Global Database Network.

  3. Find the GDN and the global domain name, and then click Disable.

    image

    Note

    After the global domain name of a GDN is disabled, you can enable it again if required.

  4. In the Disable Global Domain Name message, click OK.

Perform a cluster switching test

Assume that the primary cluster is in China (Beijing) and the secondary cluster is in China (Shanghai). After you switch the primary cluster as specified in Manage a secondary cluster, try to reconnect to the global domain name and record the recovery time.

  • After a general switching, the cluster in China (Beijing) becomes the secondary cluster and the cluster in China (Shanghai) becomes the primary cluster. An ECS instance in the China (Beijing) VPC tries to connect to the global domain name and can access the cluster in China (Beijing), which becomes the secondary cluster. Read requests are sent to this cluster, while write requests are automatically routed to the cluster in China (Shanghai).

  • After a forcible switching, the original primary cluster is removed from the GDN, and the new primary cluster is the cluster in China (Shanghai). If an ECS instance in the China (Beijing) VPC tries to connect to the global domain name, the cluster in China (Shanghai) is automatically connected (in cross-VPC mode). In this case, both read and write requests are routed to the cluster in China (Shanghai).