Automatically Restarting an ECS at a Specified Time
COC is a one-stop intelligent O&M platform. It delivers centralized O&M management and control capabilities with a secure and efficient technical architecture, meeting enterprise customers' requirements for unified O&M of multiple resources across multiple scenarios.
The job management function is one of the core COC modules to implement automated O&M. It allows you to customize O&M jobs based on service requirements and deliver jobs to specified VMs for execution. In addition, COC enhances O&M process automation with its scheduled task capability. You only need to preset the trigger time or execution interval, and the system can automatically trigger various O&M jobs such as executing scripts, inspecting resources, and changing configurations based on the rule. This streamlines repetitive O&M tasks and greatly improves the standardization, timeliness, and execution efficiency of O&M operations.
This section explains how to set up and use COC's scheduled tasks for automated operations. It uses periodic ECS restarts as an example to show the setup steps and results.
Operation Process
- Step 1: Synchronize Resources: Obtain resource data in all regions to which the current user belongs and synchronize the data to COC.
- Step 2: Install UniAgent: Install UniAgent on each desired node for information exchange between COC, lower-layer services, and hosts.
- Step 3: Create an Application: Perform application modeling and manage resources by logic service unit.
- Step 4: Create a Scheduled Task: Create an automated scheduled task on COC to deliver and execute the ECS restart job with only a few clicks.
Preparations
- You have signed up for a HUAWEI ID and completed real-name authentication.
Before using COC, sign up for a HUAWEI ID, enable Huawei Cloud services, and complete real-name authentication.
If you have already enabled Huawei Cloud services and completed real-name authentication, skip this step.
- You have enabled COC.
Upon your first login, enable COC first.
If you have enabled COC, skip this step.
Step 1: Synchronize Resources
- Log in to COC.
- In the navigation pane, choose Resources > Application and Resource Management.
- On the Resources tab page, go to the tag page of the resource type you want to synchronize, for example, Elastic Cloud Server (ECS).
- Above the resource list, click Synchronize Resource.
The system obtains resource data of all regions where the current user belongs and synchronizes the data to COC.
Figure 1 Synchronizing resources
Step 2: Install UniAgent
If UniAgent has been installed on the target instance, skip this step.
- On the Resources > Elastic Cloud Server (ECS) tab page, select the target ECSs and click UniAgent > Install. The UniAgent installation page is displayed.
When UniAgent is installed in a Virtual Private Cloud (VPC) for the first time, manually install it and set a host with UniAgent installed as the installation host. For details, see How Do I Install UniAgent for the First Time?
Figure 2 Installing UniAgent
- Set parameters for installing UniAgent by referring to Table 1.
Table 1 Parameters for installing UniAgent Parameter
Example Value
Description
UniAgent Version
1.1.9.8
Select a UniAgent version from the drop-down list.
Host Access Mode
Direct access (private network)
There are three access modes: Direct access (private network), Direct access (public network), and Proxy access.
- Direct access (private network): intended for Huawei Cloud hosts.
- Direct access (public network): intended for non-Huawei Cloud hosts.
- Proxy access: Select a proxy area where a proxy has been configured and remotely install UniAgent on a host through the proxy.
Installation Host
-
Select an installation host from the drop-down list.
Select a host where UniAgent has been installed. The installation host will assist in installing UniAgent on other hosts in the same VPC.
Host About to Accommodate UniAgent
-
Specify details of the host where UniAgent needs to be installed.
- Login Account: account for logging in to the host. Use user root on Linux OSs to obtain sufficient read and write permissions.
- Login Port: port for accessing the host.
- Password: password for logging in to the host.
Figure 3 Installing UniAgent
- Click OK and wait until the installation is complete.
Step 3: Create an Application
If you have created an application and associated it with resources, skip this step.
- In the navigation pane, choose Resources > Application and Resource Management.
- Click the Applications tab. Click Create Application.
Figure 4 Creating an application
- Set Application Structure Type to Lightweight.
- Specify Application and Description. For example, set the application name to COC_01.
- Click OK. The application is created.
Figure 5 Creating an application
- Specify a component name, for example, COC_001, and click OK.
Figure 6 Creating a component
- Configure the parameters for creating a group by referring to Table 2 and retain the preset values for the parameters that are not listed in the table.
Table 2 Parameters for creating a group Parameter
Example Value
Description
Group
COC_0001
Specify a group name based on the naming rule.
Cloud Service Provider
Huawei Cloud
Select the cloud service provider to which the target instance belongs.
Region
CN North-Beijing4
Select a region from the drop-down list.
Resource Association Method
Manual association
Select a resource association method.
Associate with Resource
-
Manually select ECS resources and associate them with the group you created.
Figure 7 Creating a group
- Click OK. The group is created.
- Click OK in the lower part of the page to complete the resource modeling.
Step 4: Create a Scheduled Task
- In the navigation pane, choose Resource O&M > Automated O&M.
- In the Routine O&M module, click Scheduled O&M.
- Click Create Task.
- Set the basic information about the scheduled task you want to create by referring to Table 3.
Table 3 Basic information parameters Parameter
Example Value
Description
Task
Test_Task
Specify a task name based on the naming rule.
The value can contain 3 to 100 characters, including letters, digits, hyphens (-), and underscores (_).
Enterprise Project
default
Select an enterprise project from the drop-down list.
Version
1.0.0
The default version number is 1.0.0. You can create a script version number.
Risk Level
Medium
Select a risk level based on service requirements.
Figure 8 Configuring basic information about a scheduled task
- Set the scheduled task execution rule by referring to Table 4. Retain the default values for other parameters.
Table 4 Parameter descriptions Parameter
Example Value
Description
Scheduled Type
Periodic execution
Select Periodic execution. The task will be executed based on the specified rule until the rule expires.
Execution Time
Simple
Every Mon, 16:30:00
If you select Periodic execution as the scheduled task type, set the following parameter:
Simple: Select the execution time by week.
Rule Expired
-
This parameter is mandatory when Time type is set to Periodic.
Configure the end time of the rule. The scheduled task is executed periodically based on the user-defined execution period until the rule expires.
Figure 9 Configuring the execution rule of a scheduled task
- Set Task Type to Jobs. In the drop-down list, select Public Scripts and click the ECS restart job. Retain the preset values for other parameters.
- Select the ECS that needs to be restarted at a scheduled time.
- Disable Manual Review.
This example demonstrates only the basic functions of scheduled O&M. For details about routine O&M, evaluating operation risks and configuring a review process are recommended.
- Click OK. The scheduled task is created.
After the scheduled task is created, you can view the created scheduled task in the scheduled O&M task list.
When the specified time arrives, the selected ECS instance automatically restarts.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot