This topic describes how to use Data Transmission Service (DTS) to migrate a self-managed MongoDB database that hosts on Elastic Compute Service (ECS) and uses the standalone or replica set architecture to ApsaraDB for MongoDB. DTS allows you to migrate historical and incremental data without business interruptions.

Prerequisites

  • The version of the self-managed MongoDB database is 3.0, 3.2, 3.4, 3.6, 4.0, or 4.2.
  • The storage space of the ApsaraDB for MongoDB instance is larger than the size of the self-managed MongoDB database.

Precautions

  • To prevent service disruptions, we recommend that you migrate data during off-peak hours.
  • The config database is an internal database. We recommend that you do not migrate this database.
  • If the source and destination ApsaraDB for MongoDB instances have different versions or storage engines, make sure that the versions or storage engines are compatible. For more information, see MongoDB versions and storage engines.

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.

Permissions required for database accounts

Database Full data migration Incremental data migration
Self-managed MongoDB database on ECS Read permissions on the source database The read permissions on the source database, the admin database, and the local database
Destination ApsaraDB for MongoDB instance Read and write permissions on the destination database Read and write permissions on the destination database

For information about how to create and authorize a database account, see the following topics:

Preparations

Skip this step if the self-managed MongoDB database on ECS uses the replica set architecture.

If the self-managed MongoDB database on ECS uses the standalone architecture, enable oplog for the database before you migrate incremental data. For more information, see Migrate a self-managed MongoDB database that uses the standalone architecture to ApsaraDB for MongoDB by using DTS.

Procedure

  1. Log on to the DTS console.
  2. In the left-side navigation pane, click Data Migration.
  3. In the Migration Tasks section, select the region where the ApsaraDB for MongoDB instance is deployed.
  4. In the upper-right corner, click Create Migration Task.
  5. Configure the source and destination databases.
    Section Parameter Description
    Task Name N/A
    • DTS automatically generates a task name. You do not need to use a unique task name.
    • We recommend that you use an informative name for easy identification.
    Source Database Instance Type Select User-Created Database in ECS Instance.
    Instance Region The region where the ECS instance is deployed.
    ECS Instance ID The ID of the ECS instance on which the self-managed MongoDB database is deployed.
    Database Type The type of the database. Select MongoDB.
    Port Number The service port of the self-managed MongoDB database.
    Database Name The name of the database corresponding to the account if authentication is enabled.
    Database Account The username of the database account used to connect to the source database. For more information about the permissions that are required for the account, see Permissions required for database accounts.
    Database Password The password of the database account used to connect to the source database.
    Note After you specify the information about the source database, you can click Test Connectivity next to Database Password to check whether the information is correct. If the information is correct, the Passed message appears. If the information is incorrect, the Failed message appears. In this case, you must click Check next to the Failed message to modify the information.
    Destination Database Instance Type Select MongoDB Instance.
    Instance Region The region where the destination ApsaraDB for MongoDB instance is deployed.
    MongoDB Instance ID The ID of the destination ApsaraDB for MongoDB instance.
    Database Name The name of the database corresponding to the account if authentication is enabled.
    Database Account The username of the database account used to connect to the destination database. For more information about the permissions that are required for the account, see Permissions required for database accounts.
    Database Password The password of the database account used to connect to the destination database.
    Note After you specify the information about the destination database, you can click Test Connectivity next to Database Password to check whether the information is correct. If the information is correct, the Passed message appears. If the information is incorrect, the Failed message appears. In this case, you must click Check next to the Failed message to modify the information.
  6. In the lower-right corner of the page, click Set Whitelist and Next.
    Note
    • You do not need to modify the security settings for ApsaraDB instances (such as ApsaraDB RDS instances and ApsaraDB for MongoDB instances) and ECS-hosted databases. DTS automatically adds the CIDR blocks of DTS servers to the IP whitelists of ApsaraDB instances or the security rules of ECS instances. For more information, see Add the CIDR blocks of DTS servers to the security settings of on-premises databases.
    • If the data source or destination is a self-managed database and the public CIDR blocks of DTS servers are added to the IP whitelist of the self-managed database to allow access from DTS servers, security risks may arise. We recommend that you strengthen authentication with accounts and passwords, restrict allowed ports, or use the internal access methods of Express Connect, VPN Gateway, or Smart Access Gateway.
    • After data migration is complete, you can remove the CIDR blocks of DTS servers from the IP whitelist.
  7. Select the migration types and the objects to be migrated. MongoDB: Select the migration types and the objects to be migrated
    Parameter Description
    Select the migration types
    • To perform only full data migration, select only Full Data Migration.
      Note To ensure data consistency, do not write new data into the source database during full data migration.
    • To ensure service continuity during data migration, select Full Data Migration and Incremental Data Migration.
      Note Before you migrate incremental data from a standalone self-managed MongoDB database, you must enable oplog for the database. For more information, see Preparations.
    Select the objects to be migrated
    • Select one or more objects from the Source Objects section and click the icon to move the objects to the Selected Objects section.
      Note
      • DTS cannot migrate data from the admin or local database.
      • The config database is an internal database. We recommend that you do not migrate data from the config database.
    • A migration object can be a database, collection, or function.
    • By default, after an object is migrated to the destination instance, the name of the object remains unchanged. You can change the names of the objects in the destination ApsaraDB for MongoDB instance by using the object name mapping feature provided by DTS. For more information, see Object name mapping.
  8. 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.
  9. After the precheck succeeds, click Next.
  10. 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
  11. Switch your workloads to the destination ApsaraDB for MongoDB instance.