When the topic of Hyper-V replica resynchronizations revs up, the first question you might ask is why and when would you need to resynchronize a virtual machine (VM) participating in a Hyper-V Replica? If the Hyper-V Primary Server realizes that the replication for the VM is not optimal or it cannot know what to replicate, then a resynchronization operation will be needed.
And a resynchronization is actually required if the virtual machine is in a critical state or if the Primary Server has lost control over the tracked changes and cannot determine the starting point for the replication. In these cases, the Primary Server needs to start over, which includes deleting the recovery history (HRL files) and creating a baseline for the VHD files that are going to be replicated.
Resynchronization is required when the following conditions are true:
- You're modifying the VHD file using any method other than the methods available with the Hyper-V Manager. In other words, the Hyper-V Replication engine must be aware of any changes being made to the VHD files included in the Hyper-v Replication so that the changes can be recorded in the HRL file.
- HRL (Hyper-V Replication Log) accumulation is more than 50%.
- There are issues writing to HRL files.
- HRL files are not closing gracefully.
In any of these cases, if resynchronization is required for a virtual machine an error message on the "Replication Health" will be shown. The error message reads "Resynchronization is required for the virtual machine <VM Name>. Resume replication to start resynchronization." If this message is displayed, the virtual machine must be resynchronized with the Replica Virtual Machine.
Note: Before you start resynchronization, you must first resolve any connectivity issues between the Primary and Replica Servers.
There are two ways to resynchronize the contents of the virtual machine: (1) by resuming the replication on the Primary virtual machine in Hyper-V Manager, or (2) by using the PowerShell cmdlet.
From Hyper-V Manager, you can Right Click on the Virtual Machine > Replication > and then select the "Resume Replication" option to resume the replication or start the resynchronization process.
To start the resync operation from PowerShell, use the Resume-VMReplication cmdlet as listed below:
Resume-VMReplication -VMName "MyVM" -Resynchronize -ResynchronizeStartTime "02/11/2014 12:00:00"
You can also initiate the resynchronization process manually even if resynchronization is not required or if Hyper-V replica has not put the virtual machine into a "Resynchronization Required" state, but we recommend avoiding this if it is not absolute necessary.
Proceed with a manual resynchronization only if you think the virtual machine contents are not completely in sync and a resynchronization would be needed to correct this. In a manually triggered resynchronization process, the virtual machine is suspended first and then the resync operation is initiated.
Suspend-VMReplication -VMName "MyVM"
Resume-VMReplication -VMName "MyVM" -Resynchronize
You can schedule a resynchronization operation per virtual machine using the Hyper-V Manager. Right click on a virtual machine participating in the Hyper-V Replica and > select "Settings." In the left hand pane, select the "Resynchronization" option and then in the Right Pane modify the settings as required as shown in the below screenshot:
As you can see from the screenshot, there are three settings you can configure for resynchronization: (1) manually, (2) automatically and (3) at a specified interval. It is advisable to configure and use the 3rd option ("Automatically starts resynchronization only during the following hours") and then change the resynchronization to occur only during non-peak hours.
You can also use the Set-VMReplication and Get-VMReplication PowerShell cmdlets to configure and view the resynchronization settings as listed in the below commands:
Command to disable auto resynchronization:
Set-VMReplication -VMName "MyVM" -AutoResynchronizeEnabled 0
Command to enable resynchronization automatically:
Set-VMReplication -VMName "RESYNC VM" -AutoResynchronizeEnabled 1 -AutoResynchronizeIntervalStart 00:00:00 -AutoResynchronizeIntervalEnd 23:59:59
To check the resynchronization settings, use the Get-VMReplication PowerShell cmdlet as shown below:
Get-VMReplication -VMName "MyVM" | ft * -auto
To check settings for all virtual machines participating in the Hyper-V Replica:
Get-VMReplication * | ft * -auto
In the Get-VMReplication output, look for the AutoResynchronizeEnabled, AutoResynchronizeIntervalStart, and AutoResynchronizeIntervalEnd columns and their values.