Migrate data between ApsaraDB for MongoDB instances of different Alibaba Cloud accounts

Updated at:

Use Data Transmission Service (DTS) to migrate data between ApsaraDB for MongoDB instances that belong to different Alibaba Cloud accounts. Running both full data migration and incremental data migration together keeps your service online and maintains data consistency throughout the migration.

Prerequisites

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 DTS pricing.

Incremental data migration

Charged. For more information, see DTS pricing.

Migration types

Migration type

Description

Full data migration

DTS migrates all historical data of the required objects from the source MongoDB database to the destination MongoDB database.

Note

The following types of objects are supported: database, collection, and index.

Incremental data migration

After full data migration is complete, DTS synchronizes incremental data from the source MongoDB database to the destination MongoDB database.

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.

Permissions required for database accounts

Migration data source

Full data migration

Incremental data migration

Source MongoDB instance

The read permission on the database to be migrated

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

Destination MongoDB instance

The readWrite permission on the destination database

The readWrite permission on the destination database

Note

For information about how to create and authorize a database account, see Use DMS to manage MongoDB database users.

Preparations

  1. Use the Alibaba Cloud account of the source instance to log on to the MongoDB console. For more information, see MongoDB console.

  2. Apply for a public endpoint for the source instance. For more information, see Apply for a public endpoint.

    .dita#concept_qlm_xcw_mfb" id="xref_0yc_vzu_u50">Apply for a public endpoint.

  3. Add the DTS server IP address ranges to the whitelist of the source instance. For more information, see Modify a whitelist.

    Note

    Select the required IP address ranges based on the region of the destination instance. For more information, see Whitelist DTS server IP addresses.

    For example, if the source instance is in the Hangzhou region and the destination instance is in the Shenzhen region, add the DTS IP address ranges of the Shenzhen region to the whitelist of the source instance.

Procedure

  1. Log on to the ApsaraDB for MongoDB console.

  2. Depending on the instance type, in the navigation pane on the left, click Replica Set Instances or Sharded Cluster Instances.

  3. In the upper-left corner of the page, select the resource group and region of the instance.

    tag="ph" id="ph_uo2_6d9_lct" conref="t2134818.dita#concept_2134818/ph_gni_2e5_16r" docType="TOPIC" baseUrl="t123029_v1_13_3.dita" data-latest="1">

  4. In the upper-right corner of the instance details page, click Migrate Database.

  5. On the Create Migration Task page, configure the migration task:

    1. Configure the source and destination databases. Cross-account MongoDB source and destination database configuration

      Category

      Configuration

      Description

      None

      Task Name

      DTS automatically generates a task name. We recommend that you configure a name with business meaning (uniqueness is not required) for easier identification later.

      Source database information

      Instance type

      Select User-Created Database with Public IP Address.

      Instance region

      Select the region where the source instance is located.

      Database Type

      Select MongoDB.

      Hostname or IP address

      The domain name from the source instance's public endpoint. Example: dds-bp1b47357f218e74****-pub.mongodb.rds.aliyuncs.com.

      Port

      Enter the service port of the source instance: 3717.

      Database name

      Enter the authentication database name, that is, the database to which the database account belongs.

      Note

      If the database account is root, the corresponding database name is admin.

      Database account

      Enter the database account of the source MongoDB instance. For information about the permission requirements, see Permissions required for database accounts.

      Database password

      Enter the password of the database account.

      Note

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

      Connection method

      The method used by Data Transmission Service (DTS) to connect to the source instance. Select Non-encrypted or SSL-encrypted based on your requirements. If you select SSL-encrypted, you must enable the SSL encryption feature of the source instance in advance.

      Note
      • SSL-encrypted is currently supported only for MongoDB Atlas.

      • Selecting SSL-encrypted significantly increases CPU consumption.

      Destination database information

      Instance Type

      Select MongoDB Instance.

      Instance Region

      Select the region where the destination MongoDB instance is located.

      MongoDB Instance ID

      The ID of the destination instance.

      Database Name

      Enter the authentication database name, that is, the database to which the database account belongs.

      Note

      If the database account is root, the corresponding database name is admin.

      Database Account

      Enter the database account of the destination MongoDB instance. For information about the permission requirements, see Permissions required for database accounts.

      Database Password

      Enter the password of the database account.

      Note

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

    2. After the configuration is complete, click Set whitelist and enter next step at the bottom of the page.

      If the source or destination database is an Alibaba Cloud database instance, such as an RDS for MySQL or ApsaraDB for MongoDB instance, DTS automatically adds the CIDR blocks of DTS servers to the IP address whitelist of the instance. If the source or destination database is a self-managed database hosted on an ECS instance, DTS automatically adds the CIDR blocks of DTS servers to the security group rules of the ECS instance. You must also ensure that the database is accessible from the ECS instance. If the self-managed database is hosted on multiple ECS instances, you must manually add the CIDR blocks of DTS servers to the security group rules of each ECS instance. If the source or destination database is a self-managed database that is deployed in an on-premises data center or provided by a third-party cloud service provider, you must manually add the CIDR blocks of DTS servers to the IP address whitelist of the database to allow access from DTS servers. For more information about the IP addresses of DTS servers, see CIDR blocks of DTS servers.

      Warning

      Adding the public CIDR blocks of DTS servers, whether automatically or manually, may introduce security risks. By using this product, you acknowledge and accept these potential risks. You are responsible for implementing basic security measures, including but not limited to using strong passwords, restricting open ports, using authentication for internal API calls, regularly reviewing and restricting unnecessary network segments, or connecting through private networks such as Express Connect, VPN Gateway, or Smart Access Gateway.

    3. Set the following parameters and select the migration objects and migration types.

      Configuration

      Description

      Migration types

      We recommend that you select both Full Data Migration and Incremental Data Migration to ensure data consistency.

      If you select only Full Data Migration: During the full migration, if data is updated in the source instance, the updated data may not be migrated to the destination instance.

      If you select only Incremental Data Migration:

      • After the migration task starts, DTS migrates only the incremental data generated in the source instance.

      • Incremental migration does not support synchronization of triggers. For more information, see Configure tasks for source databases with triggers.

      Note
      • When you use DTS to migrate a standalone instance, incremental data migration is not supported.

      • If Incremental data migration is not selected, to ensure data consistency, do not write new data to the source instance during full data migration.

      Migration objects

      Select the migration objects as follows:

      1. From the Migration objects list, select the objects to be migrated.

      2. Click to move the objects to the Selected Objects list.

      Note
      • Migration of the admin and local databases is not supported.

      • The granularity of migration objects is database, collection, or function.

      • By default, after the migration is complete, the names of the migration objects remain unchanged. To change the names of the migration objects in the destination database, use the object name mapping feature. For more information, see Library, table, and column mapping.

      Mapping name changes

      To change the names of the migration objects in the destination instance, use the object name mapping feature. For more information, see Object name mapping.

      Retry time for failed connections to the source and destination databases

      The default retry time is 12 hours. You can also customize the retry time. If DTS reconnects to the source and destination databases within the specified time, the migration task automatically resumes. Otherwise, the migration task fails.

      Note

      Because DTS charges task fees during the retry period, we recommend that you customize the retry time based on business requirements, or release the DTS instance as soon as possible after the source and destination database instances are released.

    4. After the configuration above is complete, click Precheck and start at the lower-right corner of the page.

      Description

      • Before the migration task starts officially, a precheck is performed. The migration task can be started successfully only after the precheck is passed.

      • If the precheck fails, click View details next to the failed check item, and fix the issue based on the prompts before running the precheck again.

      • If the precheck produces warnings:

        • For check items that cannot be ignored, click View details next to the failed check item, and fix the issue based on the prompts before running the precheck again.

        • For check items that can be ignored without fixing, click Confirm warning details, Confirm ignore, OK, and Re-precheck in sequence to skip the warning check items and run the precheck again. If you ignore warning check items, data inconsistency and other issues may occur, which may pose risks to your business.

    5. After the precheck is passed, click Next.

    6. On the Purchase configuration confirmation page, select Link specification and select the Terms of Service for Data Transmission (Pay-As-You-Go).

    7. Click Buy and start now. The migration task officially begins.

  6. 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

      The task does not automatically stop during incremental data migration. 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 destination 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. After the status of incremental data migration changes to The migration task is not delayed again, manually stop the migration task. Incremental data migration without delay

  7. Switch business to the destination MongoDB instance.

Follow-up operations

Determine whether to release the source instance based on business requirements.

More information

When the destination instance is a sharded cluster instance, you can configure data sharding based on business requirements. For more information, see Configure sharding to maximize shard performance.