This topic describes how to use Data Transmission Service (DTS) to migrate incremental data from a MongoDB Atlas database to ApsaraDB for MongoDB. DTS supports full data migration and incremental data migration. The data migration does not interrupt your services if you select the two migration types.

Prerequisites

The storage capacity of the destination ApsaraDB for MongoDB instance is larger than the total size of the data in the MongoDB Atlas database.

Precautions

  • DTS consumes the resources of the source and destination databases during full data migration. This may increase the loads of the database servers. If you migrate a large volume of data or the server specifications cannot meet your requirements, database services may become unavailable. Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours.
  • DTS cannot migrate data from the admin or local database.
  • The config database is an internal database. We recommend that you do not migrate this database.
  • If the source and destination MongoDB databases use different versions or storage engines, make sure that your applications can run on both databases. For more information about the versions and storage engines that are supported by ApsaraDB for MongoDB, see MongoDB versions and storage engines.

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 Pricing.
Incremental data migration Charged. For more information, see Pricing.

Migration types

Migration type Description
Full data migration All existing data in the source instance is migrated to the destination instance.
Note Full data migration is supported for databases, collections, and indexes.
Incremental data migration Only the incremental data in the source instance is migrated to the destination instance.
Note
  • Incremental data migration can be used to synchronize the create and delete operations that are performed on databases, collections, and indexes.
  • Incremental data migration can be used to synchronize the create, delete, and update operations that are performed on documents.

Permissions required for database accounts

Database Full data migration Incremental data migration
Source MongoDB Atlas database The read permission on the source database and the permission to perform the listDatabases operation
  • The read permission on the source database, the admin database, and the local database
  • The permission to perform the listDatabases operation
Destination ApsaraDB for MongoDB instance The read and write permissions on the destination database The read and write permissions on the destination database

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

Preparations

  1. Log on to the MongoDB Atlas console.
  2. In the left-side navigation pane, click Network Access. On the page that appears, click ADD IP ADDRESS.
    Create an IP address whitelist for a MongoDB Atlas database
  3. In the dialog box that appears, click ALLOW ACCESS FROM ANYWHERE and click Confirm.
    Create an IP address whitelist for a MongoDB Atlas database
    Note This step allows all IP addresses to access the MongoDB Atlas database. Delete this rule after data migration is complete.

Procedure

  1. Purchase a data migration instance. For more information, see Purchase a data migration instance.
  2. Log on to the DTS console.
  3. In the left-side navigation pane, click Data Migration.
  4. At the top of the Migration Tasks page, select the region where the ApsaraDB for MongoDB instance resides.
    Select a region
  5. Find the purchased data migration instance and click Configure Migration Task.
  6. Configure the source and destination databases.
    Configure the source and destination databases
    Section Parameter Description
    N/A Task Name DTS automatically generates a task name. We recommend that you specify an informative name to identify the task. You do not need to use a unique task name.
    Source Database Instance Type Select User-Created Database with Public IP Address.
    Instance Region If you select User-Created Database with Public IP Address as the instance type, you do not need to specify the Instance Region parameter.
    Database Type Select MongoDB.
    Hostname or IP Address

    The endpoint of the PRIMARY node in the MongoDB Atlas database.

    You can obtain the endpoint in the MongoDB Atlas console, as shown in the following figure.

    Obtain the Atlas endpoint
    Port Number The service port number of the MongoDB Atlas database. The default port number is 27017.
    Database Name You must enter the name of the authentication database. The database account is created in this database.
    Database Account Enter the account of the MongoDB Atlas database. For information about the permissions that are required for the account, see Permissions required for database accounts.
    Database Password Enter the password of the database account.
    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 and you must click Check next to the Failed message to modify the information.
    Encryption Specifies whether to encrypt the connection. In this example, select SSL-encrypted.
    Destination Database Instance Type Select MongoDB Instance.
    Instance Region The region where the destination instance is deployed.
    MongoDB Instance ID The ID of the destination instance.
    Database Name You must enter the name of the authentication database. The database account is created in this database.
    Note If you want to use the root account, enter admin in the Database Name field.
    Database Account Enter the database account of the ApsaraDB for MongoDB instance. For information about the permissions that are required for the account, see Permissions required for database accounts.
    Database Password Enter the password of the database account.
    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 and you must click Check next to the Failed message to modify the information.
  7. In the lower-right corner of the page, click Set Whitelist and Next.
    Note The IP addresses of DTS servers are automatically added to the whitelist of the destination ApsaraDB for MongoDB instance. This ensures that DTS servers can connect to the destination ApsaraDB for MongoDB instance.
  8. Select the migration types and the objects to be migrated.
    Parameter Description
    Select the migration types
    • To perform only full data migration, select Full Data Migration.
    • To migrate data with minimal downtime, select both Full Data Migration and Incremental Data Migration.
    Note If Incremental Data Migration is not selected, we recommend that you do not write data to the source database during full data migration. This ensures data consistency between the source and destination databases.
    Select the objects to be migrated
    • Select one or more objects from the Source Objects section and click the Rightwards arrow icon to move the objects to the Selected Objects section.
      Note DTS cannot migrate data from the admin, local, or config database.
    • A migration object can be a database, collection, or function.
    • By default, the name of an object remains unchanged after migration. You can change the names of the objects in the destination instance by using the object name mapping feature. For more information, see Object name mapping.
    Specify whether to rename objects You can use the object name mapping feature to rename the objects that are migrated to the destination instance. For more information, see Object name mapping.
    Specify the retry time for failed connections to the source or destination database By default, if DTS fails to connect to the source or destination database, DTS retries within the next 12 hours. You can specify the retry time based on your needs. If DTS reconnects to the source and destination databases within the specified time, DTS resumes the data migration task. Otherwise, the data migration task fails.
    Note When DTS retries a connection, you are charged for the DTS instance. We recommend that you specify the retry time based on your business needs. You can also release the DTS instance at your earliest opportunity after the source and destination instances are released.
  9. In the lower-right corner of the page, click Precheck.
    Note
    • Before you can start the data migration task, a precheck is performed. You can start the data migration task only after the task passes the precheck.
    • If the task fails to pass the precheck, you can click the Info icon icon next to each failed item to view details.
      • You can troubleshoot the issues based on the causes and run a precheck again.
      • If you do not need to troubleshoot the issues, you can ignore failed items and run a precheck again.
  10. After the task passes the precheck, click Next.
  11. In the Confirm Settings dialog box, specify the Channel Specification parameter and select Data Transmission Service (Pay-As-You-Go) Service Terms.
  12. 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

      An incremental data migration task does not automatically stop. You must manually stop the task.

      Note We 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 ApsaraDB for MongoDB instance.
      1. 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.
      2. Wait until the status of incremental data migration changes to The migration task is not delayed again. Then, manually stop the migration task. No latency exists during incremental data migration
  13. Switch your workloads to the destination ApsaraDB for MongoDB instance.