ApsaraDB for MongoDB supports the classic network and Virtual Private Cloud (VPC). If you need a more secure network for the current instance that resides in the classic network, you can switch the network type of the instance from classic network to VPC. This topic describes how to switch the network type of an instance from classic network to VPC.

Prerequisites

A replica set or sharded cluster instance that runs MongoDB 4.2 or earlier is used.
Note For a standalone instance, its network type is always VPC and cannot be changed.

Background information

  • Classic network endpoint: Classic network endpoints are used for communication over the classic network. In the classic network, Alibaba Cloud services are not isolated. To block unauthorized traffic, you must configure security groups or IP address whitelists.
  • VPC endpoint: VPC endpoints are used for communication over VPCs. A VPC is an isolated network that provides higher security and higher performance than the classic network. By default, ApsaraDB for MongoDB provides VPC endpoints for instances to ensure high security and high performance.

Precautions

If you switch the network type of an instance, a transient connection occurs for the instance. We recommend that you perform this operation during off-peak hours or make sure that your application is configured to reconnect to the instance after it is disconnected. This protects your business from being affected.

Procedure

  1. Create a VPC in the same region as the ApsaraDB for MongoDB instance. For more information, see Create and manage a VPC.
  2. Log on to the ApsaraDB for MongoDB console.
  3. In the upper-left corner of the page, select the resource group and the region of the target instance.
  4. In the left-side navigation pane, click Replica Set Instances, or Sharded Cluster Instances based on the instance type.
  5. Find the target instance and click its ID.
  6. In the left-side navigation pane, click Database Connections.
  7. In the Internal Connections - Classic Network section, click Switch to VPC.
  8. In the VPC panel, configure the following parameters. Select VPC and VSwitch.
    Parameter Description
    VPC The ID of the VPC created in Step 1.
    VSwitch The ID of the vSwitch created in Step 1.
    Retain the connection address of the classic network Determine whether to turn on Retain the connection address of the classic network based on your business requirements.
  9. Click OK.