What is Hyper-V Replica?
Hyper-V Replica is a free in-built feature in Hyper-V 3.0 for disaster recovery. It contributes to your disaster recovery strategy by creating a copy of the production virtual machine to a replica Hyper-V host. It will allow you to bring back your replica Virtual Machines instantly during the system crash or major disaster.
Let’s imagine that your primary host hardware failed, then you will be able to start your Virtual Machines on your secondary host. If you work in a small environment, then you probably do not deploy Hyper-V Clusters, then you will work with Hyper-V Host in a standalone mode. Hyper-V replication enables you to set up a Virtual Machine to replicate from one Hyper-V host to another Hyper-V Host which you can recover easily within minutes in case of a disaster. However, Hyper-V replication is not an alternative to backup.
Let’s take a look at how native Hyper-V replication is configured. Before going deeper, you must build two Hyper-V hosts (at least):
- Build two Physical or Virtual Host servers. In this guide, both Virtual Hyper-V hosts will run the same version of Windows Server 2016, thanks to the Nested Virtualization. Nested Virtualization refers to virtualization that runs inside an already virtualized environment. In other words, it is the ability to run a hypervisor inside of a virtual machine (VM), which itself runs on a hypervisor
- You must install the Hyper-V role on both
- Make sure both servers are fully patched through Windows update
Hyper-V Replica is a feature of Hyper-V, so you must enable the Hyper-V server role if you are not already using it. This feature is included in Windows Server 2012, 2012R2, and in Windows Server 2016.
Open a PowerShell console, and type the following command:
With Windows Server 2016, Microsoft provides the ability to run a Hyper-V inside of a Hyper-V, which is called Nested Virtualization. If you wish to install another Hyper-V Server for testing purposes, you need to run this command on the Hyper-V server:
Note that your Hyper-V Virtual Machine must be powered off.
Please note the following information:
- You do not need Failover Clustering in order to implement Hyper-V Replica. You just need two servers with the Hyper-V role installed
- Your Hyper-V hosts can be in a workgroup or Active Directory Domain
- Hyper-V Replica feature is not High Availability solution
To allow the replication between the Hyper-V hosts, we need to provide correct permissions first. To do so, let’s run these commands in the PowerShell on both Hyper-V Hosts:
You also can check the Hyper-V rules by running the following command:
You can also see the Hyper-V rules from the GUI:
- Control Panel
- Windows Firewall
- Advanced settings
- Inbound Rules
Enable these rules by right clicking and selecting “Enable Rule”
This should be done on both servers.
Setting up Windows Server 2016 Hyper-V VM Replication
In this lab, I deployed two Hyper-V Hosts:
- Hypv-Europe with the following IP Address 10.0.0.4. This host will be the primary host
- Hypv-France with the following IP Address 10.200.200.4. This host will be the secondary host
Let’s confirm that both Hyper-V hosts can communicate. If the ping does not work, then you must check your network settings or configure your Windows Firewall to allow the icmp request.
It is nice to work with hostname, so you can create a host file with IP address and hostname of the server. Make sure you can ping the hostname.
Now, we need to enable both Hyper-V hosts as Replica Server. Start the Hyper-V Manager console by going to:
- Server Manager
- Hyper-V Manager
and when the console opens, Right Click on your Hyper-V Host and choose Hyper-V Settings.
From left side of the menu choose Replication Configuration
Repeat this step on both Hyper-V hosts.
For those of you who want to use a certificate to allow replication, then the first step to do is to create a root CA certificate:
Next, we must create two server certificates for both Hyper-V hosts. We will use the previous Thumbprint and run the following command:
Import these certificates on both Hyper-V Hosts.
The configuration is done. You can now right-click on a Virtual Machine and click on “Enable Replication”
Replication wizard starts and click next.
In my case, I want to replicate the Virtual Machine from Hypv-Europe to Hypv-France. Click on Browse and select the replica server. Click next.
Specify the connection between the two host servers. In my case, I will use port 443 using a certificate base encryption between host servers.
You can enable “Make sure Compress the data that is transmitted over the network”
Select the VHDx file
Configure the replication frequency. By design, 5 minutes is the recommended frequency but you can select 10 or 15 minutes.
Select if any additional recovery points must be created. By default, only the latest recovery point will be maintained.
Choose how to send the initial copy. Here, I will use the network to send the copy. If you work with a branch office, it could be useful to send the initial copy using external media, depending on the bandwidth.
Click Finish to validate the wizard. The replication process will start in a few moments.
Once complete and depending the size of the Virtual Machine, then the VM will appear on the secondary host.
Changes will be sent every 5 minutes.
You can also use PowerShell to enable and initiate the replication.
If you want to configure Hyper-V replica with Hyper-V cluster, I advise you to read the following article written by Brandon Lee: Hyper-V Basic Replication Configuration
Why? Because the cluster will need to have the Replication Broker role installed.
Hyper-V Replica are not replacement for backups
The main purpose of Hyper-V replica is to ensure business continuity at the time of a minor system crash or minor disaster. Since, replica needs a short period of time to start, it’s optimal in situations where long periods of outages are inconvenient. This does not change the purpose of Hyper-V Backup or qualify it as a replacement for a virtual machine backup.
Backups are still crucial for protecting your business-critical data from ransomware, disaster, etc.
Backups also now provide immediate data recovery within the site for various data loss scenarios. Backup supports more recovery points than VM replication for your VMs that help you to fallback to any point-in-time and also help to comply with all major compliances.
To have an efficient backup and disaster recovery strategy, both backup and replication is necessary to protect your business infrastructure from various data loss scenarios. By having VM replication and backup in your BC/DR strategy you will be able to implement the best version of 3-2-1 backup rule. In the 3-2-1 backup rule, it is recommended to have (3) copies of your data, stored on at least (2) different types of media, with at least (1) copy stored offsite.
Vembu BDR Suite is a comprehensive backup solution which provides backup and replication features for your Hyper-V virtual machines and clusters and enables you to implement 3-2-1 backup methodology in your business environment.
Be sure to download a 30-day free trial of Vembu BDR Suite for testing out the powerful backup and replication options you get for Microsoft Hyper-V.