Dreaming Andy - Fotolia
Maintenance activities are performed on virtualization hosts to ensure you are running an IT environment that holds good for audits and is compliant with IT standards and procedures. More importantly, these maintenance activities are performed to make sure certain Windows security updates are applied in a timely manner.
While there are several ways to put virtualization hosts into Maintenance Mode, the easiest way I've come across is to use the System Center Virtual Machine Manager (SCVMM) PowerShell cmdlets that ship with the SCVMM installation. You can always use Virtual Machine Manager Console to put a VM host into Maintenance Mode, but that only allows you to perform maintenance operations for a single node or cluster at a time. SCVMM provides the Disable-SCVMHost PowerShell cmdlet that you can execute against one or more VM hosts.
Before starting SCVMM Maintenance Mode process
There are a few things you need to understand before you invoke the SCVMM Maintenance Mode process. First, if a VM host belongs to a cluster or is part of a Hyper-V cluster, all of the VMs running on the host will be live migrated to a node in the failover cluster. If you are using SCVMM to perform maintenance operations, you will be asked if you want to live migrate all running VMs to another node in the cluster. If you plan to use the Disable-SCVMHost PowerShell cmdlet, you must also use the MoveWithinCluster parameter.
If there are VMs that aren't configured as highly available in a failover cluster, these VMs will be saved when the Maintenance Mode process starts as opposed to live migrating highly available VMs to a node in the failover cluster. If the VM host is standalone, the Maintenance Mode process will save all VMs running on the VM host.
How to put VM hosts into Maintenance Mode
Here are a few examples of using the Disable-SCVMHost PowerShell cmdlet:
To execute Maintenance Mode process for a single VM host, execute the following PowerShell commands on SCVMM Server:
$VMHost = Get-SCVMHost –ComputerName “VHostServer”
Disable-SCVMHost –VMHost $VMHost -MoveWithinCluster
Note that use of the -MoveWithinCluster parameter with the Disable-SCVMHost command allows the cmdlet to process requests to live migrate VMs to a node in the failover cluster.
If you wanted to execute Maintenance Mode process for all VM hosts in a specific SCVMM host group, you could use these PowerShell commands:
$VMMGroup = Get-SCVMHostGroup –Name “Dallas” –VMServer “VHostServer.TechTarget.com”
$HostsInVMMGroup = Get-SCVMHost –VMHostGroup
ForEach ($EachHost in $HostsInVMMGroup
Disable-SCVMHost –VMHost $VMHost -$EachHost
SCVMM supports putting Hyper-V hosts, VMWare ESX Hosts and XenServers into Maintenance Mode. The maintenance process might be using a different method when connecting with ESX hosts and XenServers, but the Maintenance Mode operation will be performed by one command line utility -- the Disable-SCVMHost cmdlet.
When VM hosts are put into Maintenance Mode, SCVMM automatically disables creation of new VMs, disables live migration functionality and prevents standalone hosts and host clusters from participating in the SCVMM host rating system.
Returning hosts from a Maintenance Mode requires that you either use the SCVMM Manager or run the Enable-SCVMHost PowerShell cmdlet as shown in the commands below:
$MyHost = Get-SCVMHost –ComputerName “VHostServer”
Disable-SCVMHost –VMHost $MyHost
One of the important switches supported by both the Enable-SCVMHost and the Disable-SCVMHost PowerShell cmdlets is the ability to return the control to the PowerShell window immediately rather than waiting to finish the command completely. You can use the -RunAsynchronously parameter, which instructs cmdlet to create a worker thread to execute the Maintenance Mode process, and then return to the PowerShell window immediately.
Drawback of SCVMM automatic Maintenance Mode process
It's important to note that when you return a VM host or a host cluster from Maintenance Mode, all SCVMM does is resume the services provided by the VM host. Although SCVMM allows the VM host or clusters returned from the Maintenance Mode to participate in the SCVMM host ratings supported by the SCVMM Intelligent Placement features, the SCVMM maintenance restoration process doesn't move back the VMs that were previously live migrated as part of the Maintenance Mode process. SCVMM also doesn't start the VMs that were saved during the Maintenance Mode process. You must start all VMs manually on standalone VM hosts or live migrate VMs back to their original virtual host in order to distribute the workloads equally. This is one of the drawbacks of the SCVMM maintenance process that might add some manual work before the VM hosts can be available to provide user services.
While SCVMM might load balance virtualized workloads in a cluster by invoking Dynamic Optimization, Dynamic Optimization might take some time to execute and then distribute the load equally.
What changes are coming to System Center 2016?
Learn how to group Hyper-V nodes into an SCVMM cluster
What can SCVMM do for your bare-metal hypervisor deployment?