All Products
Search
Document Center

ApsaraDB for MongoDB:Migrate a self-managed MongoDB on an ECS instance to ApsaraDB for MongoDB

Last Updated:Jul 20, 2026

This topic describes how to use Data Transmission Service (DTS) to migrate data from a self-managed MongoDB database with a standalone or replica set architecture on an ECS instance to an ApsaraDB for MongoDB instance. The incremental data migration feature of DTS allows you to migrate smoothly without taking your applications offline.

This topic describes the migration procedure for the previous version of the DTS console. For the procedure in the new console, see the following topics:

Prerequisites

  • The self-managed MongoDB database is version 3.0 or later.

  • The destination ApsaraDB for MongoDB instance must have more storage space than the source database uses.

Usage notes

  • To minimize the impact on your services, perform the data migration during off-peak hours.

  • The config database is an internal system database and should not be migrated unless you have specific requirements.

  • For the versions and storage engines that are supported by ApsaraDB for MongoDB instances, see Versions and storage engines. If you want to migrate data across different versions or storage engines, you must verify the compatibility in advance.

Billing information

Migration Types Instance configurations Internet traffic
Full data migration Free of charge Free of charge
Incremental data migration Charged, For more information, see Data Transmission Service (DTS) pricing. Free of charge

Migration type description

  • Full data migration: All data of the migration objects is migrated from the source instance to the destination instance..
    Note Data migration is supported at the database, collection, and index levels.
  • Incremental data migration: Updated data of the migration objects is synchronized from the source instance to the destination instance..
    Note
    • The create and delete operations for databases, collections, and indexes can be synchronized.
    • The create, delete, and update operations on documents can be synchronized.

Database account permissions

Migration data source

Full data migration

Incremental data migration

Self-managed database on ECS

The read permission on the databases to be migrated

The read permission on the databases to be migrated, the admin database, and the local database

ApsaraDB for MongoDB instance

The readWrite permission on the destination database

The readWrite permission on the destination database

To create database accounts and grant permissions:

Preparations

If your self-managed database on an ECS instance uses a replica set architecture, you can skip this step.

If your self-managed database on an ECS instance uses a standalone architecture and you want to perform an incremental data migration, you must enable the oplog on the source database. For more information, see Migrate a self-managed standalone MongoDB database to the cloud by using DTS.

Procedure

  1. Log on to the DTS console.
  2. In the lower-right corner of the page, click the Back to Old Console icon to return to the previous version of the console.

  3. In the left-side navigation pane, click Data Migration.
  4. At the top of the Migration Tasks page, select the region where your destination ApsaraDB for MongoDB instance is located.

  5. In the upper-right corner, click Create Migration Task.
  6. Configure the source and destination databases for the migration task.

    Category

    Parameter

    Description

    Task Name

    N/A

    • DTS automatically generates a task name, which does not need to be unique.

    • You can change the task name. We recommend using a descriptive name for easy identification.

    Source Database

    Instance Type

    Select ECS-Hosted Database.

    Instance Region

    Select the region where the ECS instance is located.

    ECS Instance ID

    Select the ID of the ECS instance that hosts the self-managed MongoDB database.

    Database Type

    Select MongoDB.

    Port

    Enter the service port of the self-managed MongoDB database.

    Database Name

    Enter the name of the authentication database.

    Database Account

    Enter the account for connecting to the self-managed MongoDB database. For the required permissions, see Database account permissions.

    Database Password

    Enter the password for the database account.

    Note

    After you enter the source database information, you can click Test Connectivity next to Database Password to verify the information. If the information is correct, a Passed message is displayed. If a Failed message is displayed, click Diagnose next to Failed and adjust the source database information based on the prompts.

    Destination Database

    Instance Type

    Select MongoDB Instance.

    Instance Region

    Select the region of the destination ApsaraDB for MongoDB instance.

    MongoDB Instance ID

    Select the ID of the destination ApsaraDB for MongoDB instance.

    Database Name

    Enter the name of the authentication database.

    Database Account

    Enter the account for connecting to the destination ApsaraDB for MongoDB instance. For the required permissions, see Database account permissions.

    Database Password

    Enter the password for the database account.

    Note

    After you enter the destination database information, you can click Test Connectivity next to Database Password to verify that the entered information is correct. If the information is correct, a Passed message is displayed. If a Failed message is displayed, click Diagnose next to Failed, and adjust the destination database information as prompted.

  7. After you complete the configuration, click Set Whitelist and Next in the lower-right corner.

    Note
    • If the source or destination database is an Alibaba Cloud database instance (such as RDS MySQL or ApsaraDB for MongoDB) or a self-managed database on an ECS instance, DTS automatically adds the IP addresses of the DTS servers in the corresponding region to the whitelist of the Alibaba Cloud database instance or the security rules of the ECS instance. You do not need to add these IP addresses manually. For more information, see IP Address Ranges of DTS Servers.

    • If the source or destination is a self-managed database and you add the public IP CIDR blocks of DTS servers to allow access, security risks may arise. We recommend that you use strong passwords, restrict allowed ports, or connect to the database over a private connection, such as Express Connect, a VPN Gateway, or a Smart Access Gateway.

    • After the DTS task is complete or released, we recommend manually removing the added DTS server CIDR blocks from the whitelist.

  8. Select the migration types and the objects to migrate.

    Parameter

    Description

    Migration Type

    • To perform only a full data migration, select Full Data Migration.

      Note

      To ensure data consistency, do not write new data to the self-managed MongoDB database during the full data migration.

    • For a migration with minimal downtime, select both Full Data Migration and Incremental Data Migration.

      Note

      For a self-managed MongoDB database with a standalone architecture, you must enable the oplog to use the incremental data migration feature. For more information, see Prerequisites for Migration.

    Migration Objects

    • In the Available Objects pane, select the objects that you want to migrate and click the icon to move them to the Selected Objects pane.

      Note
      • The admin and local databases cannot be migrated.

      • The config database is an internal system database. Do not migrate it unless you have specific requirements.

    • You can select objects at the database, collection, or function level.

    • By default, the names of the migrated objects remain unchanged in the destination instance. If you need to rename the objects in the destination database, use the object name mapping feature. For more information, see Map databases, tables, and columns.

  9. In the lower-right corner of the page, click Precheck.
    Note
    • A precheck is performed before the migration task starts. The migration task starts only after the precheck succeeds.
    • If the precheck fails, click the Tip icon for each failed check item to view their details. Perform a precheck again after the failures are fixed.
  10. After the precheck succeeds, click Next.
  11. On the Confirm Purchase page, select a Link Specification and select the Data Transmission Service (Pay-As-You-Go) Terms of Service checkbox.
  12. Click Buy and Start to start the migration task.
    • Full data migration

      Do not manually end a migration task. If you do so, the system may fail to migrate all data of the database. Wait until the migration task is complete.

    • Incremental data migration

      An incremental data migration task does not automatically end. You need to manually end the task.

      Note Select an appropriate point in time to manually end a migration task. For example, you can end the migration task during off-peak hours or before you switch over your business to the destination ApsaraDB for MongoDB instance.
      1. When the task progress bar displays Incremental Data Migration and The migration task is not delayed, stop writing data to the source database for a few minutes. Wait until the progress bar displays the delay time of the incremental data migration next to Incremental Data Migration.
      2. After the status of Incremental Data Migration changes to The migration task is not delayed, manually end the migration task.Incremental data migration without delay
  13. Switch your workloads to the destination ApsaraDB for MongoDB instance.