edit-icon download-icon

Hybrid access of ApsaraDB for RDS

Last Updated: Apr 28, 2018

Follow the instructions in the document to migrate the network of an RDS instance from the classic network to the Virtual Private Cloud (VPC), while retaining the connection endpoint of the classic network. For more information about the hybrid access of RDS, see Hybrid access solution for the seamless migration from classic network to VPC.

Note: During the migration, you can specify the reservation time of the classic network endpoint. Once the reservation time is expired, the classic network endpoint is released automatically. You can receive notifications before releasing.

Prerequisites

  • The current access mode is safe connection mode. For more information on how to switch the access mode, see Set access mode. MySQL 5.7, SQL Server 2012 and SQL Server 2016 only support standard mode, but these instances also support hybrid access in this condition.

  • The current network type is classic network.

  • There are available VPC and VSwitch in the zone where the RDS instance is located. If not, see Create VPC and Create VSwitch to create one.

Migrate to VPC using the RDS console

  1. Log on to the RDS Console.

  2. Select the region where the target instance is located.

  3. Click the ID of the target instance to enter the Basic Information page.

  4. In the left-side navigation pane, select Connection Options to enter the Connection Options page.

  5. On the Instance Connection tab, click Switch to VPC.

  6. In the Switch to VPC dialog box, select the VPC and VSwitch that the RDS instance is migrated to.

  7. Check Reserve original classic endpoint, and select the Expiration time for the basic intranet address of the original network, as shown in the following figure.

    Note:

    • Starting from the seventh day before the date on which the intranet address of the original classic network is set to be released, the system will send a text message of a notice to the mobile number listed on your account every day.

    • When the reservation ages out, the intranet address of the classic network will be released automatically and can no longer be used to access the database. To prevent service interruption, set the reservation period as necessary. After the hybrid access configuration is complete, you can change the expiration date.

  8. Click OK, and the Original classic endpoint area appears on the console, as shown in the following figure.

    Console of hybrid access period

Change the expiration time of the original classic endpoint using RDS console

During the hybrid access period, you can change the reservation period of the intranet address of the original classic network at any time as needed, and the expiration date will be recalculated from the new date. For example, if the intranet address of the original classic network is set to expire on August 18, 2017, and you change the expiration time to “14 days later” on August 15, 2017, the address will be released on August 29, 2017.

Follow these steps to change the expiration time:

  1. Log on to the RDS Console.

  2. Select the region where the target instance is located.

  3. Click the target instance ID to enter the Basic Information page.

  4. In the left-side navigation pane, select Connection Options to enter the Connection Options page.

  5. On the Instance Connection tab, click Change Expiration time, as shown in the following figure.

    Change the expiration time

  6. On the Change Expiration Time confirmation page, select an expiration time and click OK.

Migrate to VPC using API

  1. Download the SDK.

  2. Call the ModifyDBInstanceNetworkType API to migrate to VPC.

    Request parameters

    Request parameterData typeRequired or notDescription
    ActionStringYes

    System parameter.

    Valid value: ModifyDBInstanceNetworkType.

    DBInstanceIdStringYesID of the target RDS instance.
    InstanceNetworkTypeStringYes

    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.

    PrivateIpAddressStringNo

    Specify a priviate IP address within the specified VSwitch.

    If no value is provided, a random private IP is allocated according to the specified VPC and VSwitch.

    RetainClassicStringNo

    Choose whether to reserve the classic network endpoint for the RDS 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.

    Return parameters

    Return parameterData typeDescription
    RequestIdStringThe unique ID of the request.
    TaskIdStringID of the task.

    Example

    1. import com.aliyuncs.DefaultAcsClient;
    2. import com.aliyuncs.IAcsClient;
    3. import com.aliyuncs.exceptions.ClientException;
    4. import com.aliyuncs.exceptions.ServerException;
    5. import com.aliyuncs.profile.DefaultProfile;
    6. import com.aliyuncs.profile.IClientProfile;
    7. import com.aliyuncs.rds.model.v20140815.ModifyDBInstanceNetworkTypeRequest;
    8. import com.aliyuncs.rds.model.v20140815.ModifyDBInstanceNetworkTypeResponse;
    9. import org.junit.Test;
    10. public class ModifyDBInstanceNetworkTypeTest {
    11. @Test
    12. public void switchNetwork_success() {
    13. ModifyDBInstanceNetworkTypeRequest request=new ModifyDBInstanceNetworkTypeRequest ();
    14. request.setInstanceId;
    15. request.setInstanceNetworkType
    16. request. setVPCId;
    17. request.setVSwitchId
    18. request.setRetainClassic;
    19. request.setClassicExpiredDays;
    20. IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou";
    21. IAcsClient client = new DefaultAcsClient(profile);
    22. try {
    23. ModifyDBInstanceNetworkTypeResponse response
    24. = client.getAcsResponse(request);
    25. System.out.println(response.getRequestId());
    26. }catch (ServerException e) {
    27. e.printStackTrace();
    28. }
    29. catch (ClientException e) {
    30. e.printStackTrace();
    31. }
    32. }
    33. }
  3. Call the DescribeDBInstanceNetInfo API to obtain the classic network endpoint.

    Request parameters

    Request parametersData typeRequired or notDescription
    ActionStringYes

    System parameter.

    Valid value: DescribeDBInstanceNetInfo.

    DBInstanceIdStringYesID of the target RDS instance.

    Return parameters

    Return parameterData typeDescription
    DBInstanceNetInfosListThe connection information of the RDS instance.
    InstanceNetworkTypeString

    The network type of the RDS instance.

    VPC: Virtual Private Cloud

    Classic: classic network

    Data structure of the DBInstanceNetInfo parameter

    ParameterData typeDescription
    ConnectionStringStringDNS connection endpoint.
    IPAddressStringIP address.
    IPTypeString

    The type of the IP.

    For the classic network, the valid values are Inner and Public.

    For the VPC, the valid values are Private and Public.

    PortStringPort number.
    VPCIdStringVPC ID.
    VSwitchIdStringVSwitch ID.
    ExpiredTimeStringExpiration date.

    Error code

    Error codeStatus codeDescription
    Forbidden.InstanceNotFound404The specified instance is not found.

    Example

    1. import com.aliyuncs.DefaultAcsClient;
    2. import com.aliyuncs.IAcsClient;
    3. import com.aliyuncs.exceptions.ClientException;
    4. import com.aliyuncs.exceptions.ServerException;
    5. import com.aliyuncs.profile.DefaultProfile;
    6. import com.aliyuncs.profile.IClientProfile;
    7. import com.aliyuncs.rds.model.v20140815.DescribeDBInstanceNetInfoRequest;
    8. import import com.aliyuncs.rds.model.v20140815.DescribeDBInstanceNetInfoResponse;
    9. import org.junit.Test;
    10. /**
    11. *
    12. */
    13. public class DescribeDBInstanceNetInfoTest {
    14. @Test
    15. public void describeDBInstanceNetInfo_success() {
    16. DescribeDBInstanceNetInfoRequest request=new DescribeDBInstanceNetInfoRequest();
    17. request.setInstanceId;
    18. IClientProfile profile = DefaultProfile.getProfile("cn-hangzhou");
    19. IAcsClient client = new DefaultAcsClient(profile);
    20. try {
    21. DescribeDBInstanceNetInfoResponse response
    22. = client.getAcsResponse(request);
    23. System.out.println(response.getRequestId());
    24. }catch (ServerException e) {
    25. e.printStackTrace();
    26. }
    27. catch (ClientException e) {
    28. e.printStackTrace();
    29. }
    30. }
    31. }

Change the expiration time of the original classic endpoint using API

  1. Download the SDK.

  2. Call the ModifyDBInstanceNetworkExpireTime API to change the expiration time of the classic network endpoint.

    Request parameters

    Request parameterData typeRequired or notDescription
    ActionStringYes

    System parameter. Valid value: ModifyDBInstanceNetworkExpireTime.

    DBInstanceIdStringYesID of the target RDS instance.
    ConnectionStringStringYesThe connection string of the classic network to be extended. There are two types of classic network string: the classic network string of the current instance and the classic network string of the read/write splitting.
    ClassicExpiredDaysIntegerYesThe retention days of the classic network string: [1-120].

    Return parameters

    Return parametersData typeDescription
    Public return parametersNoneFor more information, see Public parameters.

    Example

    1. public static void main(String[] args) {
    2. ModifyDBInstanceNetExpireTimeRequest request = new ModifyDBInstanceNetExpireTimeRequest();
    3. request.setClassicExpiredDays(3);
    4. request.setConnectionString("<connection string>");
    5. request.setDBInstanceId("<ID of the instance>");
    6. IClientProfile profile
    7. = DefaultProfile.getProfile("cn-qingdao", "<Your AccessKey>",
    8. "<Your AccessKey>");
    9. IAcsClient client = new DefaultAcsClient(profile);
    10. try {
    11. ModifyDBInstanceNetExpireTimeResponse response
    12. = client.getAcsResponse(request);
    13. System.out.println(response.getRequestId());
    14. }catch (ServerException e) {
    15. e.printStackTrace();
    16. }
    17. catch (ClientException e) {
    18. e.printStackTrace();
    19. }
    20. }
Thank you! We've received your feedback.