Migrate data between ApsaraDB for MongoDB instances of different Alibaba Cloud accounts
Use Data Transmission Service (DTS) to migrate data between ApsaraDB for MongoDB instances that belong to different Alibaba Cloud accounts. Running both full data migration and incremental data migration together keeps your service online and maintains data consistency throughout the migration.
Prerequisites
The source instance type is a standalone instance or replica set instance. If the source instance is a sharded cluster instance, use the tools provided by MongoDB to migrate. For more information, see Migrate data from a self-managed MongoDB database to a sharded cluster instance by using mongodump and mongorestore.
NoteWhen you use DTS to migrate a standalone instance, incremental data migration is not supported. For more information, see Migration types.
A destination instance already created in the target region. For more information, see Create a standalone instance, Create a replica set instance, or Create a sharded cluster instance.
4_d33_zpv">Create a sharded cluster instance.
Note(Recommended) Available storage space on the destination instance that is at least 10% larger than the total data size of the source instance.
Billing
Migration type | Task configuration fee | Internet traffic fee |
Full data migration | Free of charge | Charged only when data is migrated from Alibaba Cloud over the Internet. For more information, see DTS pricing. |
Incremental data migration | Charged. For more information, see DTS pricing. |
Migration types
Migration type | Description |
Full data migration | DTS migrates all historical data of the required objects from the source MongoDB database to the destination MongoDB database. Note The following types of objects are supported: database, collection, and index. |
Incremental data migration | After full data migration is complete, DTS synchronizes incremental data from the source MongoDB database to the destination MongoDB database. Note
|
Permissions required for database accounts
Migration data source | Full data migration | Incremental data migration |
Source MongoDB instance | The read permission on the database to be migrated | The read permission on the database to be migrated, the admin database, and the local database |
Destination MongoDB instance | The readWrite permission on the destination database | The readWrite permission on the destination database |
For information about how to create and authorize a database account, see Use DMS to manage MongoDB database users.
Preparations
Use the Alibaba Cloud account of the source instance to log on to the MongoDB console. For more information, see MongoDB console.
Apply for a public endpoint for the source instance. For more information, see Apply for a public endpoint.
.dita#concept_qlm_xcw_mfb" id="xref_0yc_vzu_u50">Apply for a public endpoint.
Add the DTS server IP address ranges to the whitelist of the source instance. For more information, see Modify a whitelist.
NoteSelect the required IP address ranges based on the region of the destination instance. For more information, see Whitelist DTS server IP addresses.
For example, if the source instance is in the Hangzhou region and the destination instance is in the Shenzhen region, add the DTS IP address ranges of the Shenzhen region to the whitelist of the source instance.
Procedure
Log on to the ApsaraDB for MongoDB console.
Depending on the instance type, in the navigation pane on the left, click Replica Set Instances or Sharded Cluster Instances.
In the upper-left corner of the page, select the resource group and region of the instance.
tag="ph" id="ph_uo2_6d9_lct" conref="t2134818.dita#concept_2134818/ph_gni_2e5_16r" docType="TOPIC" baseUrl="t123029_v1_13_3.dita" data-latest="1">
In the upper-right corner of the instance details page, click Migrate Database.
On the Create Migration Task page, configure the migration task:
Configure the source and destination databases.

Category
Configuration
Description
None
Task Name
DTS automatically generates a task name. We recommend that you configure a name with business meaning (uniqueness is not required) for easier identification later.
Source database information
Instance type
Select User-Created Database with Public IP Address.
Instance region
Select the region where the source instance is located.
Database Type
Select MongoDB.
Hostname or IP address
The domain name from the source instance's public endpoint. Example:
dds-bp1b47357f218e74****-pub.mongodb.rds.aliyuncs.com.Port
Enter the service port of the source instance: 3717.
Database name
Enter the authentication database name, that is, the database to which the database account belongs.
NoteIf the database account is root, the corresponding database name is admin.
Database account
Enter the database account of the source MongoDB instance. For information about the permission requirements, see Permissions required for database accounts.
Database password
Enter the password of the database account.
NoteAfter you enter the source database information, you can click Test Connectivity next to Database Password to verify whether the source database information is correct. If it is correct, Passed is displayed. If Failed is displayed, click Diagnose next to Failed, and adjust the source database information based on the prompts.
Connection method
The method used by Data Transmission Service (DTS) to connect to the source instance. Select Non-encrypted or SSL-encrypted based on your requirements. If you select SSL-encrypted, you must enable the SSL encryption feature of the source instance in advance.
NoteSSL-encrypted is currently supported only for MongoDB Atlas.
Selecting SSL-encrypted significantly increases CPU consumption.
Destination database information
Instance Type
Select MongoDB Instance.
Instance Region
Select the region where the destination MongoDB instance is located.
MongoDB Instance ID
The ID of the destination instance.
Database Name
Enter the authentication database name, that is, the database to which the database account belongs.
NoteIf the database account is root, the corresponding database name is admin.
Database Account
Enter the database account of the destination MongoDB instance. For information about the permission requirements, see Permissions required for database accounts.
Database Password
Enter the password of the database account.
NoteAfter you enter the destination database information, you can click Test Connectivity next to Database Password to verify whether the destination database information is correct. If it is correct, Passed is displayed. If Failed is displayed, click Diagnose next to Failed, and adjust the destination database information based on the prompts.
After the configuration is complete, click Set whitelist and enter next step at the bottom of the page.
If the source or destination database is an Alibaba Cloud database instance, such as an 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 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 database is accessible from the ECS instance. 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 servers. For more information about the IP addresses of DTS servers, see CIDR blocks of DTS servers.
WarningAdding the public CIDR blocks of DTS servers, whether automatically or manually, may introduce security risks. By using this product, you acknowledge and accept these potential risks. You are responsible for implementing basic security measures, including but not limited to using strong passwords, restricting open ports, using authentication for internal API calls, regularly reviewing and restricting unnecessary network segments, or connecting through private networks such as Express Connect, VPN Gateway, or Smart Access Gateway.
Set the following parameters and select the migration objects and migration types.
Configuration
Description
Migration types
We recommend that you select both Full Data Migration and Incremental Data Migration to ensure data consistency.
If you select only Full Data Migration: During the full migration, if data is updated in the source instance, the updated data may not be migrated to the destination instance.
If you select only Incremental Data Migration:
After the migration task starts, DTS migrates only the incremental data generated in the source instance.
Incremental migration does not support synchronization of triggers. For more information, see Configure tasks for source databases with triggers.
NoteWhen you use DTS to migrate a standalone instance, incremental data migration is not supported.
If Incremental data migration is not selected, to ensure data consistency, do not write new data to the source instance during full data migration.
Migration objects
Select the migration objects as follows:
From the Migration objects list, select the objects to be migrated.
Click
to move the objects to the Selected Objects list.
NoteMigration of the admin and local databases is not supported.
The granularity of migration objects is database, collection, or function.
By default, after the migration is complete, the names of the migration objects remain unchanged. To change the names of the migration objects in the destination database, use the object name mapping feature. For more information, see Library, table, and column mapping.
Mapping name changes
To change the names of the migration objects in the destination instance, use the object name mapping feature. For more information, see Object name mapping.
Retry time for failed connections to the source and destination databases
The default retry time is 12 hours. You can also customize the retry time. If DTS reconnects to the source and destination databases within the specified time, the migration task automatically resumes. Otherwise, the migration task fails.
NoteBecause DTS charges task fees during the retry period, we recommend that you customize the retry time based on business requirements, or release the DTS instance as soon as possible after the source and destination database instances are released.
After the configuration above is complete, click Precheck and start at the lower-right corner of the page.
Description
Before the migration task starts officially, a precheck is performed. The migration task can be started successfully only after the precheck is passed.
If the precheck fails, click View details next to the failed check item, and fix the issue based on the prompts before running the precheck again.
If the precheck produces warnings:
For check items that cannot be ignored, click View details next to the failed check item, and fix the issue based on the prompts before running the precheck again.
For check items that can be ignored without fixing, click Confirm warning details, Confirm ignore, OK, and Re-precheck in sequence to skip the warning check items and run the precheck again. If you ignore warning check items, data inconsistency and other issues may occur, which may pose risks to your business.
After the precheck is passed, click Next.
On the Purchase configuration confirmation page, select Link specification and select the Terms of Service for Data Transmission (Pay-As-You-Go).
Click Buy and start now. The migration task officially begins.
Click Buy and Start to start the data migration task.
Full data migration
We recommend that you do not manually stop the task during full data migration. Otherwise, the data migrated to the destination database will be incomplete. You can wait until the data migration task automatically stops.
Incremental data migration
The task does not automatically stop during incremental data migration. You must manually stop the task.
NoteWe recommend that you select an appropriate time to manually stop the data migration task. For example, you can stop the task during off-peak hours or before you switch your workloads to the destination ApsaraDB for MongoDB instance.
Wait until Incremental Data Migration and The migration task is not delayed appear in the progress bar of the migration task. Then, stop writing data to the source database for a few minutes. The delay time of incremental data migration may be displayed in the progress bar.
After the status of incremental data migration changes to The migration task is not delayed again, manually stop the migration task.

Switch business to the destination MongoDB instance.
Follow-up operations
Determine whether to release the source instance based on business requirements.
If the source instance is a pay-as-you-go instance, see Release an instance.
More information
When the destination instance is a sharded cluster instance, you can configure data sharding based on business requirements. For more information, see Configure sharding to maximize shard performance.