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 10% larger than the total size of the data in the source instance. This is a recommended prerequisite.Usage notes
- DTS uses the resources of the source and destination databases during full data migration. This may increase the loads on the database servers. If you migrate a large amount of data or if the server specifications do not 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 does not support incremental data migration from a standalone instance. To ensure data consistency, do not write data to the source instance during full data migration.
- 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.
- ApsaraDB for MongoDB automatically updates the minor version of the instance to the latest version if the minor version of an ApsaraDB for MongoDB instance expires or is not included in the maintenance list and when you perform some operations. This ensures that the ApsaraDB for MongoDB instance can provide higher performance and stability. For more information, see Database version upgrade, Data migration, Overview, Restore backup data to a new ApsaraDB for MongoDB instance by backup point, Restore backup data to a new ApsaraDB for MongoDB instance by point in time, and Restore one or more databases of an ApsaraDB for MongoDB instance.
- DTS cannot migrate data from the admin or local database.
- 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 ApsaraDB for MongoDB instance does not have the same primary key as that in the source instance. The default primary key is _id. Otherwise, data may be lost. If the destination instance has the same primary key as that in the source instance, delete the same document that corresponds to the _id primary key in the destination instance as that in the source instance without affecting your business.
Billing
Migration type | Task configuration fee | Internet traffic fee |
---|---|---|
Full data migration | Free of charge. | Free of charge. |
Migration types
Full data migration: DTS migrates all existing data of the source MongoDB database to the destination MongoDB database.
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 a database account and grant permissions to the database account, see Manage MongoDB databases by using DMS.
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. When the status of the migration task changes to Completed, the data of the source instance is migrated to the destination instance.Note 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.
- 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.