All Products
Search
Document Center

Elastic Compute Service:Upload a file to multiple ECS instances at a time

Last Updated:Jun 25, 2024

You can use CloudOps Orchestration Service (OOS) to upload a file to multiple Elastic Compute Service (ECS) instances at a time to improve efficiency. The file can be an on-premises file, an Object Storage Service (OSS) object, or a remote HTTPS file. This topic describes how to upload a file to multiple ECS instances at a time by using OOS.

Note

OOS is an automated O&M service provided by Alibaba Cloud to help you manage and execute O&M tasks in the cloud. For more information, see What is OOS?

Prerequisites

The ECS instances to which you want to upload a file are in the Running (Running) state.

Step 1: Select a file type

You can use OOS to upload files of the types that are described in the following table. Select a file type based on your business requirements.

File type

Description

Size limit

On-premises file

A file that is stored on an on-premises computer or server.

500 MB

OSS object

A file that is stored in an OSS bucket.

None

HTTPS file

A remote file that can be accessed over HTTPS. In most cases, an HTTPS file is hosted on a web server and transmitted over HTTPS. The URL of the file starts with https://.

None

Step 2: Prepare the upload environment

Complete the preparations based on the file type that you selected in the previous step to meet the upload requirements for the file type.

  • On-premises file

    Obtain the storage location of the file that you want to upload on the on-premises computer or server. This way, you can quickly find the file for subsequent upload operations.

  • OSS object

    1. Store the file that you want to upload in an OSS bucket. For more information, see Upload objects.

    2. Create an instance Resource Access Management (RAM) role, grant the required resource access permissions to the instance RAM role by attaching a policy to the instance RAM role, and then attach the instance RAM role to the ECS instances. In this example, the AliyunOSSReadOnlyAccess policy is attached to the instance RAM role. For more information, see the Create an instance RAM role and attach the instance RAM role to an ECS instance section of the "Grant ECS access to resources of other Alibaba Cloud services by using instance RAM roles" topic.

      Attach an instance RAM role to multiple ECS instances at a time

      1. Log on to the OOS console.

      2. In the top navigation bar, select the region where the ECS instances to which you want to attach the instance RAM role reside.

      3. In the left-side navigation pane, choose Automated Task > Common O&M Tasks. On the Batch Instance Operations tab, click Create.

      4. On the Create Task Batch Instance Operations page, configure the following parameters:

        • Task Type: Select Instance Operations.

        • Operations to Be Performed: Choose More > Add Role.

        • Role Name: Select the instance RAM role that you created.

        • Select Instances: Select multiple ECS instances as prompted.

      5. Click Create. In the Parameter Confirmation message, click OK.

        When the value of Execution Status changes to Success on the task execution details page, the instance RAM role is attached to the selected ECS instances.

  • HTTPS file

    Obtain the URL of the HTTPS file and make sure that the ECS instances to which you want to upload the file have access to the Internet. For more information, see Modify the public bandwidth configurations of an instance associated with an auto-assigned public IP address or Associate an EIP with an ECS instance.

Step 3: Upload a file to multiple ECS instances at a time

  1. Log on to the OOS console.

  2. In the top navigation bar, select the region where the ECS instances to which you want to upload the file reside.

  3. In the left-side navigation pane, choose Automated Task > Common O&M Tasks. On the Batch Instance Operations tab, click Create.

  4. On the Create Task Batch Instance Operations page, configure the parameters described in the following table.

    Note

    For the parameters that are not described in the following table, use the default values.

    Parameter

    Description

    Task Type

    Select Batch Download Files.

    File Type

    Select an option based on the type of the file that you want to upload. In this example, local File is used.

    Select File

    1. Select the on-premises file that you want to upload or drag and drop the file to the gray area of Select File. In this example, the image.png file is used.

    2. Select I agree to store the file in the temporary OSS bucket that Alibaba Cloud provides.

      Note

      Alibaba Cloud temporarily stores the file that you want to upload in an OSS bucket. After you upload the file to the selected ECS instances, Alibaba Cloud automatically deletes the file from the OSS bucket. The validity period of the file URL is 900 seconds.

    Save Path of File

    In this example, /root is used.

    Select Instances

    Select a method to filter ECS instances and select one or more ECS instances to receive the file based on your business requirements. In this example, Manually Select Instances is selected.

    Note

    If you want to upload the file to a large number of ECS instances at a time, select Specify Instance Tags or Specify Resource Group. This way, you can select ECS instances by tag or resource group. For more information, see Tag overview and Resource Group overview.

    image

  5. Click Create. In the Parameter Confirmation message, click OK.

    When the value of Execution Status changes to Success on the task execution details page, the file is uploaded to the selected ECS instances.

    image

  6. (Optional) Check the integrity and functionality of the file.

    1. Connect to an ECS instance. For more information, see Connection method overview.

    2. Check the file that is uploaded to the ECS instance. The following check items are provided as examples:

      • Compare the size of the file before and after the upload operation to check whether the file size changed.

      • Execute the application or script in the file to check whether the application or script works as expected.

      • Open the media file or document to ensure that the file or document is not damaged and can be correctly read.

References

  • If you upload script or application files, you can configure scheduled tasks to execute the files based on a schedule. You can use Alibaba Cloud OOS to set up cron jobs. For more information, see Perform scheduled O&M and Configure CRON expressions.

  • For data security and restoration purposes, you may need to back up data on ECS instances after you upload files to the instances. To improve operation fault tolerance and ensure data security, you can create snapshots for disks to back up data. For more information, see Create a snapshot for a disk.