Hyper-V replication is an essential feature for any organization. It will allow you to restore an up-to-date copy of your Virtual Machines very quickly. Please note that Hyper-V replication is not similar to backup!
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. With Hyper-V replication, we can setup a Virtual Machine to replicate from one Hyper-V host to another Hyper-V Host.
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 recover points must be created. By default, only the latest recovery point will be maintain.
Choose how to send the initial copy. Here, I will use the network to send the copy. If you work with branch office, it could be useful to send the initial copy using external media, depending the bandwidth.
Click Finish to validate the wizard. The replication process will start in a few moment.
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.
Thanks to the Hyper-V replica feature, you can now replicate easily and quickly your Virtual Machines from a primary host to your secondary host. This feature is interesting if you need to replicate a Virtual Machine between two Hyper-V hosts. These Hyper-V hosts can be on a dedicated datacenter.
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.Like what you read? Rate us