Migrate data between ApsaraDB RDS for PostgreSQL instances across accounts
Use one-click cloud migration to move data between ApsaraDB RDS for PostgreSQL instances across accounts. The feature also supports self-managed databases on ECS or in data centers.
Prerequisites
-
The ApsaraDB RDS for PostgreSQL instances must meet the following requirements:
-
The source and destination instances run the same major version of PostgreSQL. PostgreSQL 10 and later are supported.
-
The destination instance is a primary instance. Read-only instances do not support one-click cloud migration.
-
The destination instance uses cloud disks.
-
The destination instance contains no data and has enough available storage for all data from the source instance.
-
The VPC CIDR blocks of the source and destination instances do not overlap.
-
-
Cross-account migration requires cross-account authorization for network instances. For more information, see Cross-account authorization for network instances.
Usage notes
Cross-account migration requires Cloud Enterprise Network (CEN) to connect the instances over an internal network. CEN incurs additional charges. For more information, see Billing overview.
Procedure
This example migrates data from an RDS PostgreSQL instance in Account A to an instance in Account B. Account B also owns the CEN instance.
-
In Account B, configure CEN to connect the two RDS PostgreSQL instances over an internal network.
-
Create a CEN instance.
-
Log on to the CEN console.
-
On the CEN Instance page, click Create CEN Instance.
-
On the Create CEN Instance page, configure the parameters in the following table and click OK.
Parameter
Description
Name
The name of the CEN instance.
Description
The description of the CEN instance.
-
-
Attach both VPCs to the CEN instance.
-
On the CEN Instance page, click the CEN instance ID.
-
On the Basic Information page, click the
icon next to the VPC count to attach a VPC to the CEN instance. -
On the Connection with Peer Network Instance page, configure the parameters in the following table and click Confirm Creation.
NoteAttach the source and destination VPCs separately. The following table describes the source VPC configuration. Repeat the procedure for the destination VPC. Change the Region and Networks parameters to the destination instance's region and VPC. Set Account to Current Account.
Parameter
Description
Instance Type
The default value is VPC. Leave this setting unchanged.
Region
Select the region in which the source instance resides.
Transit Router
If no transit router exists in the region, CEN creates one. Select its primary and secondary zones.
Account
After you select Another Account, enter the UID of Account A, which owns the source instance.
NoteClick the user icon in the top navigation bar to view the account UID.
Connection Name
Specify a custom name.
Networks
Select the source instance's VPC. In the ApsaraDB RDS console, go to the Database Connection page of the source instance. Confirm that the network type is VPC, and record the VPC ID (such as
vpc-2z***) and the internal port5432.Select a vSwitch in each of the transit router's primary and secondary zones.
After both VPCs are attached, check the Basic Information page. In this example, the VPC count is 2. The Transit Router list contains two instances: one for Account A in China (Beijing) and one for Account B in China (Hangzhou). Both have the status Available, confirming that the cross-account connections are ready.
-
-
(Optional) Purchase cross-region bandwidth.
NotePerform this step only if the instances are in different regions, such as Account A in China (Beijing) and Account B in China (Hangzhou). For instances in the same region, skip to step 2: Configure the source instance.
-
On the CEN Instance page, click the CEN instance ID.
-
On the Basic Information page, click the Bandwidth Plans tab, and then click Purchase Bandwidth Plan (Subscription).
-
On the purchase page, configure the bandwidth plan as described in the following table. Click Buy Now and complete the payment.
Parameter
Description
Product Type
-
Non-cross-border: connects areas within the Chinese mainland or areas outside the Chinese mainland. Examples include Chinese mainland to Chinese mainland and Asia Pacific to North America.
-
Cross-border: connects the Chinese mainland to an area outside the Chinese mainland, such as North America.
In this example, select Non-cross-border.
CEN
Keep the current CEN instance selected. The bandwidth plan is automatically associated with this instance after purchase.
Area A
Select the geographic area of the network instances to connect. In this example, select Chinese Mainland.
NoteThe selected areas cannot be changed after the bandwidth plan is created.
Area B
Select the geographic area of the network instances to connect. In this example, select Chinese Mainland.
Billing Method
The bandwidth plan's billing method. The default is Pay-By-Bandwidth.
Bandwidth value
Select the bandwidth in Mbps.
Bandwidth Plan Name
Enter the name of the bandwidth plan.
Duration
Select the subscription duration of the bandwidth plan.
Select Auto-renewal to enable auto-renewal for the bandwidth plan.
Resource Group
Select the resource group to which the bandwidth plan belongs.
This parameter is available only for non-cross-border bandwidth plans.
-
After purchase, go to the Bandwidth Plans tab and confirm that the bandwidth plan is associated with the CEN instance. This example uses 50 Mbps.
-
-
(Optional) Set the cross-region bandwidth.
NotePerform this step only if the instances are in different regions, such as Account A in China (Beijing) and Account B in China (Hangzhou). For instances in the same region, skip to step 2: Configure the source instance.
-
On the CEN Instance page, click the CEN instance ID.
-
On the Basic Information page, click the Bandwidth Plans tab, and then click Set Inter-region Bandwidth.
-
On the Connection with Peer Network Instance page, configure the cross-region connection and click OK.
Parameter
Description
Instance Type
Select Inter-region Connection.
Region
The region of the source instance. In this example, select China (Beijing).
Transit Router
The existing transit router is selected automatically.
Peer Region
The region of the destination instance. In this example, select China (Hangzhou).
Transit Router
The existing transit router is selected automatically.
Bandwidth Allocation Method
Select how to allocate bandwidth. Valid values:
-
Allocate from Bandwidth Plan
-
Pay-By-Data-Transfer
This topic uses Allocate from Bandwidth Plan as an example.
Bandwidth Plan
Select a bandwidth plan associated with the CEN instance.
NoteConfigure this parameter only when Bandwidth Allocation Method is set to Allocate from Bandwidth Plan.
Bandwidth
Enter the allowed bandwidth in Mbps.
Default Line Type
The link type used by default. Valid values:
-
Platinum
-
Gold
NoteWhen Bandwidth Allocation Method is set to Pay-By-Data-Transfer, Platinum is available. Otherwise, it is unavailable.
-
After creating the connection, go to the Bandwidth Plans tab. Confirm that Allocated Bandwidth matches the configured value, such as 50 Mbps. This confirms that the cross-region bandwidth is configured.
-
-
-
Configure the source instance.
-
Configure the IP whitelist.
Follow the instructions in Configure an IP address whitelist. Set IP Addresses to the VPC CIDR block of the destination instance.
-
Create a privileged account.
For information about how to create an account, see Create an account. Set Account Type to privileged account.
NoteThe migration account must have the CREATE ROLE, REPLICATION, and pg_monitor permissions. Use an existing privileged account if one is available.
-
-
Configure the destination instance.
-
Perform the cloud migration assessment.
Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.
-
In the left-side navigation pane, click Cloud Migration/DR Deployment and then click the Feasibility Assessment tab.
-
In the Configure Scenario and Source Type step of the configuration wizard, set the scenario to Migration to Cloud and set the source to ApsaraDB RDS Instance. Click Next.
-
In the Configure Destination Instance step, click Next.
-
In the Configure Source Instance step, select all configuration preparation items and click Next.
-
In the Start Feasibility Assessment step, configure the source database information.
Parameter
Description
Migration Task Name
The task name is generated automatically. Leave it unchanged.
Source VPC/DNS IP
Enter the internal endpoint of the source instance. For more information, see View and change the endpoints and port numbers.
Source Port
Enter the port of the source instance. For more information, see View and change the endpoints and port numbers.
Username
Enter the privileged account created on the source instance.
Password
Enter the password of the source instance's privileged account.
-
Click Create Feasibility Assessment Task.
NoteDuring the migration assessment task, the instance status changes to Maintaining Instance.
After the assessment finishes, go to the Feasibility Assessment page. Check the task status in the Migration to Cloud list.
-
The cloud migration step is available only when Status is Successful.
-
If Status is Failed, click View Report in the Actions column and troubleshoot the errors. For common errors, see Introduction to cloud migration assessment reports.
-
-
Migrate data to the cloud.
Log on to the ApsaraDB RDS console and go to the Instances page. In the top navigation bar, select the region in which the RDS instance resides. Then, find the RDS instance and click the instance ID.
-
In the left-side navigation pane, click Cloud Migration/DR Deployment. On the Migration to Cloud tab, click Create Cloud Migration Task.
-
In the Create Cloud Migration Task dialog box, select a successful cloud migration assessment task from the Associated Assessment Task list.
NoteAfter Associated Assessment Task is selected, the Migration Source Type, Source IP/ DNS, Source Port, and Username parameters are filled in automatically. No manual configuration is required.
-
Click Initiate Migration to Cloud. The migration task starts automatically.
ImportantDuring migration, the destination instance status changes to Migrating Data In. The source instance remains readable and writable. Do not run another migration, restart the source instance, or change its specifications.
-
Promote the destination ApsaraDB RDS for PostgreSQL instance to the primary instance.
-
To monitor the migration, click the link in the Cloud Migration Phase column.
-
When the migration reaches Incremental Data Synchronization, go to the Actions column and click Switchover. This promotes the destination RDS PostgreSQL instance to the primary instance so that it can serve application workloads.
-
In the Switchover dialog box, follow the instructions to make the source instance read-only or stop application writes.
NotePerform the following steps to set the source instance to read-only:
-
In Configure instance parameters, set the rds_force_trans_ro_non_sup parameter of the source instance to on.
-
Run the following statement to terminate all existing sessions.
SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE usename not in ('replicator', 'monitor', 'pgsql', 'aurora') AND pid != pg_backend_pid();
-
-
Select all check boxes, click Switch Now, and wait for the migration to complete.
-
-