Data Transmission Service (DTS) lets you migrate data from ApsaraDB RDS for SQL Server to AnalyticDB for PostgreSQL. AnalyticDB for PostgreSQL supports real-time online analysis and offline data processing, making it a common destination for consolidating SQL Server data into an analytical workload.
Prerequisites
Before you begin, make sure that:
The source ApsaraDB RDS for SQL Server instance runs a database version supported by DTS. For supported versions, see Overview of data migration scenarios.
The destination AnalyticDB for PostgreSQL instance is created and has available storage space larger than the total data size of the source instance. For details, see Create an instance.
A database is created in the destination instance to receive the migrated data. For details, see CREATE DATABASE.
If your source instance meets any of the following conditions, split the migration into multiple tasks to avoid performance and stability issues:
More than 10 databases
A single database backs up logs at an interval of less than 1 hour
A single database executes more than 100 DDL statements per hour
Logs are written at a rate of 20 MB/s for a single database
Change data capture (CDC) needs to be enabled for more than 1,000 tables
Billing
| Migration type | Task configuration fee | Internet traffic fee |
|---|---|---|
| Schema migration and full data migration | Free | Free in this example |
| Incremental data migration | Charged. See Billing overview. |
Migration types
DTS supports three migration types for this scenario:
Schema migration: Migrates the schemas of selected objects (schemas, tables, views, functions, and stored procedures) from the source to the destination. The following object types are not migrated: assemblies, service brokers, full-text indexes, full-text catalogs, distributed schemas, distributed functions, CLR stored procedures, CLR scalar-valued functions, CLR table-valued functions, internal tables, system tables, and aggregate functions.
WarningSQL Server and AnalyticDB for PostgreSQL use different type systems with no one-to-one type mapping. Evaluate the impact of data type mappings on your workload before proceeding. See Data type mappings between heterogeneous databases.
Full data migration: Migrates all existing data from the selected source objects to the destination.
Incremental data migration: After full data migration completes, continuously replicates changes from the source to the destination. This keeps the destination in sync without interrupting the applications that use the source database.
SQL operations supported for incremental migration
| Operation type | SQL statements |
|---|---|
| DML | INSERT, UPDATE, DELETE |
| DDL | CREATE TABLE (partitioned tables and tables that use functions are excluded), ALTER TABLE ADD COLUMN, ALTER TABLE DROP COLUMN, DROP TABLE, CREATE INDEX, DROP INDEX |
DTS does not migrate DDL operations that use user-defined types or transactional DDL operations.
Required database account permissions
| Database | Schema migration | Full data migration | Incremental data migration |
|---|---|---|---|
| Source ApsaraDB RDS for SQL Server | Read and write | Read and write | Owner |
| Destination AnalyticDB for PostgreSQL | LOGIN; SELECT, CREATE, INSERT, UPDATE, DELETE on destination tables; CONNECT and CREATE on the destination database; CREATE on destination schemas; COPY (memory-based batch copy) | Same | Same |
For the destination instance, you can also use the initial database account or any account that has the RDS_SUPERUSER permission.
For instructions on creating accounts and granting permissions, see:
ApsaraDB RDS for SQL Server: Create a privileged account or a standard account and Modify the permissions of an account
AnalyticDB for PostgreSQL: Create a database account and Manage users and permissions
Limitations
Source database limitations
The server hosting the source database must have sufficient outbound bandwidth. Insufficient bandwidth reduces migration speed.
Tables to be migrated must have PRIMARY KEY or UNIQUE constraints with all fields unique. Tables without these constraints may produce duplicate records in the destination.
When migrating tables individually (rather than the entire database), a single task supports up to 1,000 tables. Exceeding this limit causes a request error. Either configure multiple tasks or migrate the entire database instead.
A single task supports up to 10 databases. Migrating more than 10 databases in one task may reduce performance and stability.
If the source is a read-only instance, DDL operations cannot be migrated.
Incremental migration requirements
To use incremental data migration, the source database must meet these requirements:
Data logging is enabled, the backup mode is set to Full, and a full physical backup has been performed.
Log retention period: If logs are unavailable, DTS cannot read them and the task fails. In some cases, data inconsistency or loss may occur. After full migration completes, you can reduce the retention period to more than 24 hours. The DTS Service Level Agreement (SLA) does not cover tasks that do not meet these log retention requirements.
Incremental migration only: more than 24 hours
Full + incremental migration: at least 7 days
Do not clear logs before the task completes. DTS uses the
fn_logfunction to read logs, and clearing them while the task is running causes the task to fail.
Prerequisites for CDC
If CDC needs to be enabled for the source tables, verify these conditions before starting the task. Failure to meet them causes the precheck to fail.
The value of the
srvnamefield in thesys.sysserversview matches the return value of theSERVERPROPERTYfunction.For self-managed SQL Server databases, the database owner must be the
sauser. For ApsaraDB RDS for SQL Server databases, the database owner must be thesqlsauser.For the Enterprise edition: SQL Server 2008 or later is required.
For the Standard edition: SQL Server 2016 SP1 or later is required.
If the source runs SQL Server 2017 (Standard or Enterprise edition), update to a newer version to avoid known issues.
Data type limitations
The following data types are not migrated: CURSOR, ROWVERSION, SQL_VARIANT, HIERARCHYID, POLYGON, GEOMETRY, GEOGRAPHY.
Other limitations
The destination table cannot be an append-optimized (AO) table.
During schema migration and full data migration, do not execute DDL statements that change database or table schemas. Doing so causes the migration task to fail.
If performing only full data migration (no incremental), do not write data to the source database while migration is in progress. Concurrent writes cause data inconsistency between the source and destination.
Concurrent INSERT operations during full data migration cause table fragmentation in the destination. After full migration completes, the destination tablespace is larger than the source.
If column mapping is used for non-full table migration, or if source and destination table schemas differ, columns in the source that have no corresponding column in the destination are lost.
DTS attempts to resume failed tasks for up to seven days. Before switching workloads to the destination, stop or release any failed tasks, or use the
REVOKEstatement to revoke write permissions from the DTS accounts on the destination. Otherwise, a resumed task overwrites destination data with source data.If the task includes incremental migration, reindexing is not allowed. Running it may cause the task to fail and data loss.
For FLOAT or DOUBLE columns, verify that the precision settings meet your requirements. DTS uses
ROUND(COLUMN,PRECISION)to retrieve values: FLOAT defaults to 38 digits of precision, DOUBLE defaults to 308 digits.DTS does not migrate DDL operations related to the primary key of a table for which CDC is enabled.
If the number of CDC-enabled tables to be migrated in a single migration task exceeds 1,000, the precheck fails.
Limitations by incremental synchronization mode
Incremental synchronization based on logs of source database (heap tables are not supported)
Does not modify the source database settings.
Does not support heap tables, tables without primary keys, compressed tables, or tables with computed columns. All tables must have clustered indexes that contain primary key columns. If your tables include any of these types, use hybrid log-based parsing mode instead.
To check whether your tables are heap tables, tables without primary keys, compressed tables, or tables with computed columns, see the FAQ.
If the source runs SQL Server Web edition, this mode is required. Set SQL Server Incremental Synchronization Mode to Incremental Synchronization Based on Logs of Source Database (Heap tables are not supported) when configuring the task.
Log-based parsing for non-heap tables and CDC-based incremental synchronization for heap tables (hybrid log-based parsing)
Supports heap tables, tables without primary keys, compressed tables, and tables with computed columns. Provides higher stability and a broader set of DDL statements.
DTS creates these objects in the source database: trigger
dts_cdc_sync_ddl, heartbeat tabledts_sync_progress, DDL history tabledts_cdc_ddl_history. It also enables CDC for the source database and specific tables.You cannot execute SELECT INTO or TRUNCATE on CDC-enabled tables. The triggers created by DTS cannot be manually deleted.
Multiple ADD COLUMN or DROP COLUMN operations within 10 minutes are not allowed. For example, the following sequence within 10 minutes causes an error:
ALTER TABLE test_table DROP COLUMN Flag; ALTER TABLE test_table ADD Remark nvarchar(50) NOT NULL DEFAULT('');We recommend that you set the maximum write rate for CDC-enabled tables to 1,000 records per second.
Make sure that the CDC job in the source database runs as expected. If it fails, the DTS task also fails.
Polling and querying CDC instances for incremental synchronization
Supported source databases: Amazon RDS SQL Server, Azure SQL Database, Google Cloud SQL for SQL Server.
Uses the native CDC component of SQL Server. Incremental migration is more stable and consumes less network bandwidth.
The DTS account used for the source database must have permission to enable CDC:
To enable database-level CDC: use an account assigned the
sysadminrole.To enable table-level CDC: use a privileged account.
NoteA server administrator account in Microsoft Azure SQL Database has the required permissions. CDC can be enabled for all databases purchased in Azure SQL Database based on the vCore model. For databases based on the database transaction unit (DTU) model, CDC requires a service tier of S3 or greater.
A privileged account of Amazon RDS for SQL Server has the required permissions. CDC can be enabled for stored procedures at the database level.
Incremental data migration delay is approximately 10 seconds.
The number of tables to be migrated cannot exceed 1,000. Exceeding this limit causes the precheck to fail and may cause delays or instability.
Do not execute DDL statements to add or remove columns more than twice within a minute. Exceeding this limit may cause the task to fail.
Do not modify CDC instances in the source database during migration. Doing so may cause the task to fail or data loss.
DTS account on source RDS instance
When the source is an ApsaraDB RDS for SQL Server instance, DTS automatically creates an account named rdsdt_dtsacct on the instance. Do not delete this account or change its password while the migration task is running. Doing so causes the task to fail. For more information, see System accounts.
Foreign key behavior
DTS migrates foreign keys during schema migration.
During full data migration and incremental data migration, DTS temporarily disables constraint checks and cascade operations on foreign keys at the session level. If you run cascade UPDATE or DELETE operations on the source during migration, data inconsistency may occur.
Create a data migration task
Step 1: Go to the Data Migration Tasks page
Log on to the Data Management (DMS) console.
In the top navigation bar, move the pointer over DTS.
Choose DTS (DTS) > Data Migration.
Alternatively, go directly to the Data Migration page of the new DTS console. The actual navigation may vary based on the DMS console mode and layout. See Simple mode and Customize the layout and style of the DMS console.
Step 2: Select region and create a task
From the drop-down list to the right of Data Migration Tasks, select the region where your data migration instance resides.
NoteIn the new DTS console, select the region in the upper-left corner.
Click Create Task.
Step 3: Configure source and destination databases
On the Create Task page, configure the following parameters:
| Section | Parameter | Description |
|---|---|---|
| N/A | Task Name | A name for the task. DTS generates a default name. Use a descriptive name to identify the task. The name does not need to be unique. |
| Source Database | Select an existing DMS database instance | Optional. If you select an existing DMS instance, DTS populates the connection parameters automatically. Otherwise, configure the parameters manually. |
| Database Type | Select SQL Server. | |
| Access Method | Select Alibaba Cloud Instance. | |
| Instance Region | The region of the source ApsaraDB RDS for SQL Server instance. | |
| Replicate Data Across Alibaba Cloud Accounts | Select No for same-account migration. | |
| RDS Instance ID | The ID of the source ApsaraDB RDS for SQL Server instance. | |
| Database Account | The account for the source instance. See Required database account permissions. | |
| Database Password | The password for the account. | |
| Destination Database | Select an existing DMS database instance | Optional. Same behavior as for the source. |
| Database Type | Select AnalyticDB for PostgreSQL. | |
| Access Method | Select Alibaba Cloud Instance. | |
| Instance Region | The region of the destination AnalyticDB for PostgreSQL instance. | |
| Instance ID | The ID of the destination AnalyticDB for PostgreSQL instance. | |
| Database Name | The name of the database in the destination instance that will receive the migrated objects. | |
| Database Account | The account for the destination instance. See Required database account permissions. | |
| Database Password | The password for the account. |
Step 4: Test connectivity
Click Test Connectivity and Proceed.
DTS automatically adds its server CIDR blocks to the IP address whitelist of Alibaba Cloud database instances and to the security group rules of ECS-hosted databases. For self-managed databases deployed in data centers or on third-party clouds, manually add the DTS server CIDR blocks to the database whitelist. See Add the CIDR blocks of DTS servers.
Adding DTS server CIDR blocks to a database whitelist or security group introduces security risks. Before using DTS to migrate data, understand and acknowledge these risks and take preventive measures, including but not limited to: strengthening username and password security, limiting exposed ports, authenticating API calls, regularly auditing whitelist and security group rules, and removing unauthorized CIDR blocks. Alternatively, connect the database to DTS using Express Connect, VPN Gateway, or Smart Access Gateway.
Step 5: Configure objects and migration settings
Configure the following parameters:
| Parameter | Description |
|---|---|
| Migration Types | Select the migration types for your scenario: Schema Migration + Full Data Migration for one-time migration; Schema Migration + Full Data Migration + Incremental Data Migration for continuous sync during migration. If Incremental Data Migration is not selected, do not write data to the source database during migration to ensure data consistency. |
| SQL Server Incremental Synchronization Mode | Select the mode that matches your source database. See Limitations by incremental synchronization mode for details on each mode's requirements and constraints. This parameter is available only when Full Data Migration is selected. |
| DDL and DML Operations to Be Synchronized | The SQL operations to migrate at the instance level. See SQL operations supported for incremental migration. To select operations for a specific database or table, right-click an object in Selected Objects. |
| Processing Mode of Conflicting Tables | Precheck and Report Errors: fails the precheck if the destination has tables with the same names as source tables. To resolve conflicts, use object name mapping. Ignore Errors and Proceed: skips the check. During full migration, DTS skips conflicting records and keeps the existing destination data. During incremental migration, DTS overwrites conflicting records. Use with caution. |
| Capitalization of Object Names in Destination Instance | Controls the capitalization of database names, table names, and column names in the destination. Default is DTS default policy. See Specify the capitalization of object names in the destination instance. |
| Source Objects | Select the objects to migrate and click |
| Selected Objects | To rename a migrated object, right-click it. See Map the name of a single object. To rename multiple objects at once, click Batch Edit. See Map multiple object names at a time. To filter rows using a WHERE condition, right-click a table and specify conditions. See Specify filter conditions. |
Renaming an object may cause other objects that depend on it to fail migration.
To select SQL operations for a specific database or table, right-click it in Selected Objects.
Step 6: Configure advanced settings
Click Next: Advanced Settings and configure the following:
Data verification settings
To enable data verification after migration, see Configure a data verification task.
Advanced settings
| Parameter | Description |
|---|---|
| Dedicated Cluster for Task Scheduling | By default, DTS schedules the task to a shared cluster. For higher stability, purchase a dedicated cluster. See What is a DTS dedicated cluster. |
| Set Alerts | Configure alerting for task failures or latency threshold breaches. Select Yes to specify alert thresholds and notification settings. See Configure monitoring and alerting. |
| Retry Time for Failed Connections | How long DTS retries failed connections after the task starts. Valid values: 10–1,440 minutes. Default: 720 minutes. Set to more than 30 minutes. If DTS reconnects within this period, the task resumes. Otherwise, the task fails. If multiple tasks share the same source or destination database, the shortest retry time among them applies. DTS charges for the instance during retries. Set this parameter based on your business requirements, and release the DTS instance as early as possible after the source and destination instances are released. |
| Retry Time for Other Issues | How long DTS retries failed DDL or DML operations. Valid values: 1–1,440 minutes. Default: 10 minutes. Set to more than 10 minutes. Must be less than Retry Time for Failed Connections. |
| Enable Throttling for Full Data Migration | Limit the read and write load on the source and destination databases during full migration. Configure Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s). Available only when Full Data Migration is selected. |
| Enable Throttling for Incremental Data Migration | Limit the load on the destination database during incremental migration. Configure RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s). Available only when Incremental Data Migration is selected. |
| Environment Tag | Tag the DTS instance by environment (for example, production or test). Optional. |
| Enclose Object Names in Quotation Marks | Select Yes to wrap schema, table, and column names in single or double quotation marks during schema migration and incremental migration in these cases: the source environment is case-sensitive and the database name uses mixed case; a table name does not start with a letter or contains non-standard characters; object names are keywords or reserved words in the destination database. |
| Configure ETL | Enable extract, transform, and load (ETL) processing. Select Yes to enter data transformation statements. See Configure ETL in a data migration or data synchronization task. |
Step 7 (optional): Configure database and table fields
Click Next: Configure Database and Table Fields to set the Type, Primary Key Column, and Distribution Key for tables being migrated to AnalyticDB for PostgreSQL.
This step is available only when Schema Migration is selected. Set Definition Status to All to view and edit all tables. For composite primary keys, specify one or more Primary Key Column values as Distribution Key columns. See Manage tables and Define table distribution.
Step 8: Save settings and run the precheck
Click Next: Save Task Settings and Precheck.
To review the API parameters for this task configuration, move the pointer over Next: Save Task Settings and Precheck and click Preview OpenAPI parameters.
DTS runs a precheck before starting the migration task. The task starts only after the precheck passes.
If any item fails, click View Details next to that item, resolve the issue, then click Precheck Again.
If an alert is triggered:
If the alert cannot be ignored, fix the issue and rerun the precheck.
If the alert can be ignored, click Confirm Alert Details, then click Ignore in the dialog box, and click OK to confirm. Then click Precheck Again. Ignoring an alert may result in data inconsistency.
Step 9: Purchase the instance
Wait until Success Rate reaches 100%, then click Next: Purchase Instance.
On the Purchase Instance page, configure:
| Section | Parameter | Description |
|---|---|---|
| New Instance Class | Resource Group Settings | The resource group for the data migration instance. Default: default resource group. See What is Resource Management? |
| Instance Class | The instance class determines migration speed. Select based on your workload. See Specifications of data migration instances. |
Step 10: Start the task
Read and accept Data Transmission Service (Pay-as-you-go) Service Terms by selecting the check box.
Click Buy and Start, then click OK in the dialog box.
The task appears in the task list. Monitor its progress there.
What's next
After migration completes:
Verify data consistency between the source and destination databases.
Stop or release any failed DTS tasks before switching workloads to the destination. Alternatively, use the
REVOKEstatement to revoke write permissions from the DTS accounts on the destination database to prevent a resumed task from overwriting destination data.For data verification, see Configure a data verification task.