Hyper-V Replica Resynchronization Process

by Nirmal Sharma

Resynchronizations can become necessary when a Hyper-V Primary Server fails to properly replicate to the Replica Server. Discover what to look for and how to proceed when a Hyper-V resync is needed.

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. Windows Server Tutorials 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:

Symantec AntiVirus Screenshot #1

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.

How Does the Resynchronization Process Work?

A resynchronization process goes through the following steps:

  1. A resynchronization event takes place, either manually or automatically.
  2. Primary and Replica virtual machine VHD sizes are checked.
  3. Primary Server starts tracking changes on the VHD while the resynchronization is in progress.
  4. The writes are tracked in a HRL file and are only replicated once the resynchronization process has been completed.
  5. Event ID 29242 is logged, which records the Virtual Machine Name, VHD files, VHD file's start and end block.
  6. A differencing disk is created for VHDs. This is because if the resync operation needs to be cancelled, it can be cancelled easily.
  7. The differencing disk is merged into the VHD file at the end of the resync operation.
  8. At this stage, VHDs are compared and then synced. This comparison is done block by block and only the blocks that differ are sent across the network. This reduces the amount of data sent over the network.
  9. Event ID 29244 is logged in the Primary Server when the resynchronization process is over. The Event ID 29244 includes information about the VHD being replicated, the virtual machine name, blocks sent, time taken and the result of the operation.
  10. At this stage, changes are successfully merged to the VHD file and therefore operation cannot be cancelled.
  11. All the recovery points and HRL files are deleted.

As you know, resynchronization is a process in which all recovery points are deleted and the Primary Virtual Machine is prepared for a fresh replication. This is very similar to when you enable the replication for a virtual machine.

The overall purpose of resynchronization process is to make sure the Primary Server starts tracking the changes on the VHD files once again and replication can resume as usual. So, proceed with the "manual" resynchronization process only:

  • If the Primary Server is no longer replicating to the Replica Server and a signifcant number of changes have taken place at Primary virtual machine.
  • If you suspect that the contents of Primary and Replica VMs are not matching somehow.

Nirmal Sharma is a MCSEx3, MCITP and Microsoft MVP in Directory Services. He has specialized in Microsoft Technologies since 1994 and has followed the progression of Microsoft Operating System and software. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles on various sites and contributing to Solution IDs for www.Dynamic-SpotAction.com. Nirmal can be reached at nirmal_sharma@mvps.org.

Follow ServerWatch on Twitter and on Facebook

This article was originally published on Monday Mar 10th 2014
Mobile Site | Full Site