Hyper-V Replica is a built-in functionality added into Hyper-V role which uses asynchronous data replication technology to replicate Hyper-V virtual machines in a primary site to the Disaster recovery (DR) site using a single network connection. DR is a very important component for every IT system and it is very important to have some sort of backup/recovery option in case of a disaster, which involves datacenters, servers, storage, network bandwidth etc.
The Hyper-V Replica components consist of a primary server that hosts all the virtual machines running in production, and a replica server that hosts replicas of each virtual machines on the primary server.
We can configure VM to replicate from Production site A to DR Site B and then further replicate from DR Site B to Extended Replica Site C.
Before we can configure the replication settings for virtual machines, we are first required to enable the Hyper-V replication feature on the Hyper-V server.
Let’s jump into the Hyper-V manager and configure a Standalone Hyper-V Replica Server
Inside Hyper-V Manager, right-click on the name of your Hyper-V server and choose Hyper-V Settings
In the Hyper-V Settings, click on Replication Configuration and in the upper-right corner select Enable this computer as a Replica server. Under the Authentication and ports section select Kerberos HTTP (port 80).
The next step is to select the authorization and storage settings for your Hyper-V server. Under the authorization settings, you can select either Allow replication from any authorized server or Allow replication from specified servers. I will click on allow replication from the specified servers and type in *.mehic.se. I will also create a trust group (Replica).
On the Hyper-V Settings, click Apply and then click OK. When you click on Apply, Hyper-V will notify you in the background that the required Windows Firewall rules will get created for allowing replication traffic to pass between the Hyper-V servers. Click OK
Next step is to enable the Windows Firewall Rule to Enable Replication between the Primary and the Replica server.
Open Windows Firewall with Advance Security by running
In Inbound Rules, Right-Click on Hyper-V Replica HTTP Listener (TCP-In) and click Enable Rule. Do the same process on second Hyper-V host.
Configuration is done. Let’s enable VM replication. I will replicate DC01 which is on my HVTEST01
Inside Hyper-V Manager, right-click on the virtual machine and select Enable Replication
Before you begin page will pop-up. Click next
On Specify Replica Server page, enter either the NetBIOS or the Fully-Qualified Domain Name (FQDN) for the Replica server and click next
On the Specify Connection Parameters page, click Next.
On the Choose Replication VHDs page, click Next.
On the Configure Replication Frequency page, choose the frequency at which changes will be sent. I will select 5 min click Next.
On the Configure Additional Recover Points page, we have to configure the recovery history for the virtual machine.
First option (Maintain only the latest recovery points) means that if the VM is configured to have only a single recovery point, in case of recovery, the admin has to restore only the last single recovery point. It is good for saving the storage on your Hyper-V Replica server. Disadvantage with this is that we will not have a point-in-time recovery option.
Second option (Create additional hourly recovery point) allows us to create multiple recovery points for a given virtual machine. We can also select the number of recovery points that the virtual machine will be allowed to create. In addition to these, we can also set the frequency for the incremental replication VSS copy.
I will choose second option, click next
On the Choose Initial Replication Method page, click Next and Finish.
Process will start which can be monitored on Status bar
Upon completion of the initial copy of your VM you will see that a VM with the same name gets created on the replica Hyper-V server, and the state of the virtual machine is set to offline.
View Replication Heath
On the Primary Host right click on the VM –> replication –>View replication Health
Test failover feature gives us ability to verify the consistency of replication across the sites. The purpose of this test failover is to check the VM’s replication status in Replica Site. During testing of failover, there is no need to shut down the VM in production site and also the temporary machine created is stopped on its own without further intervention, along with the option to delete the test remnants.
Open Hyper-V Manager in Primary site and log on to DC01. Create new text document and save it. Example Test Failover
In Hyper-V Manager console (HVTEST02 – Replica Server), Right-Click on DC01 and select Replication and choose Test Failover…
On Test Failover dialog box, select a recovery point, and then click Test Failover
The New copy of the VM (DC01) is created in the Off – State. Right click on it and click Connect –> Click on start button
Verify that Test Failover document exist on the desktop (DC01 – Test).
To stop Failover Test we need to right-click on DC01 (OBS!!! Not DC01-Test) VM and choose Replication –> Stop Test Failover. When you click on Stop Test Failover DC01 -Test will be automatically removed from Hyper-V Manager as the test is completed.
Hyper-V Manager provides the ability to configure the IP address that the Replica virtual machine should use in the event of failover. We can also change the frequency, add more recovery points and change the time for Resynchronization.
You can change those settings on the primary VM.
Right-Click on the primary VM (DC01) and select Settings
To configure IP address that the Replica VM should use in the enent of failover, expand Network Adapter and click on Failover TCP/IP
To change frequency from 5 min to 30 seconds click on Replication (Management pane)
To add more recovery points expand Replication and click on recovery Points