This topic explains how to use the DTS console to migrate data between ApsaraDB RDS for SQL Server instances. You can configure schema migration, full data migration, and incremental data migration. Combining these migration types enables a smooth data migration without application downtime.
Prerequisites
-
The source and target RDS SQL Server instances must exist.
-
The target instance's storage space must be greater than the storage used by the source instance. If it is insufficient, increase the storage space for the instance.
Precautions
Review these precautions before you start the migration. Otherwise, the task may fail or report an error:
-
Database count limit: A single migration task can migrate a maximum of 10 databases. Exceeding this limit can compromise stability and performance.
-
Table count limit: If a task includes incremental migration, it can synchronize a maximum of 1,000 tables from the source database. Exceeding this limit may cause task latency or instability.
-
Source database operation restrictions: During the schema migration and full migration phases, do not perform DDL operations on the database or table schemas. Otherwise, the migration task will fail.
-
Table structure requirements: Tables to be migrated must have a primary key or a unique constraint. Otherwise, data duplication may occur in the destination database.
-
Foreign keys and triggers: If the migration task includes incremental migration, you must disable active triggers and foreign keys in the destination database. Otherwise, the task may fail or data loss may occur.
-
Database naming conventions: If a database name does not comply with the naming conventions of RDS SQL Server, you must manually create the database in RDS SQL Server before the migration. Otherwise, the task may not run correctly.
-
Transaction log retention period: For an incremental migration task, the transaction logs in the source database must be retained for more than 24 hours. For a task that includes both full and incremental migration, the transaction logs must be retained for at least 7 days. Otherwise, the task may fail or data inconsistency may occur.
Billing
|
Migration type |
Instance configuration fee |
Internet traffic fee |
|
Schema migration and full data migration |
Free of charge. |
When the Access Method parameter of the destination database is set to Public IP Address, you are charged for Internet traffic. For more information, see Billing overview. |
|
Incremental data migration |
Charged. For more information, see Billing overview. |
Permission requirements for database accounts
For a successful data migration, ensure that the source and destination database accounts have the following permissions:
You can use the RDS console to create an account and modify account permissions as needed.
|
Database |
Schema migration |
Full migration |
Incremental migration |
|
Source instance |
Read permission |
Read permission |
Ownership permissions on the objects to be migrated. |
|
Destination instance |
Read/write permission |
||
Procedure
-
Go to the Data Transmission Service (DTS) console.
-
In the left-side navigation pane, click Data Migration. In the top navigation bar, select a region.
-
Click Create Task and configure the source and destination databases.
Category
Setting
Description
N/A
Task Name
Enter a descriptive name to help you identify the task. The name does not need to be unique. Alternatively, you can use the system-generated name.
Source Database
Select Existing Connection
If you saved the source database connection on the DTS Data Connection Management page, you can select it here to avoid re-entering the information.
Database Type
Select SQL Server.
Connection Type
Select cloud instance.
Instance Region
Select the region where the source RDS for SQL Server instance is located.
Cross-account
This example migrates data within the same Alibaba Cloud account. Select Within the Same Account.
RDS instance ID
Select the ID of the source RDS for SQL Server instance.
Database Account
Enter the database account for the source RDS for SQL Server instance and ensure that the account has the required permissions.
Database Password
Enter the password for the database account.
Encryption
-
If SSL encryption is not enabled on the source database, select Non-encrypted.
-
If SSL encryption is enabled on the source database, select SSL-encrypted. DTS trusts the server certificate by default.
Destination Database
Select Existing Connection
If you saved the destination database connection on the DTS Data Connection Management page, you can select it here to avoid re-entering the information.
Database Type
Select SQL Server.
Connection Type
Select cloud instance.
Instance Region
Select the region where the destination RDS for SQL Server instance is located.
Instance ID
Select the ID of the destination RDS for SQL Server instance.
Database Account
Enter the database account for the destination RDS for SQL Server instance and ensure that the account has the required permissions.
Database Password
Enter the password for the database account.
Encryption
-
If SSL encryption is not enabled on the destination database, select Non-encrypted.
-
If SSL encryption is enabled on the destination database, select SSL-encrypted. DTS trusts the server certificate by default.
-
-
After completing the configuration, click Test Connectivity and Proceed at the bottom of the page.
NoteEnsure that the CIDR blocks for the DTS servers are added to the security settings of the source and destination databases, either automatically or manually, to allow access.
-
Configure the task objects.
-
On the Configure Objects page, configure the objects that you want to migrate.
Setting
Description
Migration Types
-
For a full migration, select Schema Migration and Full Data Migration.
-
For a zero-downtime migration, select Schema Migration, Full Data Migration, and Incremental Data Migration.
Note-
For more information, see Appendix: SQL operations supported for incremental migration.
-
If you do not select Schema Migration, ensure the destination database already contains the required databases and tables. Based on your requirements, you can also use the object name mapping feature in the Selected Objects box.
-
If you do not select Incremental Data Migration, do not write new data to the source instance during the data migration. This ensures data consistency.
Method to Migrate Triggers in Source Database
Select a trigger migration method based on your requirements. If the objects to be migrated do not involve triggers, you can skip this setting.
NoteThis setting is available only when you select both Schema Migration and Incremental Data Migration for Migration Types.
SQL Server Incremental Synchronization Mode
Note-
This setting is available only if Incremental Data Migration is selected for Migration Types.
-
If the source database is an RDS for SQL Server Web Edition instance, you must set SQL Server Incremental Synchronization Mode to Incremental Synchronization Based on Logs of Source Database (Heap tables are not supported).
-
In hybrid log parsing mode (when SQL Server Incremental Synchronization Mode is set to Use Log Parsing for Incremental Synchronization of Non-heap Tables and CDC for Heap Tables), the following source database versions are supported:
-
Enterprise or Enterprise Evaluation Edition: 2012, 2014, 2016, 2019, or 2022.
-
Standard Edition: 2016, 2019, or 2022.
-
The maximum number of tables for which CDC is enabled that DTS supports.
Specifies the maximum number of tables on which CDC can be enabled for the migration instance. The default value is 1,000.
NoteThis setting is not available when SQL Server Incremental Synchronization Mode is set to Incremental Synchronization Based on Logs of Source Database (Heap tables are not supported).
Processing Mode of Conflicting Tables
-
Precheck and Report Errors: DTS checks for tables in the destination database that have the same name as tables in the source database. If no conflicting tables are found, the task passes the precheck. If conflicts are found, the precheck fails and the task is blocked.
Solution: If you cannot delete or rename the conflicting table in the destination database, you can use object name mapping to change the table's name in the destination.
-
Ignore Errors and Proceed: Skips the check for tables with the same name in the destination database.
WarningSelecting Ignore Errors and Proceed may cause data inconsistency and business risks. For example:
-
If the table schemas are identical and the destination database already contains records with the same primary key values as the source:
-
During the full migration phase, DTS retains existing destination records and skips migrating the corresponding source records.
-
During the incremental migration phase, new data from the source database may overwrite data in the destination database, which can cause a loss of historical data 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.
-
Source Objects
In the Source Objects box, click the objects to migrate, and then click
to move them to the Selected Objects box.NoteThe 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
-
To change the name of a single migration object in the target instance, right-click the object in the Selected Objects box. For more information, see Map individual schema, table, and column names.
-
To change the names of multiple migration objects in the target instance, click Selected Objects in the upper-right corner of the Batch Edit box. For more information, see Map multiple schema, table, and column names.
Note-
If you use object name mapping, the migration of dependent objects may fail.
-
To filter data by using a WHERE clause, right-click the desired table in the Selected Objects box and set a filter condition in the dialog box that appears.
-
To select SQL operations to migrate 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 that appears.
-
-
Click Next: Advanced Settings to configure advanced parameters.
Setting
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.
ImportantThe 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
You can select an environment tag to identify the instance. This is not required for this example.
Configure ETL
Based on your business needs, select whether to configure the ETL feature to process data.
-
Yes: Configures the ETL feature. You must also enter data processing statements in the text box.
-
No: Does not configure the ETL feature.
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.
-
-
Click Next: Data Validation to configure a data validation task.
For more information about the data validation feature, see Configure data validation.
-
-
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.
-
-
-
Purchase the instance.
-
When the Success Rate is 100%, click Next: Purchase Instance.
-
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.
-
After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.
-
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.
-
-
SQL operations for incremental migration
DML operations
INSERT, UPDATE, DELETE
UPDATE statements that only update large objects cannot be migrated.
DDL operations
-
ALTER TABLE, limited to ADD COLUMN, DROP COLUMN, and RENAME COLUMN
-
CREATE TABLE and CREATE INDEX
NoteCREATE TABLE does not support partitioning or table definitions containing functions.
-
DROP TABLE
-
RENAME TABLE
-
TRUNCATE TABLE
-
Transactional DDL operations cannot be migrated. For example, a single SQL statement that adds multiple columns or includes both DDL and DML operations can cause data loss.
-
DDL operations on user-defined types cannot be migrated.
-
Online DDL operations cannot be migrated.
-
DDL operations using a reserved keyword as an attribute name cannot be migrated.
-
DDL operations executed by system stored procedures cannot be migrated.
-
DTS does not support
TRUNCATE TABLEoperations.