If an Elastic Compute Service (ECS) instance and an ApsaraDB for MongoDB instance are located in different regions, you can use the methods described in this topic to quickly connect the ECS instance to the ApsaraDB for MongoDB instance.

Method 1: Migrate the ApsaraDB for MongoDB instance to the region where the ECS instance is located

This method uses the data migration feature of Data Transmission Service (DTS) to migrate the ApsaraDB for MongoDB instance to the region where the ECS instance is located. For example, you can migrate an ApsaraDB for MongoDB instance from the China (Qingdao) region to the China (Hangzhou) region. For more information about DTS, see What is DTS?

  1. Create an ApsaraDB for MongoDB instance in the region where the ECS instance is located. For more information, see Create a replica set instance. If you have already created an ApsaraDB for MongoDB instance, skip this step.
  2. Migrate data from the ApsaraDB for MongoDB instance in the source region to the instance in the destination region. For more information, see Migrate data between ApsaraDB for MongoDB instances across regions.
  3. Add the private IP address of the ECS instance to a whitelist of the ApsaraDB for MongoDB instance. For more information, see Configure a whitelist for an ApsaraDB for MongoDB instance.
    Note For information about how to obtain the IP address of an ECS instance, see View instance information.

Method 2: Migrate the ECS instance to the region where the ApsaraDB for MongoDB instance is located

You can use the custom image feature or the migration tool to migrate the ECS instance data to the region where the ApsaraDB for MongoDB instance is located. For example, you can migrate the ECS instance from the China (Qingdao) region to the China (Hangzhou) region.

  • Create a custom image from the ECS instance and then create an ECS instance in the region where the ApsaraDB for MongoDB instance is located from the custom image. (Recommended)
    1. Create a custom image from the ECS instance. For more information, see Create a custom image from an instance.
    2. Copy the created custom image to the region where the ApsaraDB for MongoDB instance is located. For more information, see Copy an image.
    3. Create an ECS instance from the custom image. For more information, see Create an ECS instance by using a custom image.
      Note When you create the ECS instance, select the same virtual private cloud (VPC) as the ApsaraDB for MongoDB instance.
    4. Add the private IP address of the ECS instance to a whitelist of the ApsaraDB for MongoDB instance. For more information, see Configure a whitelist for an ApsaraDB for MongoDB instance.
      Note For information about how to obtain the IP address of an ECS instance, see View instance information.
  • Use the migration tool to migrate the ECS instance to the region where the ApsaraDB for MongoDB instance is located.
    1. Migrate the ECS instance to the region where the ApsaraDB for MongoDB instance is located. For more information, see Migrate servers between ECS instances.
    2. Add the private IP address of the ECS instance to a whitelist of the ApsaraDB for MongoDB instance. For more information, see Configure a whitelist for an ApsaraDB for MongoDB instance.