You can change the virtual private cloud (VPC) or vSwitch of an ApsaraDB for Redis instance. 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 is deployed in a VPC.
    Note You can view the network type of an ApsaraDB for Redis instance on the Instance Information page. If the network type is classic network, you can change the network type from classic network to VPC. For more information, see Change the network type from classic network to VPC.
  • The ApsaraDB for Redis instance does not have a direct connection endpoint. If a direct connection endpoint is enabled for the instance, you can release the direct connection endpoint first and enable it again after the VPC is changed.
  • The password-free access feature is disabled for the ApsaraDB for Redis instance. No Data Transmission Service (DTS) data migration tasks or data synchronization tasks are running for the ApsaraDB for Redis instance. Otherwise, an error is reported.

Scenarios

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

For example, the ECS instance on which 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 ApsaraDB for Redis 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 add cloud resources that are related to database services, such as ECS instances and ApsaraDB for Redis instances, to the same vSwitch. Then, these cloud resources are automatically assigned IP addresses that belong to the same CIDR block.

Impacts

  • If you change the VPC or vSwitch of an instance, the instance experiences transient connections for 30 seconds. Make sure that you change the VPC or vSwitch 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 you connect your applications to the VIP of the instance, the connections are closed after the VIP is changed.
    Note After you change the VPC or vSwitch of an ApsaraDB for Redis instance, the endpoint of the instance, such as r-hp3bpn39cs1vu****.redis.hangzhou.rds.aliyuncs.com, remains unchanged. We recommend that you connect your applications to instances by using endpoints.
  • A VIP change interrupts the Data Management (DMS) service for a short period of time. After the VIP is changed, the connections are automatically resumed.
  • After you change the VPC or vSwitch of an instance, clear the cache on clients. Otherwise, clients may fail to write data to the instance and can only read data from the instance.

Procedure

  1. Log on to the ApsaraDB for Redis console.
  2. In the top navigation bar of the page, select the region where the instance is deployed.
  3. On the Instances page, click the ID of the instance.
  4. In the Basic Information section, click the Edit icon icon next to the VPC ID.
    Figure 1. Change the VPC of an ApsaraDB for Redis instance
    Change the VPC of an ApsaraDB for Redis instance
    Note If you want to change only the vSwitch, you can click the Edit icon icon next to the vSwitch ID.
  5. In the panel that appears, select the VPC and the vSwitch that you want to use.
    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 Create a VPC and Create a vSwitch.
  6. Click OK.
    Warning If you change the VPC or vSwitch of an instance, the instance experiences transient connections for 30 seconds. Make sure that you change the VPC or vSwitch during off-peak hours and your application can automatically reconnect to the instance.
  7. In the message that appears, read the content and click OK.

Related operations

Operation Description
SwitchNetwork Changes the VPC or vSwitch of an ApsaraDB for Redis instance. If the instance is deployed in the classic network, the network type of the instance changes from classic network to VPC.