Migrate data from PolarDB-X 2.0 to Tablestore

更新时间:
复制 MD 格式

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

Prerequisites

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.

  • Source database operation limits:

    • During schema migration and full migration, do not perform DDL operations to change the schema of databases or tables. Otherwise, the data migration task fails.

      Note

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

    • To switch the network type of the PolarDB-X 2.0 instance during migration, update the network connection information for the migration link after the switch is successful.

    • If you perform only full data migration, do not write new data to the source instance. Otherwise, data inconsistency occurs between the source and destination. 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 the task fails, DTS technical support will attempt to recover it within 8 hours. During the recovery process, operations such as restarting the task or adjusting its parameters may be performed.

    Note

    When parameters are adjusted, only DTS task parameters are modified. Database parameters remain unchanged.The parameters that may be modified include but are not limited to those described in Modify instance parameters.

SQL operations that support incremental migration

Operation type

SQL statement

DML

INSERT, UPDATE, DELETE

Permissions required for database accounts

Database

Schema migration

Full migration

Incremental migration

Source PolarDB-X 2.0

SELECT permission

SELECT Permission

REPLICATION SLAVE, REPLICATION CLIENT, and SELECT on the objects to be migrated.

To create a database account and grant permissions:

For a PolarDB-X 2.0 instance, 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 have 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.)

      Select 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, you must enter the following database information.

      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 that corresponds to the 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.)

      Select 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, you must enter the following database information.

      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 ApsaraDB 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 Elastic Compute Service (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 ECS instance can access the database. 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. For more information about the IP addresses of DTS servers, see CIDR blocks of DTS servers.

      Warning

      Automatically or manually adding the public IP address blocks of DTS servers may pose security risks. Using this product, you acknowledge and accept the potential security risks. You must implement basic security measures. These measures include, but are not limited to, 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, ensure that a database and tables to receive the data exist in the destination database. 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 item is passed. If tables with the same names exist, an error is reported during the precheck phase, 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 cluster. The record from the source database is not migrated to the destination database.

          • During incremental migration, DTS does not keep the record in the destination cluster. 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 English 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 it 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 向右小箭头 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

      • To rename an object that you want to migrate to the destination instance, right-click the object in the Selected Objects section. For more information, see Individual table column mapping.

      • To rename multiple objects at a time, click Batch Edit in the upper-right corner of the Selected Objects section. For more information, see Map multiple object names at a time.

      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 starts continuous retry attempts. The default retry duration is 720 minutes. You can also customize the retry time within a range of 10 to 1440 minutes. We recommend that you set it to more than 30 minutes. If DTS reconnects to the source and destination databases within the set time, 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 other non-connectivity issues occur in the source or destination database (such as a DDL or DML execution exception), DTS reports an error and immediately starts continuous retry attempts. The default retry duration is 10 minutes. You can also customize the retry time within a range of 1 to 1440 minutes. We recommend that you set it to more than 10 minutes. If the related operations succeed within the set retry time, 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 the full migration phase, DTS consumes some read and write resources of the source and destination databases, which may increase the database load. As needed, you can choose whether to set speed limits 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 pressure 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

      As needed, you can also choose whether 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 pressure 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 to write heartbeat SQL information to the source database when the DTS instance is running.

      • Yes: Heartbeat SQL information is not written to the source database. This may cause the DTS instance to report a delay.

      • No: Writes heartbeat SQL information to the source database. This may interfere with features such as physical backup and cloning of the source database.

      Monitoring and Alerting

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

      • No: Does not set an alert.

      • Yes: Sets an alert. You must also set the alert threshold and alert contacts. The system sends an alert notification if the migration fails or the latency exceeds the threshold.

    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, and in the OK dialog box that appears, click OK.

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

      Note
      • If the migration instance does not include an incremental migration task, it stops automatically. After the instance stops, its Status is Completed.

      • If the migration instance includes an incremental migration task, it does not stop automatically, and the incremental migration task continues to run. While the incremental migration task is running normally, the Status of the instance 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.