Introduction

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.

Getting Started

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.

Vembu BDR Suite

Backup your Virtual & Physical Machines
Free Forever
Agentless Backups, Flexible Scheduling, Multiple Recovery Options

Open a PowerShell console, and type the following command:

PS > Install-WindowsFeature Hyper-V

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:

PS > Set-VMProcessor -VMName “HYPV01” -ExposeVirtualizationExtensions $true

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:

PS > Enable-Netfirewallrule -displayname “Hyper-V Replica HTTP Listener (TCP-In)”

You also can check the Hyper-V rules by running the following command:

PS > netsh advfirewall firewall show rule name=all dir=in | find “Hyper-V”

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”

Hyper-V-replication

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.

Hyper-V-replication

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.

Hyper-V-replication

Hyper-V-replication

Now, we need to enable both Hyper-V hosts as Replica Server. Start the Hyper-V Manager console by going to:

  • Server Manager
  • Tools
  • Hyper-V Manager

and when the console opens, Right Click on your Hyper-V Host and choose Hyper-V Settings:

Hyper-V-replication

From left side of the menu choose Replication Configuration

Hyper-V-replication

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:

PS > New-SelfSignedCertificate -Type “Custom” -KeyExportPolicy “Exportable” -Subject “CN=rootca” -CertStoreLocation “Cert:\LocalMachine\My” -KeySpec “Signature” -KeyUsage “CertSign”

Next, we must create two server certificates for both Hyper-V hosts. We will use the previous Thumbprint and run the following command:

PS > New-SelfSignedCertificate -type “Custom” -KeyExportPolicy “Exportable” -Subject “CN=hypv-europe” -CertStoreLocation “Cert:\LocalMachine\My” -KeySpec “KeyExchange” -TextExtension @(“2.5.29.37={text}1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2”) -Signer “Cert:LocalMachine\My\6A7196D9759FC2F7C49D62E08FA7195310DE5EB7” -Provider “Microsoft Enhanced RSA and AES Cryptographic Provider”

PS > New-SelfSignedCertificate -type “Custom” -KeyExportPolicy “Exportable” -Subject “CN=hypv-france” -CertStoreLocation “Cert:\LocalMachine\My” -KeySpec “KeyExchange” -TextExtension @(“2.5.29.37={text}1.3.6.1.5.5.7.3.1,1.3.6.1.5.5.7.3.2”) -Signer “Cert:LocalMachine\My\6A7196D9759FC2F7C49D62E08FA7195310DE5EB7” -Provider “Microsoft Enhanced RSA and AES Cryptographic Provider”

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.

Hyper-V-replication

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.

Hyper-V-replication

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”

Hyper-V-replication

Select the VHDx file

Hyper-V-replication

Configure the replication frequency. By design, 5 minutes is the recommended frequency but you can select 10 or 15 minutes.

Hyper-V-replication

Select if any additional recover points must be created. By default, only the latest recovery point will be maintain.

Hyper-V-replication

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.

Hyper-V-replication

Click Finish to validate the wizard. The replication process will start in a few moment.

Hyper-V-replication

Once complete and depending the size of the Virtual Machine, then the VM will appear on the secondary host.

Hyper-V-replication

Changes will be sent every 5 minutes.

You can also use PowerShell to enable and initiate the replication.

PS > Enable-VMReplication

PS > Start-VMInitialReplication

Conclusion

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.

Follow our Twitter and Facebook feeds for new releases, updates, insightful posts and more.

Like what you read? Rate us
Configuring Windows Server 2016 Hyper-V Replica Step-By-Step
Rate this post