You can use Data Transmission Service (DTS) to synchronize data from a Db2 for LUW database to an ApsaraDB RDS for MySQL instance.
Prerequisites
You have created a destination ApsaraDB RDS for MySQL instance. For more information, see Create an ApsaraDB RDS for MySQL instance.
If you need to perform full synchronization, the storage space of the destination database must be larger than the space occupied by the source database.
Limitations
Limit type | Description |
Limits on the source database |
|
Other limits |
|
Special cases | The source Db2 for LUW database is a self-managed database. When you synchronize data from the Db2 for LUW database, note the following items:
|
Billing
Synchronization type | Fee |
Full data synchronization | Free of charge |
Incremental data synchronization | Charged. See Billing overview. |
Supported synchronization topologies
One-to-one one-way synchronization
One-to-many one-way synchronization
Cascading one-way synchronization
Many-to-one one-way synchronization
For more information about the synchronization topologies and their considerations, see Data synchronization topologies.
Supported SQL operations
Operation type | SQL statement |
DML | INSERT, UPDATE, DELETE |
Preparations
Create accounts and grant permissions
Database
Required permissions
References
Db2 for LUW
DBADM permissions
ApsaraDB RDS for MySQL
Read and write permissions on the synchronization objects in the destination database
Enable the log archiving feature for the Db2 for LUW database. For more information, see logarchmeth1 - Primary log archive method configuration parameter and logarchmeth2 - Secondary log archive method configuration parameter.
Procedure
Go to the sync task list page of the destination region. You can use one of the following two methods:
From the DTS console
Log on to the Data Transmission Service (DTS) console.
In the navigation pane on the left, click Data Synchronization.
In the upper-left corner of the page, select the region where the sync instance is located.
From the DMS console
NoteThe actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode and Customize the layout and style of the DMS interface.
Log on to Data Management (DMS).
In the top menu bar, choose .
To the right of Data Synchronization Tasks, select the region where the sync instance is located.
Click Create Task to open the task configuration page.
Optional: In the upper-right corner of the page, click New Configuration Page.
NoteIf the button in the upper-right corner is Back to Previous Version, you can skip this step.
The new and old configuration pages have different parameters. We recommend that you use the new configuration page.
Configure the source and destination databases.
Section
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 have to be unique.
Source Database
Select Existing Connection
To use a database instance that is added to the system (newly created or saved), select the database instance from the drop-down list. The database information is automatically configured.
NoteIn the DMS console, this configuration item is named Select a DMS database instance..
If you have not added the database instance to the system, or you do not need to use an instance that is already added, manually configure the following database information.
Database Type
Select DB2 for LUW.
Connection Type
Select a value based on the deployment location of the source database. This topic uses Self-managed Database on ECS as an example.
NoteIf the source instance is a self-managed database, you must also complete the necessary preparations. For more information, see Preparations for connecting to a self-managed database.
Instance Region
Select the region where the Db2 for LUW database is located.
Replicate Data Across Alibaba Cloud Accounts
This example uses a database instance that belongs to the current Alibaba Cloud account. Select No.
ECS Instance ID
Enter the ID of the ECS instance that hosts the Db2 for LUW database.
Port
Enter the service port of the Db2 for LUW database. The default value is 50000.
Database Name
Enter the name of the database in the source Db2 for LUW instance that contains the objects to be synchronized.
Database Account
Enter the database account for the Db2 for LUW database. For permission requirements, see Create accounts and grant permissions.
Database Password
Enter the password that corresponds to the database account.
Destination Database
Select Existing Connection
To use a database instance that is added to the system (newly created or saved), select the database instance from the drop-down list. The database information is automatically configured.
NoteIn the DMS console, this configuration item is named Select a DMS database instance..
If you have not added the database instance to the system, or you do not need to use an instance that is already added, manually configure the following database information.
Database Type
Select MySQL.
Connection Type
Select Alibaba Cloud Instance.
Instance Region
Select the region where the destination ApsaraDB RDS for MySQL instance is located.
Replicate Data Across Alibaba Cloud Accounts
This example uses a database instance that belongs to the current Alibaba Cloud account. Select No.
RDS Instance ID
Select the ID of the destination ApsaraDB RDS for MySQL instance.
Database Account
Enter the database account for the destination ApsaraDB RDS for MySQL instance. For permission requirements, see Create accounts and grant permissions.
Database Password
Enter the password that corresponds to the database account.
Connection Method
Select Non-encrypted or SSL-encrypted as needed. If you select SSL-encrypted, you must enable SSL encryption for the RDS for MySQL instance in advance. For more information, see Use a cloud certificate to quickly enable SSL encryption.
After you complete the configuration, click Test Connectivity and Proceed at the bottom of the page. In the CIDR Blocks of DTS Servers dialog box, click Test Connectivity.
NoteEnsure that the IP address CIDR blocks of DTS servers are added to the security settings of the source and destination databases to allow access from DTS servers. This can be done automatically or manually. For more information, see Add the IP address CIDR blocks of DTS servers to a whitelist.
Configure task objects.
On the Configure Objects page, configure the objects to synchronize.
Parameter
Description
Synchronization Types
The synchronization types. By default, Incremental Data Synchronization is selected. You must also select Schema Synchronization and Full Data Synchronization. After the precheck is complete, DTS synchronizes the historical data of the selected objects from the source database to the destination cluster. The historical data is the basis for subsequent incremental synchronization.
Processing Mode of Conflicting Tables
Precheck and Report Errors: DTS checks for tables with the same name in the destination database. If a conflict exists, DTS reports an error during the precheck and does not start the task.
NoteIf it is not practical to delete or rename the conflicting table, you can map the table to a different name. For more information, see Map object names.
Ignore Errors and Proceed: Skips the check for tables with the same name in the destination database.
WarningIf you select Ignore Errors and Proceed, data inconsistency may occur. For example:
If the table schemas are consistent, destination records with the same primary or unique key as source records are overwritten.
If the table schemas are inconsistent, the task may fail or only partially synchronize data. Proceed with caution.
Source Objects
In the Source Objects box, click an object to synchronize, and then click
to move it to the Selected Objects box.NoteYou can select databases, tables, and columns as synchronization objects. If you select tables or columns, other objects such as views, triggers, and stored procedures are not synchronized to the destination database.
Selected Objects
To rename an object in the target instance, right-click the synchronization object in the Selected Objects box. For configuration instructions, see Map a single schema, table, or column name.
To rename multiple objects in the target instance at once, click Selected Objects in the upper-right corner of the Batch Edit box. For configuration instructions, see Map schema, table, and column names in batches.
NoteTo select the SQL operations to be synchronized at the database or table level, right-click the object in the Selected Objects box and select the desired SQL operations in the dialog box.
To set a WHERE clause to filter data, right-click the table in the Selected Objects box and set the filter condition in the dialog box. For instructions, see Set filter conditions.
Click Next: Advanced Settings to configure advanced parameters.
Parameter
Description
Dedicated Cluster for Task Scheduling
By default, DTS schedules tasks on a shared cluster, and you do not need to select a cluster. For more stable performance, you can purchase a dedicated cluster to run DTS sync tasks. For more information, see What is a DTS dedicated cluster?.
Retry Time for Failed Connections
After a sync 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 also specify a custom retry duration from 10 to 1,440 minutes. We recommend that you set the duration to 30 minutes or more. If DTS successfully reconnects to the database within the specified duration, the sync task automatically resumes. Otherwise, the task fails.
NoteIf you have multiple DTS instances (for example, Instance A and Instance B) that share the same source or destination, and you set the network retry time to 30 minutes for Instance A and 60 minutes for Instance B, the shorter duration of 30 minutes is used for both.
Because DTS charges for task runtime during the connection retry period, we recommend that you customize the retry duration 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 sync task starts, if other non-connectivity issues occur with the source or destination database (such as DDL or DML execution exceptions), DTS reports an error and immediately starts continuous retry operations. The default retry duration is 10 minutes. You can also customize the retry duration within the range of 1 to 1,440 minutes. We recommend that you set it to 10 minutes or more. If the relevant operations are successful within the set retry duration, the sync task automatically resumes. Otherwise, the task fails.
ImportantThe value for Retry Time for Other Issues must be less than that for Retry Time for Failed Connections.
Enable Throttling for Full Data Synchronization
During the full synchronization stage, DTS consumes read and write resources from the source and destination databases, which can increase the database load. To reduce the load on the source and destination databases, you can set a rate limit for the full synchronization task by configuring the Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) parameters.
NoteThis configuration item is available only when Synchronization Types is set to Full Data Synchronization.
You can also adjust the full synchronization rate after the sync instance is running.
Enable Throttling for Incremental Data Synchronization
You can also set a rate limit for the incremental synchronization task. To relieve pressure on the destination database, set the RPS of Incremental Data Synchronization and Data synchronization speed for incremental synchronization (MB/s).
Environment Tag
You can select an environment tag to identify the instance. This is not required for this example.
Configure ETL
Choose whether to enable the extract, transform, and load (ETL) feature. For more information, see What is ETL? Valid values:
Yes: Enables the ETL feature. Enter data processing statements in the code editor. For more information, see Configure ETL in a data migration or data synchronization task.
No: Disables the ETL feature.
Monitoring and Alerting
Specify whether to configure alerts. If the synchronization fails or the latency exceeds the specified threshold, a notification is sent to an alert contact.
No: No alerts are configured.
Yes: Configure alerts by setting an alert threshold and specifying an alert notification. For more information, see Configure monitoring and alerting during task configuration.
Click Next: Data Validation to configure a data validation task.
If you want to use the data validation feature, see Configure data validation for configuration instructions.
Save the task and run a precheck.
To view the API parameters for configuring this instance, hover over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble.
If you have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.
NoteBefore the synchronization job starts, DTS runs a precheck. The job can start only after all precheck items pass.
If the precheck fails, click View Details for the failed item. Fix the issue as prompted, and then run the precheck again.
If the precheck returns a warning:
If a check item fails and cannot be ignored, click View Details next to the item. Follow the instructions to fix the issue, and then run the precheck again.
For check items that can be ignored, you can click Confirm Alert Details, Ignore, OK, and Precheck Again in sequence to skip the warning and rerun the precheck. If you choose to shield the warning item, it may cause issues such as data inconsistency and pose risks to your business.
Purchase the instance.
When the Success Rate is 100%, click Next: Purchase Instance.
On the Purchase page, select the billing method and link specification for the data synchronization instance. The following table describes these parameters in detail.
Category
Parameter
Description
New Instance Class
Billing Method
Subscription: You pay when you create the instance. This is suitable for long-term needs and is more cost-effective than pay-as-you-go. The longer the subscription duration, the higher the discount.
Pay-as-you-go: You are charged on an hourly basis. This is suitable for short-term needs. You can release the instance immediately after use to save costs.
Resource Group Configuration
The resource group to which the instance belongs. The default is default resource group. For more information, see What is Resource Management?.
Link Specification
DTS provides sync specifications with different performance levels. The sync link specification affects the synchronization rate. You can choose a specification based on your business scenario. For more information, see Data synchronization link specifications.
Subscription Duration
In subscription mode, select the duration and quantity for the subscription instance. You can choose a monthly subscription from 1 to 9 months, or a yearly subscription of 1, 2, 3, or 5 years.
NoteThis option is only available when the billing method is Subscription.
After you complete the configuration, read and select Data Transmission Service (Pay-as-you-go) Service Terms.
Click Buy and Start. In the OK dialog box, click OK.
You can view the task progress on the Data Synchronization page.