Guide

Test a cluster failover

A cluster you have never seen fail over is a cluster you are hoping works. This test switches off a host without warning and watches the cluster restart its virtual machine on the other one.

15 minutesOn the first host, and wherever you can power off the second
What improves

You know the cluster recovers by itself, and how long it takes.

Why it matters

A failover that has never been tested tends to fail the first time it is needed.

How you do it

Start a watcher, switch off the host running the VM, and time how long the VM takes to return.

Use a test VM

The VM on the host you switch off is stopped as if its power was cut, then started again elsewhere. Do this with a test VM, or outside school hours.

Find out which host the VM is on

CON-HV-01
Get-ClusterGroup 'CON-TEST-01' | Format-Table Name, OwnerNode, State -AutoSize

This guide assumes it is on CON-HV-02. That is the host you will switch off. Run the next step on the other one.

Start a watcher

This prints a line every ten seconds and stops when the VM is running on the surviving host.

CON-HV-01
$end = (Get-Date).AddMinutes(8)
while ((Get-Date) -lt $end) {
    $g = Get-ClusterGroup 'CON-TEST-01'
    $n = (Get-ClusterNode 'CON-HV-02').State
    "{0:HH:mm:ss}  VM on {1} ({2})   CON-HV-02 is {3}" -f (Get-Date), $g.OwnerNode, $g.State, $n
    if ($g.OwnerNode.Name -eq 'CON-HV-01' -and $g.State -eq 'Online') { 'Failed over to CON-HV-01.'; break }
    Start-Sleep -Seconds 10
}

Switch the host off

On a physical server, hold the power button or use its remote management card. If the host is itself a VM, turn it off from the machine it runs on:

Hyper-V host
Stop-VM 'CON-HV-02' -TurnOff -Force

Watch

WhenWhat you see
Within 20 secondsThe host shows as Down.
For about four minutesNothing else changes. The VM still shows against the dead host.
After about four minutesThe VM shows Online on the surviving host.
The four-minute wait is deliberate

Windows cannot tell a dead host from one that has lost its network for a moment. It waits 240 seconds before restarting VMs elsewhere, so a brief blip does not restart everything. Do not switch the host back on during the wait, or you cancel the test.

Bring the host back

Switch it on again. After two or three minutes:

CON-HV-01
Get-ClusterNode | Format-Table Name, State -AutoSize
Get-ClusterGroup 'CON-TEST-01' | Format-Table Name, OwnerNode, State -AutoSize
Get-ClusterSharedVolume | Format-Table Name, State, OwnerNode -AutoSize
Invoke-Command -ComputerName CON-HV-02 -ScriptBlock { @(Get-IscsiSession | Where-Object IsConnected).Count }
CheckWhat you want
NodesBoth Up. The host rejoins by itself.
VMStill Online on the surviving host. It does not move back by itself.
Shared volumeOnline.
Last lineThe host's storage connections, back to the full number. Four, with two shares on two paths.

Things to know

  • A failover is a restart, not a seamless move. The VM starts again from cold on the other host. Anything not saved inside it is lost, as with a power cut.
  • The wait can be shortened. (Get-Cluster).ResiliencyDefaultPeriod holds the number of seconds. Lower it only if short network blips are rare on your network.
  • Planned work is different. For updates, move the VMs off first with a live migration, so nothing restarts.
  • Write the result down. Note the date and how long recovery took. It is useful evidence that your recovery plan works.

Done when

Check

The VM came back on the surviving host without anyone touching it, and the failed host rejoined the cluster with its storage reconnected.

Your progress is kept in this browser only.