Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

WSFC cluster orchestration task schedule

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Task scheduling is an important component of the operating system. Through task planning, the computer can automatically help us trigger an operation under certain conditions to complete the task.

Corresponding to the real life similar to the current intelligent rice cooker, you need to eat breakfast every morning, but you don't want to do it, so you do a regular operation with the intelligent rice cooker. At seven o'clock every morning, use a small fire to cook porridge for me. When it comes to eating, the task planning in the operating system is also a common concept. The significance is to help us accomplish the task automatically through the computer, without having to do it yourself every time.

Task scheduling is usually used in operating systems or back-end applications, such as periodically executing audit collection scripts, generating hardware reports periodically, periodically dealing with application caching, and so on

Advanced computer users can use task planning to automatically help us carry out something, for example, you know that something will be done at three o'clock this afternoon, but if you are absent at three o'clock, you can make a task plan and the computer will help you finish it automatically at that time.

Enterprise IT administrators can use task scheduling to help us complete automated server collection monitoring, or actions that require repetitive execution

Application developers can use task scheduling to automatically perform the required configuration of the application on a regular basis, such as starting an exe periodically and processing a cache periodically.

When we talk about task planning, we usually mean to plan something and then do something, not just to plan, so the task planning in the computer is different from the calendar reminder. The so-called reminder software just reminds you to do something, but it won't help you do it.

There are task plans on both Windows Server and Windows Client. Lao Wang first remembered that Server 2000 had seen it. At that time, it was called task planning. It was not very different from the 2000 era until 2003. When creating a task plan, you will run a wizard, you can specify the program to execute the task, the cycle of running the task, daily, weekly, monthly, one-time, when the computer starts up, execute the task password. You can see the task schedule after creation in the Control Panel-Task schedule folder.

In the era of Sever 2008 and vista, task planning has been enhanced, renamed to task scheduler, and moved to management tools, in which task planning is more clearly divided into three levels: trigger-action-condition, what triggers the task plan under what triggers, what actions to be performed after triggering, and what conditions need to be met before the operation is performed. For example, you can set to execute only in the idle time of the operating system, etc., and it is more friendly to the display on the interface, supporting the display of task history, supporting the export of tasks, and importing tasks.

In that era, unlike now, Microsoft did not have such powerful automation tools as powershell3.0,DSC,SCO. At that time, Microsoft itself did not have many automation tools. Therefore, if administrators needed to perform some automated management operations, they would usually choose ps1+ task plan, VBS+ task plan, BAT+ task plan, write a script, and then cooperate with the task plan and execute it regularly.

With Powershell 3.0 and Windows Server 2012, the task scheduler has been further enhanced to support the creation of task plans directly through Powershell management, making it more flexible and convenient.

Example:

Register the task schedule operation, and the registered Job will not disappear because the console of Powershell is closed.

Register-ScheduledJob-Name querydriver-ScriptBlock {driverquery}

Create a task schedule operation variable

$job=Get-ScheduledJob-Name querydriver

Create a task scheduling trigger

Executed at 07:30 in the afternoon, every five days

$jobtrigger=New-JobTrigger-Daily-At "19:30 PM"-DaysInterval 5

Assign triggers to task scheduling operations

$job=Get-ScheduledJob-Name querydriver | Add-JobTrigger-Trigger $jobtrigger

The task plan created by Powershell will be executed asynchronously in the background, and the task plan is also called at the bottom, but it is more flexible to manage through one layer above the powershell package. The created task plan can be seen in the task manager taskschd.msc. The task plan created by Powershell is located in the Windows-Powershell-ScheduledJobs folder.

View task schedule

Get-ScheduledJob-Name querydriver

Delete a task schedule

Get-ScheduledJob-Name querydriver | Unregister-ScheduledJob

Disable task scheduling

Get-ScheduledJob-Name querydriver | Disable-scheduledjob

The above gives you a brief account of the context of task planning, as well as the latest 2012 support for Powershell management. Let's cut into the topic, cluster scheduling task planning.

It is also a new function in the era of dynamic data center in 2012. Although we have the ability to manage task scheduling through powershell, this can only be performed on a single machine. If it is a large-scale cluster, you need to copy the task schedule to other nodes. If there are too many nodes and it is too troublesome, through cluster scheduling, there are three ways to schedule tasks within the cluster.

Any node: register the task plan to the cluster, put the execution program on the cluster shared disk, and execute the task plan on any one node when the trigger condition is reached, which is applicable to the cluster audit log, report collection, application warm-up and other requirements. I don't need to execute on every node, as long as one node executes, if the last node goes down Next time, other normal nodes will be selected for execution.

Resource specific: register the task schedule to the cluster, put the execution program on the cluster shared disk, and automatically execute for the specified resource of the cluster when the trigger condition is reached. This type of task plan is bound to the cluster resource. The resource is migrated to that node, and the task schedule is executed at that node. If the resource is deleted, the task is also deleted, which is suitable for performing defragmentation operations on the cluster disk. By default, disk demarcation will never be performed for CSV. If you have a large number of dynamic VHDX stored on CSV, it is recommended that you create a choreography task of this type and perform disk defragmentation automatically on a regular basis, which will help CSV improve performance.

Cluster-wide: register the task schedule to the cluster, put the executor on the cluster shared disk, and when the trigger condition is reached, the task scheduler will be executed on all valid cluster nodes. for example, if you want to open a tool or set of tools when logging in to any node, you can add this task as a cluster-wide task

Cluster orchestration tasks have been introduced since 2012 and can only be managed through powershell. The management commands for all cluster orchestration tasks are as follows

Get-ClusteredScheduledTask query cluster task

Register-ClusteredScheduledTask Registration Cluster Task

Set-ClusteredScheduledTask updates registered cluster tasks

Unregister-ClusteredScheduledTask unregisters the cluster task

In this example, Lao Wang takes the creation of a resource-specific type of cluster scheduling task as an example.

1. Create choreography operation

$action = New-ScheduledTaskAction-Execute C\ ClusterStorage\ Volume2\ 1.bat

The contents are as follows: Lao Wang actually defragmented CSV. Because it belongs to the cluster disk, it needs to be set to redirect mode before executing the disk defragmentation command for CSV, and then restore it after finishing.

two。 Create an orchestration trigger that executes at 11:00 every Friday night

$trigger = New-ScheduledTaskTrigger-Weekly-DaysOfWeek Friday-At "23:00"

3. Register the orchestration operation, orchestration trigger with the cluster orchestration task

Register-ClusteredScheduledTask-Cluster hvclus-TaskName csvdefrag-TaskType ResourceSpecific-Resource "Cluster disk 3"-Action $action-Trigger $trigger

TaskType other type parameters: AnyNode, ClusterWide, the scheduling task type cannot be changed after registration

The task schedule registered by the cluster orchestration will be displayed in the task scheduler-Windows-Failover Clustering folder. This folder is hidden before the cluster orchestration task schedule is created. After creating the orchestration task, it is displayed. Although the UI interface can also create tasks, the task schedule created by the UI interface has no cluster orchestration effect and is only used as a stand-alone machine. When the node is expelled by the cluster, all tasks in this folder will be deleted.

After creating and completing the cluster orchestration task, you can see that the resource-specific type of orchestration task is only ready on the resource owner node, and the cluster orchestration task is also displayed on other nodes, but is disabled

After moving resources to 12HV02, cluster orchestration task scheduling is disabled on 12HV01 and ready on 12HV02

Any node type orchestration task will be ready at random on one node, and if that node is down, find other normal nodes ready.

The cluster-wide type orchestration task will be ready on all nodes, and when the trigger condition is reached, all nodes will execute together, and if the node is expelled from the cluster, the orchestration task will be automatically deleted

Lao Wang put the operation program of the cluster orchestration task schedule on the cluster shared disk for high availability. You can also try to put the operation program in the same location on the local disk of all nodes.

Query all scheduling tasks within the cluster

Get-ClusteredScheduledTask-Cluster hvclus

Query scheduling tasks for specific resource types within the cluster

Get-ClusteredScheduledTask-Cluster hvclus-TaskType ResourceSpecific

Query the scheduling task schedule for a specific name within the cluster

Get-ClusteredScheduledTask-Cluster hvclus-TaskName csvdefrag

Update cluster orchestration task schedule

Change trigger condition

$trigger = New-ScheduledTaskTrigger-At 22:00-Daily

Update the scheduled task schedule

Set-ClusteredScheduledTask-Cluster hvclus-TaskName csvdefrag-Trigger $trigger

Query scheduling task plan trigger condition

(Get-ClusteredScheduledTask-TaskName csvdefrag) .TaskDefinition.Triggers

Unregister the cluster orchestration task schedule, and the task will be deleted from each node after cancellation

Unregister-ClusteredScheduledTask-Cluster hvclus-TaskName csvdefrag

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report