ECS instances and ApsaraDB for MongoDB instances in different regions cannot communicate over the internal network by default. To establish an internal network connection, bring both instances into the same region by migrating one of them. This avoids public network traffic costs and reduces latency.
Prerequisites
Before you begin, ensure that you have:
An ECS instance using the Virtual Private Cloud (VPC) network type
An ApsaraDB for MongoDB instance using the VPC network type
If either instance uses the classic network, switch it to VPC first:
Choose a migration approach
Two approaches are available. Choose based on which resource is easier to move in your environment.
| Approach | Description |
|---|---|
| Migrate the MongoDB instance to the ECS region | Uses DTS to replicate MongoDB data to a new instance in the ECS region |
| Migrate the ECS instance to the MongoDB region | Moves the ECS instance to the MongoDB region using a custom image (recommended) or Server Migration Center |
Migrate the MongoDB instance to the ECS region
This approach uses Data Transmission Service (DTS) to replicate your MongoDB data to a new instance in the ECS region. For example, you can migrate an ApsaraDB for MongoDB instance from China (Qingdao) to China (Hangzhou).
Create an ApsaraDB for MongoDB replica set instance in the ECS region. Select the same VPC as the ECS instance. For details, see Create a replica set instance.
If an ApsaraDB for MongoDB instance already exists in the target region, skip this step.
Migrate your MongoDB databases from the source region to the new instance using DTS cross-region migration. For details, see Migrate data between ApsaraDB for MongoDB instances across regions.
Add the private IP address of the ECS instance to the whitelist of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance. To get the private IP address of your ECS instance, see View instance information.
Migrate the ECS instance to the MongoDB region
Two methods are available. Use the custom image method unless your environment requires a live server migration tool.
Method 1: Use a custom image (recommended)
This method creates a custom image from your ECS instance, copies it to the MongoDB region, and launches a new ECS instance from it. For example, you can migrate an ECS instance from China (Qingdao) to China (Hangzhou).
Create a custom image from the ECS instance. For details, see Create a custom image from an instance.
Copy the custom image to the region where the ApsaraDB for MongoDB instance is located. For details, see Copy a custom image.
Create a new ECS instance from the copied image. Select the same VPC as the ApsaraDB for MongoDB instance. For details, see Create an instance by using a custom image.
Add the private IP address of the new ECS instance to the whitelist of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance. To get the private IP address of your ECS instance, see View instance information.
Method 2: Use Server Migration Center
Use Server Migration Center (SMC) to migrate the ECS instance to the MongoDB region.
Migrate the ECS instance to the region where the ApsaraDB for MongoDB instance is located. For details, see Migrate servers between ECS instances.
Add the private IP address of the ECS instance to the whitelist of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.