edit-icon download-icon

Hybrid access of ApsaraDB for Mongo

Last Updated: Aug 28, 2017

Follow the instructions in the document to migrate the network of a MongoDB instance from the classic network to the Virtual Private Cloud (VPC) using API, while retaining the connection endpoint of the classic network.

During the migration, you can specify the reservation time of the classic network endpoint. Once the reservation time is expired, the classic network endpoint will be released automatically. You will receive a notification before releasing.

Note: Currently, the migration on the console cannot reserve the classic network endpoint.

Before you begin

Before migrating to VPC, check the following:

  • Verify whether the current network type is classic network.

  • Verify the database type. Only the MongoDB replica set is supported.

  • Verify whether there are available VPC and VSwitch under the zone of the MongoDB instance. If not, see Create VPC and Create VSwitch to create one.

Procedure

  1. Download the SDK.

  2. Call the ModifyDBInstanceNetworkType API to migrate to VPC.

    Request parameters

    Request parametersData typeDescriptionDescription
    ActionStringYes

    System parameter.

    Valid value: ModifyDBInstanceNetworkType

    DBInstanceIdStringYesID of the target MongoDB instance.
    NetworkTypeStringYes

    Specify the network type, enter VPC in this tutorial. Valid values are:

    VPC: Virtual Private Cloud

    Classic: classic network

    VPCIdStringNo

    ID of the VPC.

    Required if the specified network type is VPC.

    VSwitchIdStringNo

    ID of the VSwitch to which is migrated.

    Required if the specified network type is VPC.

    RetainClassicStringNo

    Choose whether to reserve the classic network endpoint for the MongoDB instance. The default value is False. Set to True to reserve the classic network endpoint.

    ClassicExpiredDaysStringNo

    A period of time that the classic network endpoint is reserved.

    Valid values: 1 to 180 days.

    Required if choosing to reserve the classic network endpoint.

    Response parameters

    Response parametersData typeDescription
    RequestIdStringThe unique ID of the request.
    TaskIdStringID of the task.
  3. Call the DescribeReplicaSetRole API to obtain the classic network endpoint.

    Request parameters

    Request parametersData typeRequired or notDescription
    ActionStringYes

    System parameter.

    Valid value: DescribeReplicaSetRole

    DBInstanceIdStringYesID of the target MongoDB instance.

    Response parameters

    Response parametersData typeDescription
    DBInstanceIdStringID of the MongoDB instance.
    ReplicaSetsListList of the replica set.

    Data structure of ReplicaSetRole

    ParametersData typeDescription
    ReplicaSetRoleStringRole of the replica set: Primary or Secondary.
    ConnectionDomainStringConnection endpoint.
    ConnectionPortStringPort number.
    ExpiredTimeStringThe remaining time of the classic network endpoint in seconds.
    NetworkTypeString

    The network type of the MongoDB instance.

    VPC: Virtual Private Cloud

    Classic: classic network

Thank you! We've received your feedback.