If your Elastic Compute Service (ECS) instance and ApsaraDB for MongoDB instance belong to different Alibaba Cloud accounts, use one of the following methods to connect them over the internal network without routing traffic through the public internet.
Choose a method
| Method | How it works | When to use |
|---|---|---|
| Method 1: Migrate MongoDB via DTS | Uses Data Transmission Service (DTS) to move the MongoDB database to the ECS account | You can accept a data migration window and want long-term account consolidation |
| Method 2: Migrate ECS via custom image | Shares the ECS instance as a custom image and recreates it in the MongoDB account | Both instances are in the same region |
| Method 3: Connect VPCs via CEN | Uses Cloud Enterprise Network (CEN) to connect virtual private clouds (VPCs) across accounts without migrating any instance | Both instances use VPC networking and VPC CIDR blocks do not conflict |
Method 1: Migrate the ApsaraDB for MongoDB instance to the Alibaba Cloud account to which the ECS instance belongs
This method uses the DTS data migration feature to move the ApsaraDB for MongoDB database to the ECS account, placing both instances in the same account.
Steps
Create an ApsaraDB for MongoDB instance in the Alibaba Cloud account that owns the ECS instance. The new instance must be in the same region, zone, and VPC as the ECS instance. For details, see Create an instance.
Select the same VPC as the ECS instance when creating the ApsaraDB for MongoDB instance. Skip this step if such an instance already exists.
Migrate the ApsaraDB for MongoDB database to the ECS account using DTS. For details, see Migrate data between ApsaraDB for MongoDB instances of different Alibaba Cloud accounts. For an overview of DTS, see What is DTS?
Add the ECS instance's IP address to all IP address whitelists of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.
To find the IP address of your ECS instance, see View instance information.
Method 2: Migrate the ECS instance to the Alibaba Cloud account to which the ApsaraDB for MongoDB instance belongs
This method recreates the ECS instance in the MongoDB account by sharing it as a custom image, so both instances end up in the same account.
Prerequisites
The ECS instance (Alibaba Cloud account A) and the ApsaraDB for MongoDB instance (Alibaba Cloud account B) must be in the same region.
If they are in different regions, copy the custom image to the target region before sharing it, or share the image first and then copy it cross-region. For details, see Copy a custom image.
Steps
Create a custom image from the ECS instance. For details, see Create a custom image from an instance.
Share the custom image to Alibaba Cloud account B (the account that owns the ApsaraDB for MongoDB instance). For details, see Share a custom image.
In Alibaba Cloud account B, create an ECS instance from the shared custom image. For details, see Create an ECS instance from a custom image.
Select the same VPC as the ApsaraDB for MongoDB instance when creating the ECS instance.
Add the new ECS instance's IP address to all IP address whitelists of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.
To find the IP address of your ECS instance, see View instance information.
Method 3: Establish a connection between the ECS instance and the ApsaraDB for MongoDB instance by using CEN
This method uses CEN to connect the VPCs of both accounts over the internal network, without migrating any instance. For an overview of CEN, see What is CEN?
Prerequisites
Before you begin, confirm that the CIDR blocks of the involved VPCs or vSwitches do not conflict with each other.
Steps
Switch the ApsaraDB for MongoDB instance's network type to VPC. For details, see Switch the network type of an ApsaraDB for MongoDB instance from classic network to VPC. Skip this step if the instance is already on VPC.
Switch the ECS instance's network type to VPC. For details, see Migrate ECS instances from a classic network to a VPC. Skip this step if the instance is already on VPC.
Connect the two VPCs using CEN. Choose the guide that matches your deployment:
Add the ECS instance's IP address to all IP address whitelists of the ApsaraDB for MongoDB instance. For details, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.
To find the IP address of your ECS instance, see View instance information.