Migrate data between RDS for SQL Server instances

更新时间:
复制 MD 格式

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

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.

Click to view all usage limits and precautions

Usage limits

  • Data type restrictions

    DTS does not support migrating the following data types: CURSOR, ROWVERSION, SQL_VARIANT, HIERARCHYID, POLYGON, GEOMETRY, and GEOGRAPHY.

  • Incremental migration restrictions

    If a migration task includes incremental migration, rebuilding indexes is not supported. Otherwise, the task may fail or data loss may occur.

    Note

    Incremental migration is not supported if the source instance runs RDS SQL Server 2008 or 2008 R2.

  • Table structure restrictions

    • If you select Parse source logs for incremental synchronization (heap tables not supported) as the incremental synchronization mode, tables to be migrated must have a clustered index that contains the primary key columns. Heap tables, tables without a primary key, compressed tables, and tables with computed columns are not supported.

    • If you select Hybrid log parsing, the preceding restrictions do not apply, but you must ensure that the CDC jobs on the source database run correctly.

  • CDC-related restrictions

    • You cannot enable CDC for tables with clustered columnstore indexes.

    • Do not modify the CDC instance on the source database. Otherwise, the task may fail or data loss may occur.

  • DDL operation restrictions

    • Do not perform consecutive operations to add or remove columns (more than two such DDL operations within one minute). Otherwise, the task may fail.

    • You cannot modify the primary key of a table for which CDC is enabled.

  • Incremental data capture restrictions

    DTS polls the CDC instance of each table to obtain incremental data. Therefore, we recommend that you migrate no more than 1,000 tables. Otherwise, task latency or instability may occur.

  • Destination database restrictions

    If the destination instance is an RDS SQL Server instance, DTS automatically creates the databases. If the name of a database to be migrated does not comply with the naming conventions of RDS SQL Server, you must manually create the database before you configure the migration task.

  • Special scenario restrictions

    • If a single table in the source database averages more than 10 million incremental SQL changes per day, you must set the CDC data retention period to 1,440 minutes (1 day).

    • If a CDC-enabled table needs to write more than 64 KB of data to a single column, you must run the following command in advance to adjust the source database configuration:

      EXEC sp_configure 'max text repl size', -1;
  • Task recovery and overwrite risk

    DTS attempts to resume a failed task for up to 7 days. To prevent source data from overwriting destination data after a task is automatically resumed, you must end or release the task, or revoke the write permissions of the account that DTS uses to access the destination instance before you switch your workloads.

Precautions

  • Bandwidth and performance requirements

    • Ensure that the server hosting the source database has sufficient egress bandwidth. Otherwise, the migration speed is reduced.

    • We recommend that you run migration tasks during off-peak hours to avoid increasing the database load.

  • Table structure and data consistency

    • Tables to be migrated must have a primary key or a unique constraint. Otherwise, data duplication may occur in the destination database.

    • During the schema migration and full migration phases, do not perform DDL operations on table structures. Otherwise, the migration task will fail.

    • If you perform only a full migration, do not write new data to the source instance. Otherwise, the source and destination databases may become inconsistent. To ensure data consistency, we recommend that you select schema migration, full migration, and incremental migration.

  • Log backup and retention

    • For an incremental migration task, transaction logging must be enabled for the source database, the recovery model must be set to Full, and a successful full backup must have been performed.

    • For an incremental migration task, transaction logs must be retained for more than 24 hours. For a task that includes both full migration and incremental migration, transaction logs must be retained for at least 7 days. After the full migration is complete, you can adjust the retention period to more than 24 hours. Otherwise, the DTS task may fail because it cannot obtain the logs, which can lead to data inconsistency or data loss.

  • CDC configuration and operational requirements

    • If CDC needs to be enabled for tables to be migrated from the source database, the following conditions must be met:

      • The value of the srvname field in the sys.sysservers view must be consistent with the return value of the SERVERPROPERTY function.

      • If the source database is an RDS SQL Server instance, the database owner must be sqlsa.

    • We recommend that the number of CDC-enabled tables does not exceed 1,000. Otherwise, task latency or instability may occur.

    • By default, incremental data stored by the CDC component is retained for 3 days. We recommend that you adjust the retention period based on your business needs. If a single table averages more than 10 million incremental SQL changes per day, we recommend that you set the retention period to 1,440 minutes (1 day).

  • Operational restrictions

    • Do not delete or modify the system accounts created by DTS, such as rdsdt_dtsacct, while the task is running. Otherwise, the task may fail.

    • If the source instance is an RDS SQL Server instance and the migration includes an incremental migration task, disable the Transparent Data Encryption (TDE) feature to ensure the migration task runs stably.

    • Avoid performing consecutive operations to add or remove columns with an interval of less than 10 minutes. Otherwise, the task may fail.

    • If the migration task includes incremental migration, disable active triggers and foreign keys in the destination database.

  • Task scale and stability

    • A single migration task supports migrating up to 10 databases. If this limit is exceeded, stability and performance risks may occur. We recommend that you split the migration objects and configure tasks in batches.

    • If you migrate objects at the table level and need to edit them (for example, for table and column mapping), a single migration task supports migrating up to 1,000 tables. If this limit is exceeded, an error is reported after you submit the task. We recommend that you split the task or configure a full database migration.

    • We recommend that you split the migration into multiple tasks if the source instance meets any of the following conditions:

      • More than 10 databases.

      • Log backups for a single database are performed more than once per hour.

      • More than 100 DDL operations are performed per hour on a single database.

      • A single database generates more than 20 MB/s of transaction logs.

  • Other precautions

    • If you need to migrate across different versions, confirm compatibility in advance. For more information, see Feature differences among RDS SQL Server versions.

    • If the source database is an RDS SQL Server instance, DTS creates objects such as a trigger (for example, dts_cdc_sync_ddl), a heartbeat table (for example, dts_sync_progress), and a DDL storage table (for example, dts_cdc_ddl_history) in the source database to ensure the accuracy of incremental migration.

    • We recommend that you enable the READ_COMMITTED_SNAPSHOT transaction mode parameter on the source database during a full migration task to avoid the impact of shared locks on data writes.

    • Full migration performs concurrent INSERT operations, which can cause table fragmentation in the destination database. After the migration is complete, the storage space used by the tables in the destination database may be larger than that in the source database.

    • DTS attempts to resume a failed task for up to 7 days. To prevent source data from overwriting destination data after a task is automatically resumed, you must end or release the task, or revoke the write permissions of the account that DTS uses to access the destination instance before you switch your workloads.

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:

Note

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

  1. Go to the Data Transmission Service (DTS) console.

  2. In the left-side navigation pane, click Data Migration. In the top navigation bar, select a region.

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

  4. After completing the configuration, click Test Connectivity and Proceed at the bottom of the page.

    Note

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

  5. Configure the task objects.

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

      Note

      This setting is available only when you select both Schema Migration and Incremental Data Migration for Migration Types.

      SQL Server Incremental Synchronization Mode

      • Log-based Parsing for Non-heap Tables and CDC-based Incremental Synchronization for Heap Tables (Hybrid Log-based Parsing)

        • Pros:

          • Supports source databases with heap tables, tables without primary keys, compressed tables, and tables with computed columns.

          • Provides high link stability. This mode captures complete DDL statements and supports a wide range of DDL scenarios.

        • Cons:

          • DTS creates a dts_cdc_sync_ddl trigger, a dts_sync_progress heartbeat table, and a dts_cdc_ddl_history DDL storage table in the source database. It also enables database-level CDC and CDC on some tables.

          • You cannot run SELECT INTO, TRUNCATE, or RENAME COLUMN statements on CDC-enabled tables in the source database. The triggers created by DTS in the source database cannot be manually deleted.

      • Incremental Synchronization Based on Logs of Source Database (Heap tables are not supported)

        • Pros: This mode is non-intrusive to the source database.

        • Cons: Does not support source databases with heap tables, tables without primary keys, compressed tables, or tables with computed columns.

      • Polling and querying CDC instances for incremental synchronization

        • Pros:

          • Supports full and incremental migration from sources such as Amazon RDS for SQL Server, Azure SQL Database, Azure SQL Managed Instance, Azure SQL Server on Virtual Machine, and Google Cloud SQL for SQL Server.

          • Uses the native SQL Server CDC component to capture incremental data, resulting in more stable incremental migration and lower network bandwidth consumption.

        • Cons:

          • The source database account used by the DTS instance must have permissions to enable CDC. Incremental data migration has a latency of about 10 seconds.

          • When migrating multiple databases and tables, this mode may introduce stability and performance risks.

      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.

      Note

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

        Warning

        Selecting 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 Right arrow to move them to the Selected Objects box.

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

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

      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

      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.

    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.

SQL operations for incremental migration

DML operations

INSERT, UPDATE, DELETE

Note

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

    Note

    CREATE TABLE does not support partitioning or table definitions containing functions.

  • DROP TABLE

  • RENAME TABLE

  • TRUNCATE TABLE

Note
  • 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 TABLE operations.