This topic describes how to migrate data from an ApsaraDB for MongoDB replica set instance to an ApsaraDB for MongoDB sharded cluster instance by using Data Transmission Service (DTS). DTS supports full data migration and incremental data migration. When you migrate data between ApsaraDB for MongoDB instances, you can select both of the supported migration types to ensure service continuity.
Prerequisites
Each shard in the destination sharded cluster instance has sufficient storage space.Usage notes
- DTS consumes the resources of the source and destination databases during full data migration. This may increase the loads on the database servers. If the loads on the database servers are high or the server specifications do not meet the migration 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.
- 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.
- The data is concurrently written to the destination database. Therefore, the storage space occupied in the destination database is 5% to 10% larger than the size of the data in the source database.
- Make sure that the destination MongoDB database does not have the same primary key as the source database. The default primary key is _id. Otherwise, data loss may occur in the destination database. If the destination database has the same primary key as the source database, clear the related data in the destination database without interrupting the services of DTS. If the same primary key is _id, you can delete the data in the destination database that has the same _id as the source database.
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 Billing overview. |
Incremental data migration | Charged. For more information, see Billing overview. |
Migration types
Migration type | Description |
---|---|
Full data migration | DTS migrates the existing data of 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 migrates incremental data from the source MongoDB database to the destination MongoDB database. Note
|
Permissions required for database accounts
Instance | Full data migration | Incremental data migration |
---|---|---|
ApsaraDB for MongoDB replica set instance | Read permissions on the source database | Read permissions on the source, admin, and local databases |
ApsaraDB for MongoDB sharded cluster instance | Read and write permissions on the destination database | Read and write permissions on the destination database |
Preparations
Create databases and collections to be sharded in the destination ApsaraDB for MongoDB instance, and configure data sharding based on your business requirements. For more information, see Configure sharding to maximize the performance of shards.
Procedure
- Log on to the ApsaraDB for MongoDB console.
- In the left-side navigation pane, click Replica Set Instances.
- In the upper-left corner of the page, select the resource group and region to which the instance belongs.
- On the page that appears, find the instance that you want to manage and click its ID.
- In the upper-right corner of the page that appears, click Migrate Databases.
- On the Create Migration Task page, create a migration task.
- View the progress of the 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 may be incomplete. You can 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.
- Wait until Incremental Data Migration and The migration task is not delayed appear in the progress bar of the data migration task. Then, stop writing data to the source instance for a few minutes. The latency of incremental data migration may be displayed in the progress bar.
- Wait until the status of incremental data migration changes to The migration task is not delayed again. Then, manually stop the migration task.
- Full data migration
- Switch your workloads to the destination ApsaraDB for MongoDB instance.
What to do next
If you no longer need the source instance, release the source instance.
- If the source instance is charged based on the pay-as-you-go billing method, you can release the instance. For more information, see Release an instance or a node.
- If the source instance is charged based on the subscription billing method, you are not allowed to release the instance.