Migrate Aurora PostgreSQL to ApsaraDB RDS for PostgreSQL

更新时间:
复制 MD 格式

You can use DTS to migrate data from Amazon Aurora PostgreSQL to Alibaba Cloud services such as ApsaraDB RDS for PostgreSQL and PolarDB for PostgreSQL. This topic uses migration to ApsaraDB RDS for PostgreSQL as an example.

Prerequisites

Precautions

  • A full data migration consumes read and write resources on both the source and destination databases, increasing their server load. This added load can degrade performance or cause service unavailability, especially if your databases have poor performance, low specifications, or are already busy (for example, with many slow SQL queries, tables without primary keys, or deadlocks in the destination database). Before you start the migration, evaluate the performance of both databases and perform the migration during off-peak hours, for example, when CPU utilization is below 30%.

  • Amazon Aurora PostgreSQL 10.0 and earlier do not support incremental migration.

  • A single data migration task can migrate only one database. If you need to migrate multiple databases, you must create a separate data migration task for each.

  • DTS cannot migrate functions written in the C language.

  • If a source table to be migrated lacks a primary key or unique constraint, duplicate data may occur in the destination database.

  • If a data migration task fails, DTS automatically triggers auto-resume. Before you switch your business workloads to the destination instance, you must stop or release the task. This prevents the task from automatically resuming and overwriting data in the destination instance with data from the source database.

Billing

Migration type

Task configuration fee

Internet traffic fee

Schema migration and full data migration

Free of charge.

DTS charges an Internet traffic fee when the Access Method of the destination database is set to Public IP Address. For more information, see Billing overview.

Incremental data migration

Charged. For more information, see Billing overview.

Migration types

  • Schema migration

    DTS migrates the following object types to ApsaraDB RDS for PostgreSQL: TABLE, TRIGGER, VIEW, SEQUENCE, FUNCTION, USER DEFINED TYPE, RULE, DOMAIN, OPERATION, and AGGREGATE.

    Note

    DTS does not migrate functions written in C.

  • Full data migration

    DTS migrates all data from the source objects to ApsaraDB RDS for PostgreSQL.

  • Incremental data migration

    After full data migration, DTS replicates ongoing changes to ApsaraDB RDS for PostgreSQL, minimizing application downtime.

Permissions for database accounts

Database

Schema migration

Full data migration

Incremental data migration

Amazon Aurora PostgreSQL

The USAGE permission on pg_catalog

The SELECT permission on the objects to be migrated

The rds_superuser permission

Alibaba Cloud RDS for PostgreSQL

The CREATE and USAGE permissions on the objects to be migrated

The schema owner permission

The schema owner permission

To create and authorize a database account:

Data migration process

To avoid failures caused by object dependencies, DTS migrates schema and data in the following order.

  1. Migrate the schemas for TABLE, VIEW, SEQUENCE, FUNCTION, USER DEFINED TYPE, RULE, DOMAIN, OPERATION, and AGGREGATE.

  2. Run the full data migration.

  3. Migrate the schemas for TRIGGER and FOREIGN KEY.

  4. Run the incremental data migration.

    Note

    Before starting the incremental data migration, do not perform DDL operations on the migration objects. Otherwise, the migration may fail.

Step 1: Configure Amazon Aurora inbound rules

  1. Log in to the Amazon Aurora console.

  2. Go to the Basic Information page of the Amazon Aurora PostgreSQL instance.

  3. Click the DB identifier of the node whose Role is writer instance.

  4. On the Connectivity and security tab, click the name of the VPC security group that corresponds to the node.

  5. On the Security group settings page, add the IP addresses of the DTS servers for the target region to the inbound rules. For details about the IP address ranges, see Add IP addresses of DTS servers to the IP allowlist of an on-premises database.

    Click the Inbound rules tab, and then click Edit inbound rules. In the Edit inbound rules dialog box, set Type to custom TCP rule and Port range to 5432. For Source, select Custom and enter the IP addresses of the corresponding DTS servers. Click Save rules.

    Note
    • Add only the DTS server CIDR blocks for the region where your destination database is located. For example, if your source database is in Singapore and your destination database is in China (Hangzhou), add only the DTS server CIDR blocks for the China (Hangzhou) region.

    • You can add all the required CIDR blocks at once instead of adding a separate inbound rule for each.

    • If you have other questions, refer to the official Amazon documentation or contact Amazon technical support.

Step 2: Create a database and schema

Create a database and schema in the destination ApsaraDB RDS for PostgreSQL instance that match the source. The source and destination schema names must be identical. Create a database and Manage accounts by using schemas.

Step 3: Configure migration (new console)

  1. Navigate to the migration task list page for the destination region using one of the following methods.

    From the DTS console

    1. Log on to the Data Transmission Service (DTS) console.

    2. In the navigation pane on the left, click Data Migration.

    3. In the upper-left corner of the page, select the region where the migration instance is located.

    From the DMS console

    Note

    The actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode console and Customize the layout and style of the DMS console.

    1. Log on to the Data Management (DMS) console.

    2. In the top menu bar, choose Data + AI > Data Transmission (DTS) > Data Migration.

    3. To the right of Data Migration Tasks, select the region where the migration instance is located.

  2. Click Create Task to navigate to the task configuration page.

  3. Configure the source and destination databases.

    Warning

    After you select the source and destination instances, we recommend that you carefully read the limits displayed at the top of the page. Otherwise, the task may fail or data inconsistency may occur.

    Category

    Parameter

    Description

    N/A

    Task Name

    DTS automatically generates a task name. We recommend that you specify a descriptive name for easy identification. The name does not need to be unique.

    Source Database

    Select a DMS database instance.

    You can choose whether to use an existing instance, as needed.

    • If you use an existing instance, the database information below is automatically filled in. You do not need to enter it again.

    • If you do not use an existing instance, you must configure the database information below.

    Note

    Database Type

    Select PostgreSQL.

    Connection Type

    Select Public IP Address.

    Instance Region

    Select the region of the Amazon Aurora PostgreSQL database. If the exact region is unavailable, select the closest one.

    Note

    If the exact region is not listed, select the geographically closest region.

    Domain Name or IP

    Enter the endpoint of the Amazon Aurora PostgreSQL database.

    Note

    You can find the endpoint on the Basic Information page of the Amazon Aurora PostgreSQL database.

    Port Number

    Enter the service port of the Amazon Aurora PostgreSQL database. Default: 5432.

    Database Name

    Enter the name of the source database to migrate.

    Database Account

    Enter the database account for the Amazon Aurora PostgreSQL instance. For required permissions, see Permissions required for database accounts.

    Database Password

    Enter the password for the database account.

    Encryption

    Select a connection method. In this example, Non-encrypted is selected.

    If you need to connect to the database by using SSL encryption, select SSL-encrypted, and then upload the CA Certificate, Client Certificate, and Private Key of Client Certificate as needed. Then, enter the Private Key Password of Client Certificate.

    Note
    • If you select SSL-encrypted for a self-managed PostgreSQL database, you must upload the CA Certificate.

    • If you need to use a client certificate, you must upload both the Client Certificate and the Private Key of Client Certificate, and then enter the Private Key Password of Client Certificate.

    • For information about the SSL encryption feature for an RDS for PostgreSQL instance, see SSL connection encryption.

    Destination Database

    Select a DMS database instance.

    You can choose whether to use an existing instance, as needed.

    • If you use an existing instance, the database information below is automatically filled in. You do not need to enter it again.

    • If you do not use an existing instance, you must configure the database information below.

    Note

    Database Type

    Select PostgreSQL.

    Connection Type

    Select Alibaba Cloud Instance.

    Instance Region

    Select the region of the destination ApsaraDB RDS for PostgreSQL instance.

    Instance ID

    Select the ID of the destination ApsaraDB RDS for PostgreSQL instance.

    Database Name

    Enter the name of the destination database. This name can be different from the source database name.

    Note

    The database must already exist in the ApsaraDB RDS for PostgreSQL instance. Create a database.

    Database Account

    Enter the database account of the destination ApsaraDB RDS for PostgreSQL instance. For required permissions, see Permissions required for database accounts.

    Database Password

    Enter the password for the database account.

    Encryption

    Select a connection method. In this example, Non-encrypted is selected.

    If you need to connect to the database by using SSL encryption, select SSL-encrypted, and then upload the CA Certificate, Client Certificate, and Private Key of Client Certificate as needed. Then, enter the Private Key Password of Client Certificate.

    Note
    • If you select SSL-encrypted for a self-managed PostgreSQL database, you must upload the CA Certificate.

    • If you need to use a client certificate, you must upload both the Client Certificate and the Private Key of Client Certificate, and then enter the Private Key Password of Client Certificate.

    • For information about the SSL encryption feature for an RDS for PostgreSQL instance, see SSL connection encryption.

  4. When the Success Rate is 100%, click Next: Purchase Instance.

  5. Configure the task objects.

    1. On the Configure Objects page, configure the objects that you want to migrate.

      Parameter

      Description

      Migration Types

      • To perform only a full data migration, select both Schema Migration and Full Data Migration.

      • To perform a migration with no downtime, select Schema Migration, Full Data Migration, and Incremental Data Migration.

      Note

      If you do not select Incremental Data Migration, do not write new data to the source instance during the data migration to ensure data consistency.

      Processing Mode of Conflicting Tables

      • Precheck and Report Errors: Checks whether tables with the same names exist in the destination database. If no tables with the same names exist, the precheck is passed. If tables with the same names exist, an error is reported during the precheck, and the data migration task does not start.

        Note

        If a table in the destination database has the same name but cannot be easily deleted or renamed, you can change the name of the table in the destination database. For more information, see Object name mapping.

      • Ignore Errors and Proceed: Skips the check for tables with the same names.

        Warning

        Selecting Ignore Errors and Proceed may cause data inconsistency and business risks. For example:

        • If the table schemas are consistent and a record in the destination database has the same primary key value as a record in the source database:

          • During full migration, DTS keeps the record in the destination database. The record from the source database is not migrated.

          • During incremental migration, DTS does not keep the record in the destination database. The record from the source database overwrites the record in the destination database.

        • If the table schemas are inconsistent, only some columns of data may be migrated, or the migration may fail. Proceed with caution.

      Capitalization of Object Names in Destination Instance

      You can configure the case sensitivity policy for the names of migrated objects, such as databases, tables, and columns, in the destination instance. By default, DTS default policy is selected. You can also choose to keep the case sensitivity consistent with the default policy of the source or destination database. For more information, see Case sensitivity of object names in the destination database.

      Source Objects

      Select one or more objects from the Source Objects section. Click the Rightwards arrow icon and add the objects to the Selected Objects section.

      Note

      The granularity for selecting migration objects is schema, table, and column. If you select only tables or columns as migration objects, other objects such as views, triggers, and stored procedures are not migrated to the destination database.

      Selected Objects

      Note

      If you use the object name mapping feature, dependent objects may fail migration.

    2. Click Next: Advanced Settings to configure advanced parameters.

      Parameter

      Description

      Dedicated Cluster for Task Scheduling

      By default, DTS schedules tasks on a shared cluster. You do not need to select one. If you want more stable tasks, you can purchase a dedicated cluster to run DTS migration tasks.

      Retry Time for Failed Connections

      After the migration task starts, if the connection to the source or destination database fails, DTS reports an error and immediately begins to retry the connection. The default retry duration is 720 minutes. You can customize the retry time to a value from 10 to 1440 minutes. We recommend that you set the duration to more than 30 minutes. If DTS reconnects to the source and destination databases within the specified duration, the migration task automatically resumes. Otherwise, the task fails.

      Note
      • For multiple DTS instances that share the same source or destination, the network retry time is determined by the setting of the last created task.

      • Because you are charged for the task during the connection retry period, we recommend that you customize the retry time based on your business needs, or release the DTS instance as soon as possible after the source and destination database instances are released.

      Retry Time for Other Issues

      After the migration task starts, if a non-connectivity issue, such as a DDL or DML execution exception, occurs in the source or destination database, DTS reports an error and immediately begins to retry the operation. The default retry duration is 10 minutes. You can customize the retry time to a value from 1 to 1440 minutes. We recommend that you set the duration to more than 10 minutes. If the related operations succeed within the specified retry duration, the migration task automatically resumes. Otherwise, the task fails.

      Important

      The value of Retry Time for Other Issues must be less than the value of Retry Time for Failed Connections.

      Enable Throttling for Full Data Migration

      During full migration, DTS consumes read and write resources on the source and destination databases, which may increase the database load. If required, you can enable throttling for the full migration task. You can set Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) to reduce the load on the destination database.

      Note
      • This configuration item is available only if you select Full Data Migration for Migration Types.

      • You can also adjust the full migration speed after the migration instance is running.

      Enable Throttling for Incremental Data Migration

      If required, you can also choose to set speed limits for the incremental migration task. You can set RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) to reduce the load on the destination database.

      Note
      • This configuration item is available only if you select Incremental Data Migration for Migration Types.

      • You can also adjust the incremental migration speed after the migration instance is running.

      Environment Tag

      Select an environment tag to identify the instance. In this example, no tag is required.

      Configure ETL

      Choose whether to enable the extract, transform, and load (ETL) feature. For more information, see What is ETL? Valid values:

      Monitoring and Alerting

      Select whether to set alerts and receive alert notifications based on your business needs.

      • No: Does not set an alert.

      • Yes: Configure alerts by setting an alert threshold and an alert contact. If a migration fails or the latency exceeds the threshold, the system sends an alert notification.

    3. Click Next: Data Validation to configure a data validation task.

      For more information about the data validation feature, see Configure data validation.

  6. Save the task and run a precheck.

    • To view the parameters for configuring this instance when you call the API operation, move the pointer over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble that appears.

    • If you do not need to view or have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.

    Note
    • Before the migration task starts, DTS performs a precheck. The task starts only after it passes the precheck.

    • If the precheck fails, click View Details next to the failed check item, fix the issue based on the prompt, and then run the precheck again.

    • If a warning is reported during the precheck:

      • For check items that cannot be ignored, click View Details next to the failed item, fix the issue based on the prompt, and then run the precheck again.

      • For check items that can be ignored, you can click Confirm Alert Details, Ignore, OK, and Precheck Again to skip the alert item and run the precheck again. If you choose to ignore a warning, it may cause issues such as data inconsistency and pose risks to your business.

  7. Purchase the instance.

    1. When the Success Rate is 100%, click Next: Purchase Instance.

    2. On the Purchase page, select the link specification for the data migration instance. For more information, see the following table.

      Category

      Parameter

      Description

      New Instance Class

      Resource Group Settings

      Select the resource group to which the instance belongs. The default value is default resource group. For more information, see What is Resource Management?

      Instance Class

      DTS provides migration specifications with different performance levels. The link specification affects the migration speed. You can select a specification based on your business scenario. For more information, see Data migration link specifications.

    3. After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.

    4. Click Buy and Start. In the OK dialog box that appears, click OK.

      You can view the progress of the migration task on the Data Migration Tasks list page.

      Note
      • If the migration task does not include incremental migration, it stops automatically after the full migration is complete. After the task stops, its Status changes to Completed.

      • If the migration task includes incremental migration, it does not stop automatically. The incremental migration task continues to run. While the incremental migration task is running, the Status of the task is Running.

Step 3: Configure migration (old console)

  1. Log on to the DTS console.

    Note

    If you are automatically redirected to the Data Management (DMS) console, you can click the jiqiren icon in the lower-right corner and then click 返回旧版 to return to the classic DTS console.

  2. In the left-side navigation pane, click Data Migration.

  3. At the top of the Migration Tasks page, select the region of the destination cluster.

  4. In the upper-right corner of the page, click Create Data Migration Task.

  5. Configure the source and destination instances.

    Category

    Parameter

    Description

    N/A

    Task Name

    DTS automatically generates a task name. Use a descriptive name for easy identification. The name does not need to be unique.

    Source instance

    Instance Type

    Select User-Created Database with Public IP Address.

    Instance Region

    The source instance region. If you select User-Created Database with Public IP Address for Instance Type, this parameter is not required.

    Database Type

    Select PostgreSQL.

    Hostname or IP Address

    Enter the endpoint of the Amazon Aurora PostgreSQL instance.

    Note

    You can find the endpoint on the Basic Information page of the Amazon Aurora PostgreSQL instance.

    Select the writer instance, click the Connectivity & security tab, and find the endpoint (for example, xxx.ap-northeast-2.rds.amazonaws.com) and port (default: 5432) in the Endpoint & port section.

    Port

    Enter the service port of the Amazon Aurora PostgreSQL instance. Default: 5432.

    Database Name

    Enter the name of the source database to migrate.

    Database Account

    Enter the database account for the Amazon Aurora PostgreSQL instance. For required permissions, see Database account permissions.

    Database Password

    Enter the password for the database account.

    Note

    After you enter the source database information, you can click Test Connectivity next to Database Password to verify that the information is correct. If the information is correct, a Passed message appears. If a Failed message appears, click Diagnose after Failed and follow the prompts to adjust the source database information.

    Destination instance

    Instance Type

    Select RDS Instance.

    Instance Region

    Select the region of the destination ApsaraDB RDS for PostgreSQL instance.

    RDS Instance ID

    Select the ID of the destination ApsaraDB RDS for PostgreSQL instance.

    Database Name

    Enter the name of the destination database. This name can be different from the source database name.

    Note

    Create the database and schema in the destination instance before migration. Step 2: Create a database and schema in the destination ApsaraDB RDS instance.

    Database Account

    Enter the database account for the ApsaraDB RDS for PostgreSQL instance. For required permissions, see Database account permissions.

    Database Password

    Enter the password for the database account.

    Note

    After you enter the target database information, you can click Test Connectivity next to Database Password to verify that the entered information is correct. If the information is correct, a Passed message is displayed. If a Failed message is displayed, click Diagnose next to Failed, and adjust the target database information based on the prompts.

  6. After you complete the configurations, click Set Whitelist and Next in the lower-right corner of the page.

    If the source or destination is an Alibaba Cloud database instance (such as ApsaraDB RDS for MySQL or ApsaraDB for MongoDB) or a self-managed database on an ECS instance, DTS automatically adds its server IP addresses to the instance's whitelist or security group rules. In these cases, you do not need to add the IP addresses manually. However, if the source or destination is a self-managed database in a data center or from another cloud provider, you must manually add the DTS server IP addresses to allow access. For a list of IP addresses to add, see IP addresses of DTS servers.

    Warning

    Adding public IP addresses of DTS servers, whether automatically or manually, may introduce security risks. By using this product, you acknowledge and accept these potential risks. You are responsible for implementing basic security measures, such as using strong passwords, restricting open ports, using authentication for internal APIs, regularly reviewing and limiting unnecessary network segments, or connecting by using private connections such as Express Connect, VPN Gateway, or Smart Access Gateway.

  7. Select migration objects and types.

    Select the migration types and objects.

    Parameter

    Description

    Migration Type

    • For a one-time migration, select Schema Migration and Full Data Migration.

    • To migrate data with minimal downtime, select Schema Migration, Full Data Migration, and Incremental Data Migration.

    Note

    To ensure data consistency, do not write new data to the source database during migration if you do not select Incremental Data Migration.

    Migration Objects

    In the Available Objects section, select objects to migrate and click 向右小箭头 to move them to the Selected Objects section.

    Note
    • You can select databases, tables, and columns as migration objects.

    • By default, migrated objects retain their original names. To rename objects in the destination, use Object name mapping.

    • Renaming an object may cause dependent objects to fail migration.

    Edit Mapped Names

    To rename objects in the destination instance, use Object name mapping.

    Connection Retry Duration

    The duration for which DTS retries connections to a disconnected database. Default: 12 hours. You can specify a custom duration. If DTS reconnects within this duration, the task resumes automatically. Otherwise, the task fails.

    Note

    The DTS instance continues to incur charges during retries. Set the retry duration based on your business needs. Release the DTS instance promptly after the source and destination instances are released.

  8. After you complete the configuration, click Precheck and Start in the lower-right corner of the page.

    Note
    • Before the migration task starts, DTS runs a precheck. The task can start only after it passes the precheck.

    • If the precheck fails, click the 提示 icon next to the failed item to view details.

      • Fix the issues as prompted and run the precheck again.

      • If you do not need to fix the warning items, you can select Ignore and then click Ignore Warnings and Rerun Precheck to run the precheck again.

  9. After the task passes the precheck, click Next.

  10. In the Confirm Settings dialog box that appears, select a Instance Class and select the Data Transmission Service (pay-as-you-go) Service Terms checkbox.

  11. Click Buy and Start to start the data migration task.
    Note We recommend that you do not manually stop the task during full data migration. Otherwise, the data migrated to the destination database will be incomplete. You can wait until the data migration task automatically stops.
    Full data migration
  12. Switch your workloads to the ApsaraDB RDS for PostgreSQL instance.