If an Elastic Compute Service (ECS) instance and an ApsaraDB for MongoDB instance do not belong to the same Alibaba Cloud account, you can use the methods in this topic to connect the ECS instance to the ApsaraDB for MongoDB instance over an internal network.
Method 1: Migrate the ApsaraDB for MongoDB instance to the Alibaba Cloud account to which the ECS instance belongs
This method uses the data migration feature of Data Transmission Service (DTS) to migrate the ApsaraDB for MongoDB database to the Alibaba Cloud account to which the ECS instance belongs. For more information about DTS, see What is DTS?
Procedure
Create an ApsaraDB for MongoDB instance within the Alibaba Cloud account to which the ECS instance belongs. The ApsaraDB for MongoDB instance must reside in the same region, zone, and virtual private cloud (VPC) as the ECS instance. For more information, see Create an instance.
NoteWhen you create an ApsaraDB for MongoDB instance, select the same VPC as the ECS instance.
If you have created such an ApsaraDB for MongoDB instance, skip this step.
Migrate the ApsaraDB for MongoDB instance from the Alibaba Cloud account to which the instance belongs to the Alibaba Cloud account to which the ECS instance belongs. For more information, see Migrate data between ApsaraDB for MongoDB instances of different Alibaba Cloud accounts.
Add the IP address of the ECS instance to all IP address whitelists of the ApsaraDB for MongoDB instance. For more information, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.
NoteFor more information about how to obtain the IP address of an 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 migrates the ECS instance to the Alibaba Cloud account to which the ApsaraDB for MongoDB instance belongs by sharing the ECS instance as a custom image.
Prerequisites
An ECS instance within Alibaba Cloud account A and an ApsaraDB for MongoDB instance within Alibaba Cloud account B reside in the same region.
If the ECS instance and the ApsaraDB for MongoDB instance do not reside in the same region, you can copy the custom image to the destination region and share the custom image, or share the custom image and copy the custom image across regions. For more information, see Copy a custom image.
Procedure
Create a custom image from an ECS instance. For more information, see Create a custom image from an instance.
Share the created custom image to the Alibaba Cloud account to which the ApsaraDB for MongoDB instance belongs (Alibaba Cloud account B). For more information, see Procedure.
Create an ECS instance from the created custom image. For more information, see Create an ECS instance from a custom image.
NoteWhen you create the ECS instance, select the same VPC as the ApsaraDB for MongoDB instance.
Add the IP address of the ECS instance to all IP address whitelists of the ApsaraDB for MongoDB instance. For more information, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.
NoteFor more information about how to obtain the IP address of an 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 Cloud Enterprise Network (CEN) to establish a connection between VPCs that belong to different Alibaba Cloud accounts to connect the ECS instance to the ApsaraDB for MongoDB instance. For more information about CEN, see What is CEN?
Make sure that the CIDR blocks of the involved VPCs or vSwitches do not conflict with each other.
Procedure
Switch the network type of the ApsaraDB for MongoDB instance to VPC. For more information, see Switch the network type of an ApsaraDB for MongoDB instance from classic network to VPC. If the network type of the instance is VPC, skip this step.
Switch the network type of the ECS instance to VPC. For more information, see Migrate ECS instances from a classic network to a VPC. If the network type of the instance is VPC, skip this step.
Select one of the following CEN-based connections over an internal network based on the running environment. For more information, see the following topics:
Add the IP address of the ECS instance to all IP address whitelists of the ApsaraDB for MongoDB instance. For more information, see Modify an IP address whitelist of an ApsaraDB for MongoDB instance.
NoteFor more information about how to obtain the IP address of an ECS instance, see View instance information.