Currently, ApsaraDB for MongoDB supports two migration solutions. Incremental data synchronization is supported during MongoDB migration; that is, MongoDB can be migrated without halting the local application server.
Log on to MongoDB Console, click the instance ID or Manage to go to the Basic Information page, and select Import Self-Built MongoDB Data to go to the Create Migration Task page.
Select MongoDB as the database type and enter the source database connection information.
Use the DTS Migration Wizard to perform the migration operation.
For detailed instructions, refer to the DTS manual.
MongoDB has built-in mongodump and mongorestore command lines that can import and export data.
Note: Use the mongodump and mongorestore tools of MongoDB 3.0 or later versions.
Back up user-created database data.
First, you need to connect to the self-built database and select an account with the relevant permissions. Then, execute
mongodumpto export the content of the self-built database. For example, execute the following statement to export all databases and create a backup file named dump.
mongodump --host xxx:27017 --authenticationDatabase admin -u xxx -p xxx
For details, refer to mongodump command official documentation.
Import the backup file into ApsaraDB for MongoDB.
mongostorecommand based on the backup file created in the previous step to import all data into ApsaraDB for MongoDB. For example, execute the following statement to import the entire database.
mongorestore --host dds-xxx:3717 --authenticationDatabase admin -u root -p xxx dump