Mastering Windows Server 2016 Hyper-V

(Romina) #1

savdalapp01 savdalapp01—Standard Replica—(12/2/2015—7:08:59 AM) Replica
12/2/2015 7...
savdalapp01 savdalapp01—Standard Replica—(12/2/2015—8:09:00 AM) Replica
12/2/2015 8...
savdalapp01 savdalapp01—Application-consistent Replica—(12/2/2013—9:09:00
AM) AppConsistentReplica 12/2/2013 9...
savdalapp01 savdalapp01—Standard Replica—(12/2/2015—10:09:01 AM) Replica
12/2/2015 1...


To perform a failover using PowerShell, you use the Start-VMFailover cmdlet with
different switches, depending on the type of failover. Windows Server 2012 R2 and
above utilizes a new technology to maintain the recovery points instead of regular
Hyper-V snapshots, which is why you will see HRU files if you look on the filesystem.
Each HRU file represents a recovery point through use of undo logs that utilize the
change tracking that is leveraged by Hyper-V Replica. By using the HRU files instead
of snapshots, the VM’s VHD file is always in the most current state. Only if a historical
recovery point is selected are the HRU files used to roll back the state. This approach
uses less IOPS and reduces any chance of corruption.


For a test failover, typically you need to list all of the snapshots and save to an array,
so a specific snapshot can be selected to be used for the test. Next, one of the
snapshots in the array is used as part of the test failover. Zero would be the first item
in the array, so take care to look at the snapshots to ensure that the correct one is
selected. This is performed on the replica virtual machine.


$VMSnapshots = Get-VMSnapshot -VMName ‐SnapshotType Replica
Start-VMFailover -Confirm:$false -VMRecoverySnapshot $VMSnapshots[0] -AsTest


A planned failover is a bit more involved and includes running commands against the
primary VM to prepare it for failover and then activating on the replica VM. On the
primary VM, the following commands are run:


Stop-VM
Start-VMFailover -VMName –prepare


Next, on the replica VM, the following commands are run to perform the actual
failover, reverse the replication, and then start the replica VM:


Start-VMFailover -VMName
Set-VMReplication -reverse -VMName
Start-VM


An unplanned failover is used when the primary has been lost and you need to force
the replica to start. If multiple points in time are available, one of those times can be
selected in a similar fashion to the test failover, with the major difference that the -
AsTest switch is not used. Remember to select the right snapshot or don’t use a
snapshot at all, and use -VMName instead of the -VMRecoverySnapshot parameter.


$VMSnapshots = Get-VMSnapshot -VMName ‐SnapshotType Replica
Start-VMFailover -Confirm:$false -VMRecoverySnapshot $VMSnapshots[0]

Free download pdf