All Products
Search
Document Center

Elastic Compute Service:Best practices for migrating all instances from the classic network to a VPC

Last Updated:Nov 24, 2023

This topic describes how to migrate all Elastic Compute Service (ECS) and ApsaraDB RDS instances from the classic network to a virtual private cloud (VPC). After the instances are migrated, their business environments quickly become available.

Background information

Assume that you have created two ECS instances (ECS_A and ECS_B) and one RDS instance in the classic network. The ECS instances function as application servers, and the RDS instance functions as a database server. These instances can communicate with each other over the internal network. You want to migrate the ECS and RDS instances to a VPC and retain the internal IP addresses for the instances to ensure business stability.

Preparations

Before you migrate the instances, we recommend that you perform the following operations:

  • Create snapshots for all disks on the ECS instances to back up data. For more information, see Create a snapshot for a disk.

  • ECS instances are restarted when they are migrated. We recommend that you configure application services deployed on the instances to automatically run on system startup and monitor the availability of the services.

For more information, see Preparations in Migrate ECS instances from the classic network to a VPC.

Step 1: Migrate the ECS instances

Create a migration plan to migrate the application servers (ECS_A and ECS_B) to a VPC.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Maintenance & Monitoring > icon1 > Migration Plan.

  3. In the upper-left corner of the top navigation bar, select a region. 地域

  4. Click Create Migration Plan.

  5. In the Configure Migration Plan step, configure parameters and click Next.

    1. Configure parameters in the Destination Zone and VPC section.

      Parameter

      Description

      Plan Name

      Enter a name for the migration plan. Example: ECS_c2v_demo.

      Select a destination zone

      Select a destination zone from the drop-down list. Example: Shenzhen Zone B.

      Note
      • Available zones are automatically planned based on resources. You can only select a zone from the drop-down list.

      • Only a single zone can be specified for each migration plan. If you want to specify multiple zones, you must create multiple migration plans.

      Destination VPC or Create a VPC

      Select (Default) Automatically create a VPC, CIDR block: 10.0.0.0/8 from the drop-down list. Then, the system creates a VPC with the 10.0.0.0/8 CIDR block.

    2. Configure parameters in the Instance Network Properties section.

      网络属性

      Parameter

      Description

      Destination Security Group

      (Default) Clone Security Groups of Classic Network-type Instances is automatically selected. This value indicates that the system clones the security groups of specified ECS instances from the classic network to the destination VPC.

      Note

      If rules of a security group reference security groups as sources or destinations for traffic, the security group cannot be cloned.

      Mac Address Retention Policy

      Select the MAC address that you want to retain. Valid values: (Default) Private Mac Address and Public Mac Address.

      If the business environments on the instances are not associated with MAC addresses, select (Default) Private Mac Address.

    3. Configure parameters in the Instance Network Connectivity section and click Next.

      Parameter

      Description

      Retain Internal IP Address

      By default, (Default) Yes is selected, which indicates that the internal IP addresses of ECS instances to be migrated are retained.

      If you set vSwitch Creation Policy to Automatic, a vSwitch is automatically created.

      Ensure interconnections between the migrated instances and the classic network-type instances specified in the plan over the internal network

      All ECS instances will be migrated to the specified VPC based on this migration plan, and no ECS instances will remain in the classic network. Therefore, select (Default) No.

  6. In the Select Instances step, select the ECS_A and ECS_B instances and click Next.

  7. In the Scheduled Migration step, set a unified migration time for the ECS instances and click Verify.

    Note

    The ECS instances are restarted when they are migrated. We recommend that you migrate your ECS instances during off-peak hours.

    1. Select the ECS instances and click Batch Schedule Migration Time.

    2. In the Batch Schedule Migration Time dialog box, set the Migration Time parameter and click OK.

  8. In the Verify dialog box, read the migration consideration, select the options that are displayed, and then click Confirm and Create.

    Note

    If your migration plan does not meet the requirements, the system prompts an error message. You can create a migration plan again based on the error message.

    After the ECS instances are migrated, you can choose Instances & Images > Instances in the left-side navigation pane of the ECS console to view the instances. The network type of the instances changes to VPC, and the internal IP addresses of the instances remain unchanged.

Step 2: Migrate the RDS instance

Change the network type of the database server (RDS instance) to migrate it from the classic network to the VPC to which the ECS instances are migrated. For more information, see Change the network type of an ApsaraDB RDS for MySQL instance.

  1. Obtain the information of the VPC created by the system in Step 1.

    1. In the left-side navigation pane of the ECS console, choose Instances & Images > Instances.

    2. Click the ID of one of the migrated ECS instances.

    3. On the Instance Details tab, record the VPC ID and vSwitch ID. Then, click the vSwitch ID to obtain the information of the zone in which the vSwitch resides.

      Item

      Example

      VPC ID

      vpc-wz9avqy2c3fw8w4******

      vSwitch ID

      vsw-wz98loggfq88msu******

      Zone

      Shenzhen Zone B

  2. Obtain the network information of the RDS instance in the classic network.

    1. Log on to the ApsaraDB RDS console.

    2. In the left-side navigation pane, click Instances.

    3. In the upper-left corner of the top navigation bar, select the region where the RDS instance resides.

    4. Click the ID of the RDS instance.

    5. View the region and zone of the RDS instance.

      • If the zone of the RDS instance is the same as that of the vSwitch obtained in the previous step, proceed to the next step.

      • If the zone of the RDS instance is different from that of the vSwitch obtained in the previous step, create a vSwitch in the zone of the RDS instance and then proceed to the next step. For information about how to create a vSwitch, see Create and manage a vSwitch.

      Note

      In this example, the vSwitch and the RDS instance both reside in Shenzhen Zone B. You do not need to create a vSwitch.

  3. In the left-side navigation pane of the page that appears, click Database Connection.

  4. Click Switch to VPC.

  5. In the dialog box that appears, select the VPC and vSwitch that you obtained and enable the Reserve Original Classic Network Endpoint feature. Then, click OK.

    Item

    Description

    VPC

    Select the VPC ID that you obtained in Step 1. Example: vpc-wz9avqy2c3fw8w4******.

    vSwitch

    Select the vSwitch ID that you obtained in Step 1. Example: vsw-wz98loggfq88msu******.

    Note

    If you have created a vSwitch because the RDS instance does not reside in the same zone as the vSwitch that you obtained, select the ID of the vSwitch that you created.

    Reserve original classic endpoint

    Clear the option. The classic network endpoint is not retained and changes to a VPC endpoint.

    Note

    When you change the network type from classic network to VPC, a transient connection that lasts approximately 30 seconds occurs and ECS instances that reside in the classic network are immediately disconnected from the RDS instance.

  6. Check whether the RDS instance is migrated to the VPC.

    After the RDS instance is migrated, you can click Database Connection in the left-side navigation pane. On the Database Connection page of the RDS instance, the network type changes to VPC and the internal endpoint also changes.

Step 3: Check the migration result

After the ECS and RDS instances are migrated, access your business system to check whether the system runs normally.

  1. Use a browser to access web applications.

  2. Check whether web applications can be accessed.

    If your business system runs normally, the ECS and RDS instances are migrated to the VPC.