All Products
Search
Document Center

Elastic Compute Service:Use a custom image to replicate ECS instances across regions

Last Updated:Aug 20, 2024

To deploy or back up business across different regions, you can use a custom image to replicate Elastic Compute Service (ECS) instances from a source region to a destination region. The new ECS instances (replica ECS instances) have the same environment configurations as the source ECS instances (replicated ECS instances). This way, you can quickly replicate business environments across regions. This topic describes how to use a custom image to replicate an ECS instance across regions.

Usage notes

Before you replicate an ECS instance across regions, take note of the following items:

  • When you create a custom image from the source ECS instance, a snapshot is automatically created for each disk that is attached to the instance. You are charged for the snapshots. For information about the billing of snapshots, see Snapshots.

    Note

    Snapshots cannot be created for local disks. ECS instances to which local disks are attached do not support the operations that are described in this topic.

  • The source ECS instance can reside in the classic network or a virtual private cloud (VPC), but the new ECS instance must reside in a VPC.

  • After you use a custom image to replicate an ECS instance across regions, the disk data on the new ECS instance is the same as the disk data on the source ECS instance. However, new instance metadata, including an instance ID, a public IP address, and a private IP address, is generated for the new ECS instance, which is different from the instance metadata of the source ECS instance. Before you replicate an ECS instance, we recommend that you identify resource associations. This way, you can update the resource associations at the earliest opportunity after the replication is complete. For information about instance metadata, see Obtain instance metadata.

Step 1: Create a custom image from the source ECS instance

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Instances.

  3. In the upper-left corner of the top navigation bar, select a region. In this example, select China (Hangzhou).

  4. Find the source ECS instance and choose image.png > Disk and Image > Create Custom Image in the Actions column.

  5. In the Create Custom Image dialog box, configure parameters and click OK.

    • Specify the Custom Image Name parameter. In this example, set the Custom Image Name parameter to Created_from_hangzhouECS1.

    • Configure the other parameters. For information about how to configure the other parameters, see Create a custom image from an instance.

  6. In the left-side navigation pane, choose Instances & Images > Images.

  7. On the Custom Images tab, find the Created_from_hangzhouECS1 custom image that you created in the previous step and check its status.

    When the custom image is in the Available state, you can proceed to the next step.

Step 2: Copy the custom image to a different region

Before you replicate an ECS instance to create a new ECS instance in a different region, you must use the image copy feature to copy the custom image that you created in the previous step to the destination region.

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

  2. In the upper-left corner of the top navigation bar, select a region. In this example, select China (Hangzhou).

  3. On the Custom Images tab, find the Created_from_hangzhouECS1 image and click Copy Image in the Actions column.

  4. In the Copy Image dialog box, configure the parameters and click OK.

    • Enter a name for the image copy. Example: Copy_from_hangzhouImage1.

    • Select a destination region. Example: China (Beijing).

    • Configure the other parameters. For information about how to configure the other parameters, see Copy a custom image.

  5. In the upper-left corner of the top navigation bar, switch to the China (Beijing) region to check the progress and status of the Copy_from_hangzhouImage1 image.

    After the custom image is copied to the destination region, you must perform the subsequent steps in the region.

Step 3: Create a new ECS instance from the custom image

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

  2. In the upper-left corner of the top navigation bar, select a region. In this example, select China (Beijing).

  3. On the Custom Images tab, find the custom image copy Copy_from_hangzhouImage1.

  4. In the Actions column, click Create Instance.

  5. On the ECS instance buy page, configure the parameters to create an ECS instance.

    • The parameters in the Image and Region parameters are automatically specified and do not need to be modified.

    • Select an instance type based on your business requirements.

    • Configure the other parameters. For information about how to configure the other parameters, see Create an instance on the Custom Launch tab.

Step 4: Check the data in the new ECS instance

Check the data in the new ECS instance to ensure that business runs as expected on the instance after the replication is complete. Examples:

  • Check the disk data.

    Check whether the data stored on the system disk of the new ECS instance is the same as the data stored on the system disk of the source ECS instance. For example, check whether the files and directory structures on the system disks are the same. If data disks are attached to the source ECS instance and the new ECS instance, check whether the data stored on the data disks of the new ECS instance is the same as the data stored on the data disks of the source ECS instance.

  • Run applications or services.

    If specific applications or services run on the source ECS instance, run the applications or services on the new ECS instance and check whether the applications or services provide the same functionality and support the same data operations as the applications or services on the source ECS instance.

  • Compare resource information.

    Compare resource information, such as image information and network configurations, to identify changes between the source ECS instance and the new ECS instance. For more information, see View instance information.

  • Update resource associations.

    New instance metadata is generated for the new ECS instance, which is different from the instance metadata of the source ECS instance. In this case, you must update resource associations at the earliest opportunity after the replication is complete. Examples:

    • If an application depends on a specific private IP address for internal communication, you must update the network configurations of the new ECS instance after the replication is complete. For example, change the private IP address of the new ECS instance to a private IP address in the subnet to which the private IP address of the source ECS instance belongs and check the network connectivity of the new ECS instance. For information about how to change the private IP address of an ECS instance, see Modify the private IP address of an instance.

    • If an application depends on Domain Name System (DNS) services to work, you must update the DNS settings of the new ECS instance after the replication is complete to ensure that the application can continue to provide external services on the new ECS instance. For more information, see How do I customize the DNS settings of a Linux instance?

(Optional) Step 5: Release or delete the source ECS instance and the resources of the instance

Warning

The instance release, snapshot deletion, and image deletion operations are irreversible. When an ECS instance is released or a snapshot or an image is deleted, data in the instance, snapshot, or image is deleted and cannot be recovered. Make sure that you release or delete resources only after all business data is migrated.

Perform the following operations before you release or delete the source ECS instance and the resources of the instance to prevent unnecessary charges: Verify that data on the new ECS instance is the same as data on the source ECS instance, update resource associations for the new ECS instance, and make sure that business runs as expected on the new ECS instance.

  • Release the source ECS instance. For more information, see Release an instance.

  • Delete the snapshots of the disks that are attached to the source ECS instance. For more information, see Delete a snapshot.

  • Delete the custom image that you created from the source ECS instance. For more information, see Delete a custom image.

References

You can use Server Migration Center (SMC) to migrate ECS instance data across Alibaba Cloud accounts. For more information, see Migrate data between ECS instances that belong to the same Alibaba Cloud account or different Alibaba Cloud accounts.