In Windows Server 2012 Microsoft introduced a new feature called Hyper-V Replica. In my opinion Hyper-V Replica is a true Game Changer, something like the forward pass in football or the slam dunk in basketball. In my interview with Carsten Rachfahl from hyper-v-server.de I mentioned that I think a lot of customer will choose Hyper-V Replica as Disaster Recovery solution.
What is Hyper-V Replica and how does it work?
What is Hyper-V Replica and how does it work. With Hyper-V Replica it is possible to replicate Hyper-V Virtual Machines from a Hyper-V host to another Hyper-V host or cluster. The great thing about it is that Hyper-V Replica is optimized for replication over WAN. This allows companies to replica Virtual Machines from a primary site to a secondary site, and in case of a disaster on the primary site, Virtual Machines can be failed over to the secondary site.
The replication is done per virtual machine, so you can also replicate VMs to two or more different locations.
Hyper-V Replica is an asynchronous replication, Hyper-V Replica will do a initial replication of the Virtual Machine and after that changes will be replicated every 5 to 10 minutes.
How to enable Hyper-V Replica on a single host
To allow the Hyper-V host to send and receive virtual machine replications you have to enable the Hyper-V Replica feature and configure the Windows Firewall. Hyper-V Replica can be enabled via Hyper-V Manager in the Hyper-V settings. You can setup different replication settings such as which hosts can replicate to this server or which port is used for the replication and whether HTTP or HTTPS should be used.
After you have enabled Hyper-V Replica you have to open the Windows Firewall ports for Hyper-V Replica. You can simply enable the rules in the Windows Firewall settings.
You can also enable this firewall rules via Windows PowerShell.
Enable-NetFirewallRule -DisplayName "Hyper-V Replica HTTP Listener (TCP-In)"
How to enable Hyper-V Replica on a Hyper-V Cluster
To allow the Hyper-V Cluster to send and receive virtual machine replications you have to enable the Hyper-V Replica Broker role in the Hyper-V Cluster and configure the Windows Firewall on each host. The Hyper-V Replica Broker role enables the failover cluster to participate in virtual machine replication with Hyper-V Replica. You cannot replicate to a single host which is used in a cluster, you can only replicate to the Hyper-V Replica Broker.
First the Hyper-V Replica Broker cluster role has to be added.
The Hyper-V Replica Broker needs a own IP in the same subnet as the cluster. The Name of the Replica Broker role will be used as target to replicate virtual machines.
This can of course also be done via Windows PowerShell.
$Broker = "ReplicaBroker" Add-ClusterServerRole -Name $Broker –StaticAddress 10.10.77.1 Add-ClusterResource -Name “Virtual Machine Replication Broker” -Type "Virtual Machine Replication Broker" -Group $Broker Add-ClusterResourceDependency “Virtual Machine Replication Broker” $Broker Start-ClusterGroup $Broker
After you have added the Hyper-V Replica Broker role in the Cluster you have to enable Hyper-V Replica and set it up like the standalone Hyper-V host.
After you have configured the Hyper-V Replica Broker settings you also have to enable the Windows Firewall rules. This Windows PowerShell command will help you to configure the Firewall rule on every node in the cluster.
Get-ClusterNode | ForEach-Object {Invoke-Command -ComputerName $_.Name -ScriptBlock {Enable-NetFirewallRule -DisplayName "Hyper-V Replica HTTP Listener (TCP-In)"}}
How to enable virtual machine replication
After you have enabled Hyper-V Replica on the source Hyper-V host/cluster and destination Hyper-V host/cluster you can setup the virtual machine to replicate. Right click the virtual machine and “Enable Replication”.
Specify the Replica server name to use to replicate the virtual machine. If the Replica server is on a failover cluster, specify the name of the Hyper-V Replica Broker as the Replica server.
You can specify the connection parameters and set up compression for the transmitted data.
You can choose which VHDs of the virtual machine should be replicated to the destination.
Configure the Recovery History, this allows you to choose from different recovery points when you start a failover.
Configure the Initial Replication Method. You could also move the initial replication copy via external hard drive to the destination.
After you have started the replication, Hyper-V Replica will start with the initial replication of the virtual machine, and the virtual machine will also be visible on the destination Replica server.
To do this via Windows PowerShell you could use the following commands
$ReplicaServer = "ReplicaBroker.cloud.win" $RecoveryPort = 80 $PrimaryVM1 = “SharePoint2013” $PrimaryServer = "hyperv01.cloud.win Set-VMReplication -VMName $PrimaryVM1 -ReplicaServerName $ReplicaServer -ReplicaServerPort $RecoveryPort -AuthenticationType Integrated -CompressionEnabled $true -RecoveryHistory 0 Start-VMInitialReplication –VMName $PrimaryVM1
Check Replication State and Replication Health
To check the Replication State and the Replication Health you have a variety of options.
First in the Hyper-V Manager you can see the Replication State of the virtual machine.
You can also right click on the virtual machine and view the replication health, state and other interesting information.
You can also use Windows PowerShell to get information about the virtual machine replication state and health.
Get-VMReplication
Failover Options
Now after the replication is setup you have different failover options for the virtual machine. This options allow you to do different failover scenarios.
- Planned Failover
- Test Failover
- Failover
Planned Failover
A Planned Failover is a solution if both sites are still available it is also possible to migrate the virtual machine from on datacenter to another datacenter. A planned failover basically shuts down the source virtual machines, replicates all the latest changes and after all changes are replicated to the recovery site the virtual machines on the recovery site will start with no loss of data.
The primary server will automatic change to the Replica server and the Replica server will change to the primary server.
Test Failover
If you want to test the virtual machine on the recovery site you can use this feature. This will create a copy of the virtual machine on the recovery site which can be used for testing without interrupting the replication. You can also set the copy of the virtual machine to connect to another virtual switch or to be not connected so no IP address conflict will happen.
Failover
The Failover option will be used on the recovery site during a disaster where the primary site is down. This will start the virtual machine on the recovery site and the administrator will have to choose the latest recovery point. Data between the disaster recovery and the latest recovery point will be lost.
$VM = Get-VM -Name "SharePoint2013" Start-VMFailover -VM $VM
There is also a possibility to inject another IP address configuration on the recovery site.
After you have selected a Recovery Point for the Failover, the other Recovery points are still available as snapshots for this Virtual Machine. if the first Recovery Point is not working correctly you can choose another Recovery Point.
Failback
Now a lot of disaster recovery solutions are easy to failover but how can you to a failback of your workload? In Hyper-V replica this is pretty easy. After a unplanned Failover the primary server is still the same and the virtual machine is now running on the recovery server. Now to failback a virtual machine with the latest data you reverse the replication so the primary server changes to the recovery server and the recovery server where the virtual machine is running after the failover will be the primary server. Now the virtual machine will be replicated in in the other way. To do failback of the virtual machine back without losing data you can now do a planned failover.
$VM = Get-VM -Name "SharePoint2013" Set-VMReplication -reverse -VMName $VM
Conclusion
I hope this post shows you how great Hyper-V Replica is and how easy to setup it is. If you have any question about Hyper-V Replica you should check out Microsoft TechNet or use the comment function on this post.
Tags: Disaster Recovery, Hyper-V, Hyper-V 2012, Hyper-V Replica, Microsoft, PowerShell, Replica, Replication, Virtual Machine, Virtualization, VM Replication, Windows Server 2012 Last modified: January 7, 2019
Interesting post. Thanks for it.
How many recovery Point in times can be chosen? Is there any performance impact?
When I failover, how to I choose which point in time to choose to spin up the VM? What if I choose a wrong one?
Its an interesting feature but I need to know the impact before using it.
Thanks.
Hi Fred
First if you choose a Recovery Point for the Failover which is not working or has some other problems you can still change to another Recovery Point. All Recovery Point are saved as Snapshots. I have updated the post and you can find a screenshot under Familover.
For the Performance Part I will write another blog post :) I hope I could help :)
Sorry I missed one question, the maximum of Hyper-V Replica recovery points are 15.
Great Arcticle !!!!,
Need help on mentioned Case…
Need help to open Port 80 for Hyper-V Replica
We have Setup Windows Cluster 2012 Failover Cluster in Both Sites ( primary and DR) with the help of mentioned links.
https://www.thomasmaurer.ch/2012/07/hyper-v-replica-the-game-changer/
http://kristiannese.blogspot.in/2012/03/hyper-v-replica-by-example-part-one.html
Now, We want to cross-check Hyper-V Replica functionality but it is saying that Port 80 is not opened, Need Suggestion on same.
Windows Firewall inbound rules is already set as per above links.
Question: From where to where we need to open port 80 means which nodes/cluster/Hyper-V Broker ? As per mentioned cases.
Like,
Case 1. From Hyper-V broker of Primary Site to Hyper-V Broker of DR Site
Case 2: From Physical IP Address of Both Servers at Primary Site to Physical IP of Both Server at DR Site.
Case 3: From Cluster IP Address of Primary Site to Cluster IP of DR Site.
Case 4. From Physical IP Address of Primary Site to Hyper-v Replica Broker of DR Site.
Case 5. Port 80 need to open between Both End for Physical IP’s, Hyper-V Replica Broker and Cluster IP.
Kindly suggest on urgent basis.
Note: It is working fine in same IP Subnet, only change with different Subnet.
Thanks
Kirpal Singh
Hi
I have 2 servers with HV2012 .
In server 1 i have create 3 VM , i have export these 3 VM to an external usb HDD and import them to server 2 .
I have configure replica in server1 to replicate with server2. Now i have a problem ; the initial process take a long long time , why ? I have check the option ” use an existing vm in replica server as initial copy ” in wizard of Replica setup .
Can someone help me please …
br
Leo
I would recommend you to use the build in feature of Hyper-V Replica to save the media on a disk and import it on the other Hyper-V host
Hi,
Very interesting post. Do you know what are the benefits of the compression?
Thanks
This must not working at all. Because when you perform an unplanned failover on vm on replica server, the replication status of the replica server will be ‘ FailedOverWaitingCompletion’, then primary server’s replication status will be ‘critical’ as it lost data sync with the replica server. So what should we do next?