PowerShell cmdlets增強(qiáng)Win Server故障轉(zhuǎn)移群集管理
如果你管理Windows故障轉(zhuǎn)移群集,你會(huì)發(fā)現(xiàn)安裝Windows Server 2012故障轉(zhuǎn)移群集之后,Cluster.exe CLI 命令沒(méi)了。這些年,系統(tǒng)管理員們一直使用Cluster.exe腳本創(chuàng)建集群、轉(zhuǎn)移故障轉(zhuǎn)移組、修改資源屬性和解決集群宕機(jī)問(wèn)題。是的,Cluster.exe命令仍在遠(yuǎn)程服務(wù)器管理工具(RSAT)中。但不是默認(rèn)安裝。
你可能會(huì)在Windows Server 2012中發(fā)現(xiàn)任務(wù)欄上的PowerShell和Server Manager圖標(biāo),但可能會(huì)疏忽Windows Server 2012操作系統(tǒng)默認(rèn)安裝的是Server Core,包含2300多個(gè)PowerShell cmdlet。微軟明確表明了,就像其他任何數(shù)據(jù)中心服務(wù)器一樣,可以遠(yuǎn)程或者使用腳本管理Windows服務(wù)器。在Windows中,意味著PowerShell。
幸運(yùn)的是,Windows Server故障轉(zhuǎn)移群集對(duì)PowerShell來(lái)說(shuō)不再陌生了。Windows Server 2008 R2 中就有69個(gè)群集相關(guān)的PowerShell cmdlet協(xié)助配置集群、組織和資源。本文探討Windows Server 2012故障轉(zhuǎn)移集群中的新PowerShell cmdlet。
Windows Server 2012中,總共有81個(gè)故障轉(zhuǎn)移群集cmdlet可以用來(lái)管理PowerShell組件。新的群集cmdlet可以執(zhí)行群集資源注冊(cè)表檢查點(diǎn)(Add-ClusterCheckpoint)、監(jiān)控虛擬機(jī)服務(wù)故障(Add-ClusterVMMonitoredItem)和配置兩個(gè)新角色:Scale-Out File Servers(Add-ClusterScaleOutFileServerRole)和iSCSI Target Server (Add-ClusteriSCSITargetServerRole)。
圖1. Windows PowerShell ISE幫助管理員熟悉故障轉(zhuǎn)移集群cmdlets
圖1中,使用PowerShell cmdlet“Get-command –module FailoverClusters”列出了所有的故障轉(zhuǎn)移群集cmdlets。我正在使用內(nèi)置的Windows PowerShell腳本集成環(huán)境(ISE)編輯器,它可以幫助管理員們熟悉所有的故障轉(zhuǎn)移群集cmdlets。
除了故障轉(zhuǎn)移群集cmdlets之外,微軟還有一些新的PowerShell cmdlets模塊,包括ClusterAwareUpdating(17個(gè)新cmdlets)、ClusterAware ScheduledTasks(19個(gè)新cmdlets)和iSCSITarget(23個(gè)新cmdlets)。還有很多群集識(shí)別更新 cmdlets,比如Add-CauClusterRole(添加CAU角色)、Get-CauReport(獲得更新報(bào)告)以及Invoke-CauRun(調(diào)用執(zhí)行掃描和安裝任何新的更新)
群集識(shí)別任務(wù)調(diào)度是Windows Server 2012的新功能,并且任務(wù)調(diào)度程序目前與故障轉(zhuǎn)移群集集成。一個(gè)調(diào)度任務(wù)可以以下面三種方式運(yùn)行:
- ClusterWide on all cluster nodes
- AnyNode on a random node in the cluster
- ResourceSpecific on a node that owns a specific cluster resource
新的ScheduledTasks cmdlets創(chuàng)建一個(gè)群集識(shí)別調(diào)度任務(wù)。在表格中,你可以看到cmdlets可以注冊(cè)、獲取和設(shè)置集群預(yù)定任務(wù)屬性。
想要使用這些PowerShell cmdlets,首先你要指派一個(gè)動(dòng)作和Trigger變量。這個(gè)動(dòng)作變量指定執(zhí)行程序,比如下面例子中的Windows計(jì)算器。Trigger變量在執(zhí)行任務(wù)前設(shè)置。生成的cmdlets安排群集中的任務(wù)在每天14:00執(zhí)行,就像下面這樣:
- PS C:\> $action = New-ScheduledTaskAction –Execute C:\Windows\System32\Calc.exe
- PS C:\> $trigger = New-ScheduledTaskTrigger -At 14:00 –Daily
- PS C:\> Register-ClusteredScheduledTask -Action $action -TaskName ClusterWideCalculator -Description "Runs Calculator cluster wide" -TaskType ClusterWide -Trigger $trigger
- TaskName TaskType
- -------- --------
- ClusterWideCa... ClusterWide
- PS C:\>
圖2. 在Task Scheduler中,管理員可以瀏覽所有的群集任務(wù)
但是,只有PowerShell能用來(lái)注冊(cè)、獲得/設(shè)置和注銷(xiāo)群集識(shí)別調(diào)度任務(wù)。你可以在Computer Management中使用Task Scheduler瀏覽群集任務(wù)(圖2)。
圖3.管理員以使用新的iSCSI Target cmdlets配置iSCSI LUNs
***,可以使用高可用的iSCSI Target Server配置故障轉(zhuǎn)移群集。使用Install-WindowsFeature –name FS-iSCSITarget-Server(或使用Server Manager)安裝iSCSI Target Server角色。然后使用新的cmdlet Add-ClusteriSCSITargetServerRole創(chuàng)建iSCSI Target資源并產(chǎn)生共享存儲(chǔ)。然后,你可以使用新的iSCSI Target cmdlets配置iSCSI LUNs(圖3)。
Windows Server 2012中的PowerShell cmdlets完全可以幫助你管理你的故障轉(zhuǎn)移群集。除了創(chuàng)建、配置和解決群集問(wèn)題,你還可以使用PowerShell cmdlets添加新的擴(kuò)展文件服務(wù)器、iSCSI Target Server角色、集群調(diào)度的任務(wù)和Cluster-Aware Updating。