You can change the virtual private cloud (VPC) or vSwitch in which an ApsaraDB for Redis instance is deployed. For example, you can change the VPC of an ApsaraDB for Redis instance to the VPC to which an Elastic Compute Service (ECS) instance belongs. This way, the ApsaraDB for Redis instance can communicate with the ECS instance over the internal network.

Prerequisites

  • The ApsaraDB for Redis instance runs in a VPC.
    Note You can view the network type on the Instance Information page. If the network type of the ApsaraDB for Redis instance is classic network, you can change classic network to VPC. For more information, see Change the network type from classic network to VPC.
  • The password-free access for VPCs feature of the ApsaraDB for Redis instance is disabled. Data Transmission Service (DTS) is not running a data migration or data synchronization task for the ApsaraDB for Redis instance. Otherwise, an error is prompted.

Scenarios

Operation Scenario
Change the VPC of an ApsaraDB for Redis instance Clients are unable to communicate with the ApsaraDB for Redis instance because the clients and the ApsaraDB for Redis instance belong to different VPCs.

For example, the ECS instance where your workloads are running is deployed in VPC A and the ApsaraDB for Redis instance is deployed in VPC B. To connect the ApsaraDB for Redis instance to the ECS instance, you can change the VPC of the ApsaraDB for Redis instance to VPC A.

Change the vSwitch of an instance To centrally manage cloud resources and IP address whitelists, you can group the cloud resources and then allocate IP addresses.

For example, you can attach cloud resources that are related to database services, such as ECS and Redis instances, to the same vSwitch. Then, these cloud resources are automatically assigned IP addresses that belong to the same CIDR block.

Impacts

  • When the system changes the network type, the instance is disconnected for 30 seconds. Make sure that you change the network during off-peak hours and your application can automatically reconnect to the instance.
  • If you change the VPC or vSwitch of an instance, the virtual IP address (VIP) of the instance is changed. Therefore, if applications connect to the VIP of the instance, the connections are closed after the VIP is changed.
    Note When you change the VPC or vSwitch of an ApsaraDB for Redis instance, the endpoint of the instance remains unchanged, for example, r-hp3bpn39cs1vu****.redis.hangzhou.rds.aliyuncs.com. We recommend that you connect your applications to this endpoint.
  • When the system changes the VIP, your Data Management (DMS) service is interrupted for a short period of time. After the VIP is changed, the connections are automatically resumed.
  • After you change the network, clear the client cache. Otherwise, only read operations can be processed and write operations cannot be processed.

Procedure

  1. Log on to the ApsaraDB for Redis console.
  2. On the top of the page, select the region where the instance is deployed.
  3. On the Instance List page, click the Instance ID of the instance.
  4. Click Instance Information next to Try New Version.
    Figure 1. The Try New Version page
    The Try New Version page
    Note If the product page is already the latest, skip this step.
  5. In the Basic Information section, click the Edit icon icon next to the VPC ID.
    Note If you want to modify only the vSwitch, you can click the Edit icon icon next to the vSwitch ID.
  6. In the panel that appears, select the VPC and the vSwitch that you want to change.
    Note If no VPC or vSwitch is available in the drop-down list, create a VPC and a vSwitch. The vSwitch and the ApsaraDB for Redis instance must belong to the same zone. For more information, see Work with VPCs and Create a vSwitch.
  7. Click OK.
    Warning When the system changes the network type, the instance is disconnected for 30 seconds. Make sure that you change the network during off-peak hours and your application can automatically reconnect to the instance.
  8. In the message that appears, read the content and click OK.

Related API operations

API operation Description
SwitchNetwork Changes the VPC of an ApsaraDB for Redis instance. If the instance is deployed in a classic network, the network type of the instance changes from classic network to VPC.