Migrate Huawei Cloud document database to Alibaba Cloud
This topic describes how to use Data Transmission Service (DTS) to migrate a document database from Huawei Cloud to an Alibaba Cloud MongoDB instance. DTS supports both full data migration and incremental data migration. Combining these two migration types enables a smooth database migration without application downtime.
Prerequisites
-
The source Huawei Cloud document database must be a single-node or replica set instance.
NoteDTS does not support incremental data migration when migrating a single-node instance to Alibaba Cloud.
-
The destination Alibaba Cloud MongoDB instance must have more storage space than the source Huawei Cloud document database.
Notes
-
A full data migration consumes resources on both the source and target databases, which increases the database server load. If your database already has a high load or low specifications, this can degrade performance or even make the service unavailable. Evaluate your system carefully and perform the data migration during off-peak hours.
-
If a migration task fails, DTS automatically attempts to recover it. To prevent an automatic recovery from overwriting data on the target instance, you must stop or release the task before switching your services to the target instance.
-
Migration of the
adminandlocaldatabases is not supported. -
See Versions and storage engines for the versions and storage engines supported by Alibaba Cloud MongoDB instances. If you migrate data across different versions or storage engines, verify compatibility in advance.
-
DTS writes data concurrently. As a result, the target requires 5% to 10% more storage space than the source.
-
Ensure that the target contains no documents with the same primary key (
_idby default) as the source. Otherwise, data loss will occur. If the target contains documents with matching primary keys, delete the conflicting documents from the target before you start the migration, as long as this does not impact your services.
Billing
| Migration type | Link Configuration Fee | Data transfer cost |
| Full data migration | Free of charge. | You are charged only when data is migrated out of 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 | Migrates all historical data of the selected objects from the source MongoDB database to the destination MongoDB database. Note DTS supports the migration of databases, collections, and indexes. |
| Incremental data migration | After a full data migration, DTS synchronizes incremental data updates from the source MongoDB database to the destination MongoDB database. Note
|
Database account permissions
|
Source database |
Full data migration |
Incremental data migration |
|
HUAWEI CLOUD Document Database |
|
|
|
Alibaba Cloud MongoDB instance |
|
|
To create a database account and grant permissions:
-
For an Alibaba Cloud MongoDB instance, see Manage MongoDB database users in DMS.
-
For a HUAWEI CLOUD Document Database, see MongoDB Create User instructions.
Preparation
-
Log in to the Huawei Cloud document database console.
-
Click the instance ID to open the Instance Management page.
-
On the Basic Information tab, in the Instance Information section, click the SSL slider to disable SSL.
WarningDisabling SSL will cause the instance to restart. Proceed with caution.
-
On the Basic Information tab, in the Node Information section, click Bind EIP.
NoteYou can bind a public IP address to a node with either the Primary or Secondary role.
-
Primary node: The primary node in a replica set instance. Its database supports read and write operations.
-
Secondary node: A secondary node in a replica set instance. Its database supports read operations only.
In the Bind EIP dialog box, select an available elastic IP and click OK.
-
-
On the Basic Information tab, in the Network section, click the security group ID.
-
On the Security Group Settings page, add the IP address range of the DTS servers to the Inbound Rules. Click Add Rule. In the Add Inbound Rule dialog box, configure the Protocol, Port, and Source, and then click OK.
Note-
The default port for the Huawei Cloud document database is 8635. If you modified the port, enter the new port number.
-
In the IP address ranges of the DTS servers document, select the IP address range based on the region of your target instance. For example, if your source instance is in the China (Hangzhou) region and your target instance is in the China (Shenzhen) region, you must add the DTS IP address range for China (Shenzhen) to the allowlist of the source instance.
-
Procedure
-
Navigate to the migration task list page for the destination region using one of the following methods.
From the DTS console
-
Log on to the Data Transmission Service (DTS) console.
-
In the navigation pane on the left, click Data Migration.
-
In the upper-left corner of the page, select the region where the migration instance is located.
From the DMS console
NoteThe actual operations may vary based on the mode and layout of the DMS console. For more information, see Simple mode console and Customize the layout and style of the DMS console.
-
Log on to the Data Management (DMS) console.
-
In the top menu bar, choose .
-
To the right of Data Migration Tasks, select the region where the migration instance is located.
-
-
Click Create Task to navigate to the task configuration page.
-
Configure the source and destination databases.
WarningAfter you select the source and destination instances, we recommend that you carefully read the limits displayed at the top of the page. Otherwise, the task may fail or data inconsistency may occur.
Category
Parameter
Description
N/A
Task Name
DTS automatically generates a task name. We recommend that you specify a descriptive name for easy identification. The name does not need to be unique.
Source Database
Select a DMS database instance.
You can choose whether to use an existing instance, as needed.
-
If you use an existing instance, the database information below is automatically filled in. You do not need to enter it again.
-
If you do not use an existing instance, you must configure the database information below.
Note-
In the DMS console, you can click Add DMS Database Instance to register a database with DMS. For more information, see ApsaraDB Data Ingestion and Register a database hosted on a third-party cloud service or a self-managed database.
-
In the DTS console, you can register a database with DTS on the Database Connections page or the new configuration page. For more information, see Manage database connections.
Database Type
Select MongoDB.
Connection Type
Select Public IP.
Instance Region
Select the region where the Huawei Cloud document database is located.
NoteIf the region where the Huawei Cloud document database is located is not available in the drop-down list, you can select the closest region.
Architecture
Select Replica Set.
Domain Name or IP
Enter the EIP (Elastic IP Address) for the Huawei Cloud document database that you bound in Preparations.
Port
Enter the port number of the Huawei Cloud document database. In this example, enter 8635.
Authentication database
Enter the name of the authentication database. The default value is admin.
Database Account
Enter the database account for the Huawei Cloud document database. For the required permissions, see Database account permissions.
Database Password
Enter the password for the database account.
Connection Method
Select Non-encrypted.
Destination Database
Select a DMS database instance.
You can choose whether to use an existing instance, as needed.
-
If you use an existing instance, the database information below is automatically filled in. You do not need to enter it again.
-
If you do not use an existing instance, you must configure the database information below.
Note-
In the DMS console, you can click Add DMS Database Instance to register a database with DMS. For more information, see ApsaraDB Data Ingestion and Register a database hosted on a third-party cloud service or a self-managed database.
-
In the DTS console, you can register a database with DTS on the Database Connections page or the new configuration page. For more information, see Manage database connections.
Database Type
Select MongoDB.
Connection Type
Select Cloud Instance.
Instance Region
Select the region where the target Alibaba Cloud MongoDB instance is located.
Architecture type
Select an architecture based on your business requirements. Valid values:
-
Replica Set: This architecture deploys multiple node types to achieve high availability and read/write splitting. For more information, see Replica set architecture.
-
Sharded Cluster: This architecture provides three components: Mongos, Shard, and ConfigServer. You can specify the number and configurations of Mongos and Shard nodes. For more information, see Sharded cluster architecture.
Instance ID
Select the instance ID of the target Alibaba Cloud MongoDB instance.
Authentication database
Enter the name of the authentication database. The default value is admin.
Database Account
Enter the database account for the target Alibaba Cloud MongoDB instance. For the required permissions, see Database account permissions.
Database Password
Enter the password for the database account.
-
-
After you complete the configuration, click Test Connectivity and Proceed at the bottom of the page. In the CIDR Blocks of DTS Servers dialog box that appears, click Test Connectivity.
NoteEnsure that the IP address segments of the DTS service are automatically or manually added to the security settings of the source and destination databases to allow access from DTS servers. For more information, see Add DTS server IP addresses to a whitelist.
-
Configure the task objects.
-
On the Configure Objects page, configure the objects that you want to migrate.
Parameter
Description
Migration Types
-
To perform only a full data migration, select Schema Migration and Full Data Migration.
-
To perform a migration with minimal downtime, select Schema Migration, Full Data Migration, and Incremental Data Migration.
NoteWhen you migrate a single-node Huawei Cloud document database, only full data migration is supported. To ensure data consistency, do not write new data to the source database during the full data migration.
Processing Mode of Conflicting Tables
- Precheck and Report Errors: checks whether the destination database contains collections that have the same names as collections in the source database. If the source and destination databases do not contain collections that have identical collection names, the precheck is passed. Otherwise, an error is returned during the precheck and the data synchronization task cannot be started. Note You can use the object name mapping feature to rename the collections that are synchronized to the destination database. You can use this feature if the source and destination databases contain identical collection names and the collections in the destination database cannot be deleted or renamed. For more information, see Set object names in the destination instance.
- Ignore Errors and Proceed: skips the precheck for identical collection names in the source and destination databases. Warning If you select Ignore Errors and Proceed, data inconsistency may occur, and your business may be exposed to potential risks.
- DTS does not synchronize data records that have the same primary key values as data records in the destination database.
- Data may fail to be initialized, only some columns are synchronized, or the data synchronization task fails.
Capitalization of Object Names in Destination Instance
You can configure the case policy for database and collection object names in the destination instance. By default, the DTS default policy is selected. Alternatively, you can match the default policy of the source or destination database. For more information, see Case policy for destination object names.
Source Objects
Select one or more objects from the Source Objects section. Click the
icon and add the objects to the Selected Objects section. NoteYou can select migration objects at the DATABASE and COLLECTION levels.
Selected Objects
-
To change the name of a single migration object in the target instance, right-click the object in the Selected Objects box. For more information, see Map individual schema, table, and column names.
-
To change the names of multiple migration objects in the target instance, click Selected Objects in the upper-right corner of the Batch Edit box. For more information, see Map multiple schema, table, and column names.
Note-
Using the object name mapping feature can cause the migration of dependent objects to fail.
-
To filter data by using a condition, right-click the migration object in the Selected Objects box and specify the filter condition in the dialog box that appears. For more information, see Configure filter conditions.
-
-
Click Next: Advanced Settings to configure advanced parameters.
Parameter
Description
Retry Time for Failed Connections
After the migration task starts, if the connection to the source or destination database fails, DTS reports an error and immediately begins to retry the connection. The default retry duration is 720 minutes. You can customize the retry time to a value from 10 to 1440 minutes. We recommend that you set the duration to more than 30 minutes. If DTS reconnects to the source and destination databases within the specified duration, the migration task automatically resumes. Otherwise, the task fails.
Note-
For multiple DTS instances that share the same source or destination, the network retry time is determined by the setting of the last created task.
-
Because you are charged for the task during the connection retry period, we recommend that you customize the retry time based on your business needs, or release the DTS instance as soon as possible after the source and destination database instances are released.
Retry Time for Other Issues
After the migration task starts, if a non-connectivity issue, such as a DDL or DML execution exception, occurs in the source or destination database, DTS reports an error and immediately begins to retry the operation. The default retry duration is 10 minutes. You can customize the retry time to a value from 1 to 1440 minutes. We recommend that you set the duration to more than 10 minutes. If the related operations succeed within the specified retry duration, the migration task automatically resumes. Otherwise, the task fails.
ImportantThe value of Retry Time for Other Issues must be less than the value of Retry Time for Failed Connections.
Enable Throttling for Full Data Migration
During full migration, DTS consumes read and write resources on the source and destination databases, which may increase the database load. If required, you can enable throttling for the full migration task. You can set Queries per second (QPS) to the source database, RPS of Full Data Migration, and Data migration speed for full migration (MB/s) to reduce the load on the destination database.
Note-
This configuration item is available only if you select Full Data Migration for Migration Types.
-
You can also adjust the full migration speed after the migration instance is running.
Enable Throttling for Incremental Data Migration
If required, you can also choose to set speed limits for the incremental migration task. You can set RPS of Incremental Data Migration and Data migration speed for incremental migration (MB/s) to reduce the load on the destination database.
Note-
This configuration item is available only if you select Incremental Data Migration for Migration Types.
-
You can also adjust the incremental migration speed after the migration instance is running.
Environment Tag
You can select an environment tag to identify the instance. This is not required for this example.
Configure ETL
Based on your business needs, select whether to configure the ETL feature to process data.
-
Yes: Configures the ETL feature. You must also enter data processing statements in the text box.
-
No: Does not configure the ETL feature.
Monitoring and Alerting
Select whether to set alerts and receive alert notifications based on your business needs.
-
No: Does not set an alert.
-
Yes: Configure alerts by setting an alert threshold and an alert contact. If a migration fails or the latency exceeds the threshold, the system sends an alert notification.
-
-
Click Next: Data Validation to configure a data validation task.
For more information about the data validation feature, see Configure data validation.
-
-
Save the task and run a precheck.
-
To view the parameters for configuring this instance when you call the API operation, move the pointer over the Next: Save Task Settings and Precheck button and click Preview OpenAPI parameters in the bubble that appears.
-
If you do not need to view or have finished viewing the API parameters, click Next: Save Task Settings and Precheck at the bottom of the page.
Note-
Before the migration task starts, DTS performs a precheck. The task starts only after it passes the precheck.
-
If the precheck fails, click View Details next to the failed check item, fix the issue based on the prompt, and then run the precheck again.
-
If a warning is reported during the precheck:
-
For check items that cannot be ignored, click View Details next to the failed item, fix the issue based on the prompt, and then run the precheck again.
-
For check items that can be ignored, you can click Confirm Alert Details, Ignore, OK, and Precheck Again to skip the alert item and run the precheck again. If you choose to ignore a warning, it may cause issues such as data inconsistency and pose risks to your business.
-
-
-
Purchase the instance.
-
When the Success Rate is 100%, click Next: Purchase Instance.
-
On the Purchase page, select the link specification for the data migration instance. For more information, see the following table.
Category
Parameter
Description
New Instance Class
Resource Group Settings
Select the resource group to which the instance belongs. The default value is default resource group. For more information, see What is Resource Management?
Instance Class
DTS provides migration specifications with different performance levels. The link specification affects the migration speed. You can select a specification based on your business scenario. For more information, see Data migration link specifications.
-
After the configuration is complete, read and select Data Transmission Service (Pay-as-you-go) Service Terms.
-
Click Buy and Start. In the OK dialog box that appears, click OK.
You can view the progress of the migration task on the Data Migration Tasks list page.
Note-
If the migration task does not include incremental migration, it stops automatically after the full migration is complete. After the task stops, its Status changes to Completed.
-
If the migration task includes incremental migration, it does not stop automatically. The incremental migration task continues to run. While the incremental migration task is running, the Status of the task is Running.
-
-
Procedure (legacy console)
-
Log in to the DTS console.
NoteIf you are automatically redirected to the Data Management (DMS) console, you can click the
icon in the lower-right corner and then click
to return to the classic DTS console. - In the left-side navigation pane, click Data Migration.
-
At the top of the Migration Tasks page, select the region of the destination ApsaraDB for MongoDB instance.
- In the upper-right corner, click Create Migration Task.
-
Configure the source and destination databases. The following table describes the parameters.
Category
Parameter
Description
N/A
Task name
DTS automatically generates a task name. Specify a descriptive name for easier identification. The name does not need to be unique.
Source database
Instance type
Select Self-managed MongoDB with Public IP.
Instance region
If you set Instance type to Self-managed MongoDB with Public IP, you do not need to set the Instance region parameter.
Database type
Select MongoDB.
Hostname or IP address
Enter the EIP (Elastic IP Address) for the Huawei Cloud document database that you bound in Preparations.
Port
Enter the port number of the Huawei Cloud document database. In this example, enter 8635.
Database
Enter the name of the authentication database. The default value is admin.
Database account
Enter the database account for the Huawei Cloud document database. For more information about the permission requirements, see Database account permissions.
Database password
Enter the password for the database account.
NoteAfter you enter the source database information, you can click Test Connection next to Database Password to verify that the information is correct. If the information is correct, a Test Passed message is displayed. If a Test Failed message is displayed, click Diagnose next to Test Failed and adjust the source database information based on the prompts.
Connection mode
Select Non-encrypted.
NoteThe SSL-encrypted mode is available only when you migrate a MongoDB Atlas database.
Destination database
Instance type
Select MongoDB Instance.
Instance region
Select the destination instance's region.
MongoDB instance ID
Select the destination instance ID.
Database
Enter the name of the authentication database. The default value is admin.
Database account
Enter the database account for the ApsaraDB for MongoDB instance. For more information about the permission requirements, see Database account permissions.
Database password
Enter the password for the database account.
NoteAfter you enter the target database information, you can click Test Connection next to Database Password to verify that the information is correct. If the information is correct, a Test Passed message is displayed. If a Test Failed message is displayed, click Diagnose next to Test Failed and adjust the target database information based on the prompts.
-
After you complete the configuration, click Set Whitelist and Continue in the lower-right corner of the page.
If the source or destination database is an Alibaba Cloud database instance, such as an ApsaraDB RDS for MySQL or ApsaraDB for MongoDB instance, DTS automatically adds the CIDR blocks of DTS servers in the corresponding region to the whitelist of the instance. If the source or destination database is a self-hosted database that is deployed on an ECS (Elastic Compute Service) instance, DTS automatically adds the CIDR blocks of DTS servers to the security rules of the security group to which the ECS instance belongs. You must also ensure that the self-hosted database can be accessed from the ECS instance. If the database is deployed in a cluster on multiple ECS instances, you must manually add the CIDR blocks of DTS servers to the security rules of the security group for each ECS instance. If the source or destination database is a self-hosted database in an on-premises data center or a database service provided by another cloud service provider, you must manually add the CIDR blocks of DTS servers to the IP address whitelist of the database. For more information, see Add the CIDR blocks of DTS servers to the security settings of a database.
WarningAdding public IP addresses 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, such as using strong passwords, restricting open ports, using authentication for internal APIs, regularly reviewing and limiting unnecessary network segments, or connecting by using private connections such as Express Connect, VPN Gateway, or Smart Access Gateway.
-
Select the migration types and objects. The following table describes the parameters.
Parameter
Description
Migration types
-
To perform only a full data migration, select Full Data Migration.
NoteWhen you migrate a single-node Huawei Cloud document database, only full data migration is supported. To ensure data consistency, do not write data to the source database during the full data migration.
-
To perform a data migration with minimal downtime, select both Full Data Migration and Incremental Data Migration.
Migration objects
-
In the Available box, select the objects to migrate and click the
icon to move them to the Selected Objects box. NoteYou cannot migrate the admin and local databases.
-
You can select objects to migrate at the database, collection, or function level.
-
By default, migrated object names are unchanged in the destination database. To change the names, use the object name mapping feature of DTS. For more information, see Object name mapping.
Object name mapping
To change the name of a migration object in the destination instance, use the object name mapping feature. For more information, see Object name mapping.
Connection retry duration
Specify how long DTS retries to connect to a disconnected database. The default value is 12 hours. If DTS cannot reconnect within this period, the migration task fails.
NoteYou are charged for a migration task that is retrying to connect to a database. We recommend that you specify a proper duration based on your business requirements. You can also release the DTS instance as soon as possible after the source and destination database instances are released.
-
-
After you complete the preceding configurations, click Precheck and start in the lower-right corner of the page.
Note-
A precheck runs before the migration task starts. The task begins only after the precheck is successful.
-
If the precheck fails, click the
icon next to the failed check item to view the details.-
Fix the issues as instructed and run the precheck again.
-
If a warning item does not require a fix, you can also select Ignore or Ignore and Rerun Precheck to bypass the warning item and run the precheck again.
-
-
- After the precheck succeeds, click Next.
-
On the Confirm page, specify the Link specification parameter and select the DTS (Pay-As-You-Go) Service Terms checkbox.
- Click Buy and Start to start the migration task.
- Full data migration
Do not manually end a migration task. If you do so, the system may fail to migrate all data of the database. Wait until the migration task is complete.
- Incremental data migration
An incremental data migration task does not automatically end. You need to manually end the task.
Note Select an appropriate point in time to manually end a migration task. For example, you can end the migration task during off-peak hours or before you switch over your business to the destination ApsaraDB for MongoDB instance.- When the task progress bar displays Incremental Data Migration and The migration task is not delayed, stop writing data to the source database for a few minutes. Wait until the progress bar displays the delay time of the incremental data migration next to Incremental Data Migration.
- After the status of Incremental Data Migration changes to The migration task is not delayed, manually end the migration task.

- Full data migration
-
Switch your workloads to the destination ApsaraDB for MongoDB instance.
More information
If the target instance is a sharded cluster instance, you can configure data sharding. For more information, see Configure data sharding to optimize shard performance.
