The Rolling Update feature allows you to update images and execute scripts on ECS instances with just a few clicks. This way, you can manage ECS instances in a scaling group in a more efficient manner.

Prerequisites

An Alibaba Cloud account is created. To create an Alibaba Cloud account, go to the account registration page.

Procedure

This topic uses a scaling group that meets the following requirements:
  • The scaling group is in China (Hangzhou).
  • The CentOS 6.4 64-bit public image is used in the active scaling configuration of the scaling group.
  • One hundred ECS instances are created based on the active scaling configuration of the scaling group. All instances are in the In Service state.
  • No scaling activities are in progress in the scaling group.
This topic describes how to update the images of ECS instances in the preceding scaling group to Alibaba Cloud Linux 2 images. This topic also describes how to install Apache on the ECS instances after the images are updated. To update images and execute scripts, perform the following steps:

Step 1: Create a custom image

  1. Log on to the ECS console.
  2. In the left-side navigation pane, choose Instances & Images > Instances.
  3. In the top navigation bar, select a region.
  4. Create an ECS instance.
    1. In the upper-left corner of the Instances page, click Create Instance.
    2. Configure the parameters that are required to create an instance.
      The following table shows the sample configurations of the instance. Configure other parameters based on your business requirements. Make sure that the configurations are the same as the active scaling configurations in the scaling group.
      StepParameterExample value
      Basic ConfigurationsBilling MethodPay-As-You-Go
      Region
      • Region: China (Hangzhou)
      • Zone: Random
      Image
      • Type: Public Image
      • Version: Alibaba Cloud Linux 2.1903 LTS 64-bit
      System Configurations (Optional)Instance NameInstance-ForCustomImage
    3. Click Next: Preview.
    4. Read and select ECS Service Terms, and then click Create Order.
    5. Check the fees of the ECS instance and follow the on-screen instructions to complete the payment.
      After the instance is created, go to the Instances page to check the status of the instance. When the instance is in the Running state, the instance is created.
      Note Before you create a custom image, you can configure the ECS instance Instance-ForCustomImage. For example, you can deploy applications and copy data. This helps reduce maintenance operations after the image is updated.
  5. Create a custom image that you want to use to update the images of ECS instances in the scaling group.
    1. Find the Instance-ForCustomImage instance and choose More > Disk and Image > Create Custom Image in the Actions column.
    2. Configure the parameters of the custom image.
      The following table shows the sample configurations of the image. Configure other parameters based on your business requirements.
      ParameterExample value
      Custom Image NameImage-AliyunLinux
      Custom Image DescriptionThe image that is used to update the images of ECS instances in the scaling group.
    3. Click Create.
  6. Create a custom image that you want to use to roll back the images of ECS instances in the scaling group.
    1. Find an ECS instance that belongs to the scaling group and choose More > Disk and Image > Create Custom Image in the Actions column.
    2. Configure the parameters of the custom image.
      The following table shows the sample configurations of the image. Configure other parameters based on your business requirements.
      ParameterExample value
      Custom Image NameImage-CentOSBck
      Custom Image DescriptionThe image that is used to roll back the images of ECS instances in the scaling group when errors occur in the rolling update task.
    3. Click Create.
  7. In the left-side navigation pane, choose Instances & Images > Images to view the creation progress of the Image-AliyunLinux and Image-CentOSBck images on the Images page.
    If the progress is 100%, the image is created.

Step 2: Update images and execute scripts

  1. Log on to the Auto Scaling console.
  2. In the left-side navigation pane, click Scaling Groups.
  3. In the top navigation bar, select the region where Auto Scaling is activated.
  4. Find a scaling group and use one of the following methods to go to the scaling group details page:
    • Click the ID of the scaling group in the Scaling Group Name/ID column.
    • Click Details in the Actions column.
  5. In the upper part of the page, click the Rolling Update tab.
  6. Create and execute an image update task.
    1. Click Create Execution Task.
    2. Configure the parameters of the image update task.
      The following table shows the sample configurations of the task. Configure other parameters based on your business requirements.
      ParameterExample value
      Task DescriptionUpdate multiple images from CentOS 6.4 64-bit to Alibaba Cloud Linux 2.1903 LTS 64-bit at the same time.
      Task TypeImage Update
      Image for UpdateImage-AliyunLinux
      Image for RollbackImage-CentOSBck
      Execution Batch10
      Suspension PolicyAutomatic
    3. Click Create Task.
    4. Learn about the risks that are associated with the execution of the update task and click OK if you agree.
      The update task is automatically executed.
    After the task is complete, the images of the 100 ECS instances in the scaling group are updated to Alibaba Cloud Linux 2.1903 LTS 64-bit.
  7. Create and execute a script execution task.
    1. Click Create Execution Task.
    2. Configure the parameters of the script execution task.
      The following table shows the sample configurations of the task. Configure other parameters based on your business requirements.
      ParameterExample value
      Task DescriptionInstall Apache and view the status of Apache.
      Task TypeScript Execution
      Script for Execution
      # Install Apache. 
      yum install -y httpd
      # Start Apache. 
      systemctl start httpd
      # Enable Apache to run at startup. 
      systemctl enable httpd
      # View the status of Apache. 
      systemctl status httpd
      Script for Rollback
      # View the status of Apache. 
      systemctl status httpd
      Execution Batch10
      Suspension PolicyAutomatic
    3. Click Create Task.
    4. Learn about the risks that are associated with the execution of the task and click OK if you agree.
      The script execution task is automatically executed.
    After the task is complete, Apache is installed on the 100 ECS instances in the scaling group. Apache is in the active state. View the status of Apache