Migrate data from PolarDB-X 2.0 to Tablestore

Updated at:

Data Transmission Service (DTS) supports migrating data from PolarDB-X 2.0 to Tablestore.

Prerequisites

  • A Tablestore instance has been created. For more information, see Create an instance.

  • Obtain the AccessKey ID and AccessKey secret of the Alibaba Cloud account that owns the Tablestore instance. For more information, see Create an AccessKey.

Notes

Type

Description

Source database limits

  • The tables to be migrated must have a primary key or a UNIQUE constraint, and the fields must be unique. Otherwise, duplicate data may appear in the destination database.

  • If you migrate data at the table level and need to edit the objects, such as mapping table or column names, split the tables into batches and configure multiple tasks if the number of tables in a single migration task exceeds 5,000. You can also configure a task to migrate the entire database. Otherwise, a request error may be reported after you submit the task.

  • If the names of the tables to be migrated from the source PolarDB-X 2.0 database contain uppercase letters, only schema migration is supported.

  • Binary logging (Binlog) is enabled for PolarDB-X 2.0 by default. Ensure that the binlog_row_image parameter is set to full. For more information about how to view the parameter, see Parameter settings. Otherwise, an error is reported during the precheck and the data migration task cannot be started.

  • Operational limitations on the source database:

    • During schema migration and full data migration, do not perform DDL operations that change the database or table schema. Otherwise, the data migration task will fail.

      Note

      During full data migration, DTS queries the source database. This action places a metadata lock, which may block DDL operations on the source database.

    • If you need to change the network type of the PolarDB-X 2.0 instance during migration, you must update the network connection information of the migration task after the change is complete.

    • If you perform only full data migration, do not write new data to the source database during the migration. Otherwise, data will become inconsistent between the source and destination databases. To maintain real-time data consistency, select schema migration, full data migration, and incremental data migration.

Other limits

  • Before you migrate data, evaluate the performance of the source and destination databases. Migrate data during off-peak hours. Otherwise, initial full data synchronization consumes read and write resources of the source and destination databases, which may increase the database workloads.

  • Initial full data synchronization concurrently runs INSERT operations. This causes table fragmentation in the destination database. Therefore, the tablespace of the destination instance is larger than that of the source instance after the initial full data synchronization is complete.

  • During DTS migration, do not write data to the destination database from sources other than DTS. Otherwise, data inconsistency may occur between the source and destination databases.

  • Data from the tables to be migrated can only be migrated to data tables in Tablestore.

  • The number of tables to be migrated must not exceed the limit of the Tablestore instance (no more than 64). Otherwise, the migration task reports an error. To migrate more than 64 tables, contact Tablestore helpdesk to increase the table limit for the destination Tablestore instance.

  • The names of the tables or columns to be migrated must follow the naming conventions of Tablestore:

    • Table or column names can contain uppercase letters, lowercase letters, digits, and underscores (_). They must start with a letter or an underscore.

    • Table or column names can be 1 to 255 characters in length.

  • If a task fails, DTS support staff will attempt to restore it within eight hours. During restoration, they may restart the task or adjust its parameters.

    Note

    Only DTS task parameters are modified—not database parameters. Parameters that may be adjusted include those listed in Modify instance parameters.

SQL operations supported for incremental migration

Operation type SQL statements
DML INSERT, UPDATE, DELETE

Required database account permissions

Database Schema migration Full data migration Incremental data migration
Source PolarDB-X 2.0 SELECT SELECT REPLICATION SLAVE, REPLICATION CLIENT, and SELECT on objects to migrate

For instructions on creating accounts and granting permissions, see Manage database accounts and Permissions required for an account to synchronize data.

Procedure

  1. Go to the Data Migration Tasks page.

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

    2. In the top menu bar, click Integration & Development.

    3. In the navigation pane on the left, choose Data Transmission (DTS) > Data Migration.

    4. To the right of Migration Tasks, select the region of the migration instance.

    Note
  2. Click Create Task to open the task configuration page.

    1. Optional: In the upper-right corner of the page, click New Configuration Page.

      Note
      • If the button in the upper-right corner of the new configuration page is Back to Previous Version, skip this step.

      • The parameters on the new and old configuration pages are different. Use the new configuration page.

    2. Configure the source and destination databases.

      Category

      Configuration

      Description

      None

      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 an existing DMS database instance. (Optional. If you have not registered a DMS database instance, ignore this option and configure database settings in the section below.)

      Choose whether to use an existing instance as needed.

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

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

      Database Type

      Select PolarDB-X 2.0.

      Access Method

      You can select Alibaba Cloud Instance.

      Instance Region

      Select the region where the source PolarDB-X 2.0 instance is located.

      Replicate Data Across Alibaba Cloud Accounts

      This example shows how to migrate data between instances in the same Alibaba Cloud account. Select No. For more information about cross-account scenarios, see Configure a task for cross-account data migration.

      Instance ID

      Select the ID of the source PolarDB-X 2.0 instance.

      Database Account

      Enter the database account of the source PolarDB-X 2.0 instance. For information about the permission requirements, see Permissions required for database accounts.

      Database Password

      Enter the password for the specified database account.

      Destination Database

      Select an existing DMS database instance. (Optional. If you have not registered a DMS database instance, ignore this option and configure database settings in the section below.)

      Choose whether to use an existing instance as needed.

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

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

      Database Type

      Select Tablestore.

      Access Method

      Select Alibaba Cloud Instance.

      Instance Region

      Select the region where the destination Tablestore instance is located.

      Instance ID

      Select the name of the destination Tablestore instance.

      AccessKey ID of Alibaba Cloud Account

      Enter the AccessKey ID of the Alibaba Cloud account that owns the Tablestore instance. The AccessKey ID is used to identify the user.

      Important

      If you enter the AccessKey ID of a RAM user, you must grant the AliyunOTSFullAccess permission to the RAM user. This permission allows the RAM user to manage Tablestore. For more information, see Grant permissions to a RAM user using a RAM policy.

      AccessKey Secret of Alibaba Cloud Account

      Enter the AccessKey secret of the Alibaba Cloud account that owns the Tablestore instance. The AccessKey secret is used to verify the identity of the user.

    3. After you complete the configuration, click Test Connectivity and Proceed at the bottom of the page.

      If the source or destination database is an Alibaba Cloud database instance, such as an RDS for MySQL or ApsaraDB for MongoDB instance, DTS automatically adds the CIDR blocks of DTS servers to the IP address whitelist of the instance. If the source or destination database is a self-managed database hosted on an ECS instance, DTS automatically adds the CIDR blocks of DTS servers to the security group rules of the ECS instance. You must also ensure that the database is accessible from the ECS instance. If the self-managed database is hosted on multiple ECS instances, you must manually add the CIDR blocks of DTS servers to the security group rules of each ECS instance. If the source or destination database is a self-managed database that is deployed in an on-premises data center or provided by a third-party cloud service provider, you must manually add the CIDR blocks of DTS servers to the IP address whitelist of the database to allow access from DTS servers. For more information about the IP addresses of DTS servers, see CIDR blocks of DTS servers.

      Warning

      Adding the public IP address blocks of DTS servers, whether automatically or manually, may introduce security risks. Using this product, you acknowledge and accept these potential risks. You must implement basic security measures, such as using strong passwords, limiting open ports for each CIDR block, using authentication for internal API calls, and regularly checking and restricting unnecessary CIDR blocks. You can also connect using an internal network, such as a leased line, VPN Gateway, or Smart Access Gateway.

  3. Configure the task objects.

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

      Configuration

      Description

      Migration Types

      • If you only need to perform a full 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 Schema Migration, you must ensure that a database and tables to receive the data exist in the destination database. You can also use the object name mapping feature in the Selected Objects box as needed.

      • If you do not select Incremental Data Migration, do not write new data to the source instance during 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.

      Operation Types

      Select the operation types to migrate based on your business needs. By default, all operation types are selected.

      Processing Policy of Dirty Data

      Select the policy to handle data write errors. Valid values:

      • Skip

      • Block

      Data Write Mode

      Select the data write mode. Valid values:

      • Overwrite Row: Overwrites data at the row level using UpdateRowChange.

      • Update Row: Updates data in a row using PutRowChange.

      Batch Write Mode

      The API operation to call for batch writes. Valid values:

      • BulkImportRequest: Performs an offline write.

      • BatchWriteRowRequest: Performs a batch write operation.

      Note

      We recommend that you select BulkImportRequest to improve read and write efficiency and reduce billing costs for your Tablestore instance.

      More

      If needed, click More to configure the following parameters:

      • Queue Size: The length of the queue for the process that writes data to the Tablestore instance.

      • Thread Quantity: The number of callback handler threads for writing data to the Tablestore instance.

      • Concurrency: The maximum number of concurrent requests for the Tablestore instance.

      • Buckets: Specifies the number of concurrent buckets used to write incremental data sequentially. Increasing this value can improve concurrent write performance.

        Note

        The value for Buckets cannot exceed the value for Concurrency.

      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

      In the Source Objects box, click the objects to migrate, and then click Right arrow to move them to the Selected Objects box.

      Note
      • You can select objects to migrate at the database or table level. If you select tables as the migration objects, other objects such as views, triggers, and stored procedures are not migrated to the destination database.

      • You can migrate tables from only one database. This means you can select one database or multiple tables from the same database.

      Selected Objects

      Note
      • Database name mapping is not supported. You can map table and column names only when you select tables as the migration objects. If you use the mapping feature, the migration of other objects that depend on the mapped object may fail.

      • When you use the column name mapping feature, you can modify the type of the corresponding column in the destination Tablestore instance.

      • To filter data with a WHERE clause, right-click the table in the Selected Objects box and set the filter condition in the dialog box that appears. For more information, see Set a filter condition.

    2. Click Next: Advanced Settings.

      Configuration

      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

      As needed, you can select an environment tag to identify the instance. In this example, no tag is selected.

      Configure ETL

      Select No because the extract, transform, and load (ETL) feature is not supported.

      Whether to delete SQL operations on heartbeat tables of forward and reverse tasks

      Choose whether DTS writes heartbeat SQL information to the source database while the instance is running.

      • Yes: Does not write heartbeat SQL information to the source database. The DTS instance may display latency.

      • No: Writes heartbeat SQL information to the source database. This may interfere with source database operations like physical backups and cloning.

      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: Configure Database and Table Fields, and then click OK in the Note dialog box.

      By default, DTS sets the primary key of the source table as the Primary Key Column. To modify this, set Definition Status to All.

      Note

      You can create a composite primary key by selecting multiple columns for the Primary Key Column.

  4. At the bottom of the page, click Next: Save Task and Pre-check.

    • To view the API operation parameters for configuring this instance, move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters in the pop-up that appears.

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

    Note
    • Before the migration task starts, DTS performs a precheck. The migration task can start only after all precheck items are passed.

    • If the precheck fails, click View Details next to the failed item. Resolve the issue and run the precheck again.

    • If a warning is reported for a check item:

      • For failed checks that cannot be ignored, click View Details next to the check. Resolve the issue and run the precheck again.

      • To ignore a warning for a check item, click Confirm Warning Details, Confirm Ignore, and OK. Then, click Rerun Precheck to run the precheck again. If you choose to ignore a warning, data inconsistency may occur and pose risks to your business.

  5. If the Precheck success rate is 100%, click Next: Purchase.

  6. Purchase the instance.

    1. 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.

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

    3. 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.

  7. Verify the result.

    1. Log on to the Tablestore console.

    2. At the top of the page, select a resource group and a region.

    3. On the Overview page, click the instance name, or click Instance Management in the Actions column for the instance.

    4. On the Instance Details tab, click Data Table List to query the migrated table data.