ApsaraDB for MongoDB provides standalone instances, replica set instances, and sharded cluster instances. Standalone instances are suitable in development environments and test environments that store unimportant data. Replica set instances and sharded cluster instances are suitable in production environments. This topic describes how to migrate data from a standalone instance to a replica set instance or sharded cluster instance by using Data Transmission Service (DTS).

Prerequisites

The available storage space of the destination instance is larger than the total size of the data in the source instance.

Precautions

  • DTS uses specific resources of the source instance and destination instance during the full data migration process. This may increase the loads of the physical hosts on which these instances are deployed. If the data volume is large or the specifications of the physical hosts do not meet your requirements, the source instance and destination instance 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 does not support incremental data migration from a standalone instance. To ensure data consistency, do not write data to the source instance during the full data migration process.
  • 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.
  • To ensure better performance and stability of the instance, the system will upgrade the minor version to the latest version by default. If the minor version of your instance expires or is not included in the maintenance list and the instance is upgraded, migrated, changed, Created from a backup, Created by point-in-time, or performed Restore one or more databases of an ApsaraDB for MongoDB instance.
  • DTS cannot migrate data from the admin or local database.

Pricing

Migration type Instance fee Internet traffic fee
Full data migration Free of charge Free of charge

Migration types

All existing data in the source instance is migrated to the destination instance. This is called full data migration.

Note Full data migration is supported for databases, collections, and indexes.

Permissions required for database accounts

Instance Permission
Source ApsaraDB for MongoDB instance Read permissions on the source database
Destination ApsaraDB for MongoDB instance Read and write permissions on the destination database

For more information about how to create and authorize a database account, see Manage MongoDB databases by using DMS.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.
  2. In the upper-left corner of the page, select the resource group and the region of the target instance.
  3. Find the target instance and click its ID.
  4. At the top of the Migration Tasks page, select the region where the destination ApsaraDB for MongoDB instance is deployed.
    Select a region
  5. On the Create Migration Task page, create a migration task.
    1. Specify the information about the source database and destination database.
      Configure the source database and destination database
      Section Parameter Description
      N/A Task Name The name of the migration task. DTS automatically generates a task name. We recommend that you specify an informative name that helps identify the migration task. The task name does not need to be unique.
      Source Database Instance Type Select ApsaraDB for MongoDB.
      Instance Region Select the region where the source ApsaraDB for MongoDB instance is deployed.
      MongoDB Instance ID Select the ID of the source instance.
      Database Name Enter the name of the destination database. The permissions on the destination database must be granted to the account that is used to connect to the destination instance.
      Note If you want to use the root account, enter admin in the Database Name field.
      Database Account Enter the username of the account that is used to connect to the source instance. For more information about the permissions that are required for the account, see Permissions required for database accounts.
      Database Password Enter the password of the account that is used to connect to the source instance.
      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.
      Destination Database Instance Type Select MongoDB Instance.
      Instance Region Select the region where the destination ApsaraDB for MongoDB instance is deployed.
      MongoDB Instance ID Select the ID of the destination instance.
      Database Name Enter the name of the destination database. The permissions on the destination database must be granted to the account that is used to connect to the destination instance.
      Note If you want to use the root account, enter admin in the Database Name field.
      Database Account Enter the username of the account that is used to connect to the destination instance. For more information about the permissions that are required for the account, see Permissions required for database accounts.
      Database Password Enter the password of the account that is used to connect to the destination instance.
      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.
    2. In the lower-right corner of the page, click Set Whitelist and Next.
      Note DTS automatically creates IP address whitelists on the source instance and destination instance. The created IP address whitelists contain the IP address of the DTS server. This ensures that the DTS server can communicate with the source instance and destination instance. After the data of the source instance is migrated to the destination instance, you can delete these IP address whitelists. For more information, see Configure a whitelist for a sharded cluster instance.
    3. Configure migration types and objects to be migrated.
      Configure migration types and objects
      Parameter Description
      Migration Types Select Full Data Migration.
      Note If the source instance is a standalone instance, you can select only Full Data Migration. To ensure data consistency, do not write data to the source instance during the full data migration process.
      Objects Select objects to be migrated in the following way:
      1. Select one or more objects from the Available section.
      2. Click to move the selected objects to the Selected section.
      Note
      • DTS cannot migrate data from the admin or local database.
      • The objects that you can migrate are databases, collections, and functions.
      • By default, after an object is migrated to the destination instance, the name of the object remains unchanged. If you want an object to have a different name after the migration, you can use the object name mapping feature of DTS to rename the object. For more information, see Object name mapping.
      Specify whether to rename objects You can use the object name mapping feature of DTS to rename the objects that you want to migrate. For more information, see Object name mapping.
      Specify the retry time for a failed connection to the source instance or destination instance By default, if DTS fails to connect to the source instance or destination instance, DTS retries to establish a connection within the next 12 hours. You can specify the retry time based on your business requirements. If DTS reconnects to the source instance and destination instance within the specified period of time, DTS resumes the migration task. If DTS cannot reconnect to the source instance or destination instance within the specified period of time, the migration task fails.
      Note When DTS retries to establish a connection, you are charged for the migration task. We recommend that you specify the retry time based on your business requirements. After the source instance and destination instance are released, we recommend that you release the migration task at your earliest opportunity.
  6. View the progress of the migration task.
    When the status of the migration task changes to Completed, the data of the source instance is migrated to the destination instance.
    Note Do not manually stop a migration task. If you manually stop a migration task, the data that is migrated to the destination instance is incomplete. You can wait until the data migration task automatically stops.

References