If an 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 quickly connect the ECS instance to the ApsaraDB for MongoDB instance over the internal network.

Method 1: Migrate the ApsaraDB for MongoDB instance to the Alibaba Cloud account to which the ECS instance belongs

This method uses a 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.

Procedure

  1. Create an ApsaraDB for MongoDB instance for the Alibaba Cloud account to which the ECS instance belongs. For more information, see Create an instance. Skip this step if you have already created an ApsaraDB for MongoDB instance.
    Note When creating the ApsaraDB for MongoDB instance, select the same region, zone, and VPC as the ECS instance.
  2. Migrate the MongoDB database from the instance that belongs to the source Alibaba Cloud account to the instance that belongs to destination Alibaba Cloud account. For more information, see Use DTS to migrate MongoDB databases between different Alibaba Cloud accounts.
  3. Add the private IP address of the ECS instance to the whitelist of the ApsaraDB for MongoDB instance. For more information, see Configure a whitelist.
    Note For more information about how to obtain the IP address of an ECS instance, see How to query the IP address of an ECS instance.

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

The ECS instance and ApsaraDB for MongoDB instance must be in the same region because images cannot be shared across different regions.

Procedure

  1. Create a custom image from the ECS instance.
  2. Share the custom image to the Alibaba Cloud account to which the ApsaraDB for MongoDB instance belongs. For more information, see Share images.
  3. Create an ECS instance from the custom image.
    Note When creating the ECS instance, select the same VPC as the ApsaraDB for MongoDB instance.
  4. Add the private IP address of the ECS instance to the whitelist of the ApsaraDB for MongoDB instance. For more information, see Configure a whitelist.
    Note For more information about how to obtain the IP address of an ECS instance, see How to query the IP address of an ECS instance.

Method 3: Establish a connection between the ECS instance and ApsaraDB for MongoDB instance through Cloud Enterprise Network

This method uses Cloud Enterprise Network (CEN) to establish a connection between the VPCs that belong to different Alibaba Cloud accounts to connect the ECS instance to the ApsaraDB for MongoDB instance.
Note Ensure that the CIDR blocks of the VPCs or VSwitches involved do not conflict with each other.

Procedure

  1. Switch the network type of the ApsaraDB for MongoDB instance to VPC. For more information, see Switch from a classic network to a VPC. If the network type is VPC, skip this step.
  2. Switch the network type of the ECS instance to VPC. If the network type is VPC, skip this step.
  3. Based on the running environment, select one of the following CEN-based connections over the internal network. For more information, see
  4. Add the private IP address of the ECS instance to the whitelist of the ApsaraDB for MongoDB instance. For more information, see Configure a whitelist.
    Note For more information about how to obtain the IP address of an ECS instance, see How to query the IP address of an ECS instance.