This document describes how to use the data migration feature of DTS to migrate data from MongoDB to TencentDB for MongoDB.
MongoDB supports heterogeneous migration between replica set and sharded cluster, i.e., four source-target architecture scenarios: replica set-to-replica set, replica set-to-sharded cluster, sharded cluster-to-replica set, and sharded cluster-to-sharded cluster.
use admin
db.createUser({
user: "username",
pwd: "password",
roles:
[
{role: "readAnyDatabase", db: "admin"},
{role: "read", db: "local"}
]
})
TencetDTSData
during data migration.Note:Only replica set migration supports DDL operations, while shard migration will filter out DDL operations (except transactions).
Operation Type | Supported SQL Operation |
---|---|
DML | INSERT, UPDATE, and DELETE |
DDL | INDEX: createIndexes, createIndex, dropIndex, and dropIndexes COLLECTION: createCollection, drop, collMod, renameCollection, and convertToCapped DATABASE: dropDatabase and copyDatabase |
Type | Environment Requirements |
---|---|
Source database requirements | TencetDTSData . |
Target database requirements | TencetDTSData . mongos , config server , and mongod node information. |
Log in to the DTS console, select Data Migration on the left sidebar, and click Create Migration Task to enter the Create Migration Task page.
On the Create Migration Task page, select the types, regions, and specifications of the source and target instances and click Buy Now.
Configuration Item | Description |
---|---|
Source Instance Type | Select the source database type, which cannot be changed after purchase. In this scenario, select MongoDB. |
Source Instance Region | Select the source database region. If the source database is a self-built one, select a region nearest to it. |
Target Instance Type | Select the target database type, which cannot be changed after purchase. In this scenario, select MongoDB. |
Target Instance Region | Select the target database region. |
Specification | Select the specification of the migration linkage according to your business conditions. |
On the Set source and target databases page, configure the task, source database, and target database settings.
Note:Create a read-only account in the source instance for migration; otherwise, the precheck will fail.
As there are many cross-scenarios of source database deployment modes and access types, the migration steps for different scenarios are similar. The following only provides configuration examples for typical scenarios. For other scenarios, configure by referring to the examples.
Example 1: Migrate a local self-built MongoDB instance (sharded cluster) to a TencentDB instance over Direct Connect.
Setting Type | Configuration Item | Description |
---|---|---|
Task Configuration | Task Name | Set a meaningful name for easy task identification. |
Running Mode |
| |
Source Database Settings | Source Database Type | The source database type selected during purchase, which cannot be changed. |
Region | The source database region selected during purchase, which cannot be changed. | |
Access Type | Select a type based on your scenario. This scenario takes Direct Connect as an example. For the preparations for different access types, see Overview.
| |
Architecture | Select the architecture of the source database. This scenario takes Cluster Migration as an example. | |
VPC-based Direct Connect Gateway | Only VPC-based direct connect gateway is supported. Confirm the network type associated with the gateway. | |
VPC | Select the VPC and subnet of the VPC-based Direct Connect gateway. | |
Node - mongod | Enter the IP and port of the mongod node and separate multiple nodes by line breaks, such as `186.3.55.77:6379`. | |
Node - mongos | Enter the IP and port of the mongos node. | |
Node - config server | Enter the IP and port of the config server node. | |
Authentication Required | Select whether to check the security of username and password in the source database. | |
Authentication Database | Name of the database to be authenticated, i.e., name of the database of the account executing the migration task, such as `admin`. | |
Authentication Mechanism | Currently, SCRAM-SHA-1 is supported. | |
Account & Password Selection | If the three nodes of mongod, mongos, and config server in the source database have the same account and password, select Same account & password; otherwise, select Different accounts & passwords and enter their respective accounts and passwords. | |
Target Database Settings | Target Database Type | The target database type selected during purchase, which cannot be changed. |
Region | The target database region selected during purchase, which cannot be changed. | |
Access Type | In this scenario, select Database. | |
Database Instance | Select the instance ID of the target database. | |
Account | Account of the target database, which must have the required permissions. | |
Password | Password of the target database. |
Setting Type | Configuration Item | Description |
---|---|---|
Task Configuration | Task Name | Set a meaningful name for easy task identification. |
Running Mode |
| |
Tag | Tags are used to manage resources by category in different dimensions. If the existing tags do not meet your requirements, go to the console to create more. | |
Source Database Settings | Source Database Type | The source database type selected during purchase, which cannot be changed. |
Region | The source database region selected during purchase, which cannot be changed. | |
Access Type | If the source database is a TencentDB instance, select Database. For the preparations for different access types, see Overview.
| |
Cross-/Intra-Account | This parameter needs to be configured when TencentDB is selected as the access type.
| |
Database Instance | Select the instance ID of the source database. | |
Account | Account of the source MongoDB database, which must have the required permissions. | |
Password | Password of the source MongoDB database. | |
Target Database Settings | Target Database Type | The target database type selected during purchase, which cannot be changed. |
Region | The target database region selected during purchase, which cannot be changed. | |
Access Type | In this scenario, select Database. | |
Database Instance | Select the instance ID of the target database. | |
Account | Account of the target database, which must have the required permissions. | |
Password | Password of the target database. |
Setting Type | Configuration Item | Description |
---|---|---|
Task Configuration | Task Name | Set a meaningful name for easy task identification. |
Running Mode |
| |
Source Database Settings | Source Database Type | The source database type selected during purchase, which cannot be changed. |
Region | The source database region selected during purchase, which cannot be changed. | |
Access Type | For a third-party cloud database, you can select Public Network generally or select VPN Access, Direct Connect, or CCN based on your actual network conditions. This scenario takes Public Network as an example. For the preparations for different access types, see Overview.
| |
Architecture | Select the architecture of the source database. This scenario takes Cluster Migration as an example. | |
Node - mongod | Enter the IP and port of the mongod node and separate multiple nodes by line breaks, such as `186.3.55.77:6379`. | |
Node - mongos | Enter the IP and port of the mongos node. | |
Node - config server | Enter the IP and port of the config server node. | |
Authentication Required | Select whether to check the security of username and password in the source database. | |
Authentication Database | Name of the database to be authenticated, i.e., name of the database of the account executing the migration task, such as `admin`. | |
Authentication Mechanism | Currently, SCRAM-SHA-1 is supported. | |
Account & Password Selection | If the three nodes of mongod, mongos, and config server in the source database have the same account and password, select Same account & password; otherwise, select Different accounts & passwords and enter their respective accounts and passwords. | |
Target Database Settings | Target Database Type | The target database type selected during purchase, which cannot be changed. |
Region | The target database region selected during purchase, which cannot be changed. | |
Access Type | In this scenario, select Database. | |
Database Instance | Select the instance ID of the target database. | |
Account | Account of the target database, which must have the required permissions. | |
Password | Password of the target database. |
Test the connectivity between the source and target instances.
If the connectivity test fails, fix the problem as instructed in Failed Connectivity Test.
On the Set migration options and select migration objects page, set the migration options and migration objects (you can select specified databases and tables).
Configuration Item | Description |
---|---|
Migration Type | Select a type based on your scenario.
|
Migration Object |
|
Specified objects | Select the objects to be migrated in Source Database Object and move them to the Selected Object box. |
On the Verify task page, complete the precheck and click Start Task.
If the verification fails, fix the problem as instructed in Fix for Verification Failure and initiate the verification task again.
Was this page helpful?