This topic describes how to migrate incremental data from a MongoDB Atlas database to Alibaba Cloud by using Data Transmission Service (DTS). 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 uses resources of the source and destination instances during full data migration. This may increase the load of the database server. If you migrate a large volume of data or if the server specifications cannot meet your requirements, the databases may be overloaded or become unavailable. We recommend that you migrate data during off-peak hours.
  • You 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 MongoDB Atlas database and the destination ApsaraDB for MongoDB instance 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 type Instance 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 data of the migration objects is migrated from the source instance to the destination instance.
Note The following types of objects are supported: database, collection, and index.
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 that are performed on databases, collections, and indexes can be synchronized.
  • The create, delete, and update operations that are performed on documents can be synchronized.

Required database account permissions

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

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. Log on to the DTS console.
  2. In the left-side navigation pane, click Data Migration.
  3. In the upper part of the Migration Tasks page, select the region where the ApsaraDB for MongoDB instance is deployed.
    Select a region
  4. In the upper-right corner of the page, click Create Migration Task.
  5. In the Configure Source and Destination step, configure the source and destination databases for the migration task.
    Configure the source and destination databases
    Section Parameter Description
    N/A Task Name The name of the migration task. DTS automatically generates a task name. We recommend that you set a descriptive name that makes it easy to identify. Task names do not have to be unique.
    Source Database Instance Type The category of the source database. In this example, select User-Created Database with Public IP Address.
    Instance Region The region where the source database resides. If Instance Type is set to User-Created Database with Public IP Address, you do not need to set Instance Region.
    Database Type The database engine of the source database. In this example, 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 The name of the authentication database to which the database account belongs.
    Database Account The account that is used to log on to the source database. For more information about the permissions that are required for the account, see Required database account permissions.
    Database Password The password of the source database account.
    Note After you specify the source database information, click Test Connectivity next to Database Password to verify whether the information is valid. If the information is valid, the Passed message appears. If the information is invalid, the Failed message appears, and you must click Check next to the Failed message to modify the information.
    Connection method Specifies whether to encrypt the connection. In this example, select SSL-encrypted.
    Destination Database Instance Type The category of the destination instance. In this example, select MongoDB Instance.
    Instance Region The region where the destination instance is deployed.
    MongoDB Instance ID The ID of the destination instance.
    Database Name The name of the authentication database to which the database account belongs.
    Note If the database account is root, enter admin.
    Database Account The account that is used to log on to the destination database. For more information about the permissions that are required for the account, see Required database account permissions.
    Database Password The password of the destination database account.
    Note After you specify the destination database parameters, click Test Connectivity next to Database Password to verify whether the information is valid. If the information is valid, the Passed message appears. If the information is invalid, the Failed message appears, and 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 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.
  7. Configure the migration object and migration type.
    Settings Description
    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, do not write data to the source database when the migration is in progress. This can ensure data consistency.
    Migration objects
    • Select objects from the Available section and click the Right arrow icon to move the objects to the Selected section.
      Note You cannot migrate data from the admin or local 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 object names You can use the object name mapping feature to change the names of the objects that are synchronized 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 period of 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.
    Specify whether to copy temporary tables to the destination database when Data Management (DMS) performs online data definition language (DDL) operations on the source table If you use Data Management (DMS) to perform online DDL operations on the source database, you can specify whether to migrate temporary tables generated by online DDL operations.
    • Yes: DTS migrates the data of temporary tables generated by online DDL operations.
      Note If online DDL operations generate a large amount of data, the migration task is delayed.
    • No: DTS does not migrate the data of temporary tables generated by online DDL operations. Only the original DDL data of the source database is migrated.
      Note If you select No, the tables in the destination database may be locked.
  8. In the lower-right corner of the page, click Precheck.
    Notice
    • Before you can start the data migration task, a precheck is performed. DTS can migrate data only if the precheck is past.
    • If the precheck fails, click the Prompt icon next to each failed item to view details. Fix the issues as prompted and run the precheck again.
  9. After the task passes the precheck, click Next.
  10. In the Confirm Settings dialog box, specify the Channel Specification parameter and then read and select Data Transmission Service (Pay-As-You-Go) Service Terms.
  11. Click Buy and Start to start the migration task.
    • Full data migration

      Do not manually stop a task during full data migration. Otherwise, the system may fail to perform a full data migration. Wait until the full data migration task automatically stops.

    • Incremental data migration

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

      Note Manually stop the migration task at an appropriate point of time. For example, you can stop the migration task during off-peak hours or before you switch your workloads to the destination 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 latency time of incremental data migration may be displayed in the progress bar.
      2. After the status of incremental data migration changes to The migration task is not delayed, manually stop the migration task. No latency exists during incremental data migration
  12. Switch over your workloads to the destination ApsaraDB for MongoDB instance.