You can use the rolling update feature of Auto Scaling to update images and run scripts for ECS instances in a scaling group. This makes managing these instances more efficient.
Background
Assume that a scaling group has the following properties:
-
The scaling group is in the China (Hangzhou) region.
-
The active scaling configuration uses the CentOS 6.4 64-bit public image.
-
The scaling group contains 100 ECS instances that are created based on the active scaling configuration. All ECS instances are in the In Service state.
-
The scaling group has no ongoing scaling activities.
Procedure
This tutorial describes how to update the images of ECS instances in a scaling group to Alibaba Cloud Linux 2 and then install Apache on the instances.
Step 1: Prepare custom images
Log in to the ECS console.
In the left-side navigation pane, choose .
In the upper-left corner of the page, select a region and resource group.
-
Create an ECS instance.
-
In the upper-left corner of the Instances page, click Create Instance.
-
On the Custom Launch tab, configure parameters such as the billing method, region, instance type, and image as needed.
For more information about the parameters, see Parameter description.
The following table describes the sample configurations used in this tutorial. Ensure that the other configurations match the active scaling configuration of the scaling group.
Parameter
Example
Billing Method
pay-as-you-go
Region
Region: China (Hangzhou)
Network and Zone
-
Network: VPC
-
Zone: Random assignment
Images
-
Type: Public image
-
Version: Alibaba Cloud Linux 2.1903 LTS 64-bit
-
-
Before you create the instance, review the overall configuration on the right side of the page and set options such as the usage duration to ensure that the settings meet your requirements.
-
Read and select ECS Terms of Service and other service agreements. Follow the on-screen instructions. Then, click Confirm Order.
-
Confirm the fees for the ECS instance and complete the payment as prompted.
After the instance is created, go to the instance list page to view the creation progress. When the instance enters the Running state, it has been successfully created. Then, rename the instance to
Instance-ForCustomImage.NoteBefore you create a custom image, you can configure the created ECS instance
Instance-ForCustomImage. For example, you can deploy applications or copy data to the instance. This reduces post-update maintenance.
-
-
Prepare a custom image for the update.
-
Find the ECS instance Instance-ForCustomImage, and in the Actions column, click .
-
Configure the custom image.
The following table describes the sample configurations used in this tutorial. Configure other parameters as needed.
Parameter
Example
Custom Image Name
Image-AliyunLinux
Custom image description
This image is used for the rolling update of ECS instances in the scaling group.
-
Click Create.
-
-
Prepare a custom image for rollback.
-
Find an ECS instance that belongs to a scaling group, and in the Actions column, click .
-
Configure the custom image.
The following table describes the sample configurations used in this tutorial. Configure other parameters as needed.
Parameter
Example
Custom Image Name
Image-CentOSBck
Custom image description
This image is used to roll back the ECS instances in the scaling group if an issue occurs during the rolling update.
-
Click Create.
-
-
In the left-side navigation pane, choose to view the creation progress of Image-AliyunLinux and Image-CentOSBck.
The image is ready when its creation progress reaches 100%.
Step 2: Update image and run script
Sign in to the Auto Scaling console.
In the left-side navigation pane, click Scaling Groups.
In the top navigation bar, select a region.
Find the scaling group that you want to manage and open its details page in either of the following ways:
In the Scaling Group Name/ID column, click the ID of the scaling group.
In the Actions column, click Details.
At the top of the page, click the tab, and then find the list.
-
Create and run an image update task.
-
Click Create Execution Task.
-
Configure the image update task.
The following table describes the sample configurations used in this tutorial. Configure other parameters as needed.
Parameter
Example
Task Description
Update images from CentOS 6.4 64-bit to Alibaba Cloud Linux 2.1903 LTS 64-bit in batches.
Task Type
Update Image
Image for Update
Image-AliyunLinux
Image for Rollback
Image-CentOSBck
Execution Batch
10
Suspension Policy
Do Not Suspend
-
Click Create Task.
-
Review the impacts of the rolling update task. Click OK.
The rolling update task starts automatically.
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.
-
-
Create and run a script execution task.
-
Click Create Execution Task.
-
Configure the script execution task.
The following table describes the sample configurations used in this tutorial. Configure other parameters as needed.
Parameter
Example
Task Description
Install Apache and view the Apache service status.
Task Type
Script Execution
Script for Execution
# Install the Apache service. yum install -y httpd # Start the Apache service. systemctl start httpd # Enable the Apache service to start on boot. systemctl enable httpd # Check the status of the Apache service. systemctl status httpdScript for Rollback
# Check the status of the Apache service. systemctl status httpdExecution Batch
10
Suspension Policy
Do Not Suspend
-
Click Create Task.
-
Review the impacts of the rolling update task. Click OK.
The rolling update task starts automatically.
After the task is complete, Apache is installed on the 100 ECS instances in the scaling group, and the Apache service is active.

-
> Disks and Images > Create Custom Image