Edit

Share via


Enable Hyper-V Replica on a single host

Hyper-V Replica helps you protect your workloads by replicating virtual machines (VMs) between Hyper-V hosts running Windows Server. This article explains how to enable Hyper-V Replica on a single host by using Hyper-V Manager, PowerShell, or Windows Admin Center - Virtualization mode.

You can replicate between clusters, single hosts, or a combination of both. If you use a certificate for authentication, there's no Active Directory dependency between the hosts. Single hosts can either be domain members or be in a workgroup.

If you want to learn how to enable Hyper-V Replica on a failover cluster instead, see Enable Hyper-V Replica on a failover cluster. For more information about Hyper-V Replica and how it works, see Hyper-V Replica overview.

Prerequisites

Before you begin, make sure you meet the following prerequisites:

  • You have a single Hyper-V host to receive the replicated VM. You also have another cluster or single host that runs the VM you want to replicate.

  • Decide on an authentication method:

    • If your hosts are joined to the same or trusted Active Directory domains, you can use Kerberos (HTTP) authentication.

    • If your hosts aren't domain joined or are in untrusted domains, or you also want to use encryption, you must use certificate-based (HTTPS) authentication. You need to have a valid certificate installed on each host, both sending and receiving. The certificate must meet the following requirements:

      • Not be expired
      • Have both Client and Server Authentication Enhanced Key Usage (EKU) attributes and an associated private key.
      • Terminate at a valid root certificate.
      • The subject common name (CN) or subject alternative name (SAN) must match the fully qualified domain name (FQDN) of the host. If you're sending a VM from a cluster, you also need a certificate for the Hyper-V Replica Broker role FQDN on each primary host.
  • Network connectivity between the hosts. By default, if you use Kerberos authentication, replication uses HTTP over port 80. If you use certificate-based authentication, replication uses HTTPS over port 443.

  • A storage location on the receiving host to store the replicated VMs.

  • A user account that has administrative privileges on both the primary and replica clusters or hosts.

Enable Hyper-V Replica

Before you can replicate VMs to a single Hyper-V host, you need to enable Hyper-V Replica. You configure the receiving host, not the primary cluster or host.

To ensure that you can fail a VM back to the original primary host or cluster after a failover event, configure both primary and replica hosts and clusters for replication.

Use Hyper-V Manager, PowerShell, or Windows Admin Center - Virtualization mode to enable and configure Hyper-V Replica. Select the relevant tab for instructions.

To enable and configure Hyper-V Replica by using Hyper-V Manager:

  1. Open Hyper-V Manager on a device you use to manage the host that you want to replicate to, or on the host itself where Windows Server with Desktop Experience is installed.

  2. In the left pane, select the host you want to configure as the replica server.

  3. In the right pane, under Actions, select Hyper-V Settings.

  4. Under the Server section, select Replication Configuration in the left pane and make the following changes:

    1. Check the box Enable this computer as a Replica server.

    2. For Authentication and ports, check the box for the authentication method you want to use from Use Kerberos (HTTP) or Use certificate-based authentication (HTTPS). Change the port if you don't want to use the default ports. If you're using certificate-based authentication, select Select Certificate, then you're prompted to select the certificate that matches the requirements.

    3. For Authorization and storage, select either Allow replication from any authenticated server to allow the replica server to accept VM replication traffic from any primary server that authenticates successfully, or Allow replication from the specified servers to accept traffic only from the primary servers you specifically select. For both options, you need to specify where the replicated VHDs should be stored on the replica host.

      If you select Allow replication from the specified servers, select Add. In Add Authorization Entry, specify the FQDN of a primary host, a location to store replica files, and a trust group. A trust group is a free-form text field that you can use to group primary servers. Select OK.

    4. Select OK to save your settings.

    A screenshot of the Replication Configuration settings in Hyper-V Manager showing options to enable the server as a Replica and configure authentication and authorization.

Enable Windows Firewall rules for Hyper-V Replica

To allow replication between the primary and replica clusters and hosts, traffic must get through the Windows Firewall (or any other third-party firewalls). When you install the Hyper-V role on each host, the Windows Firewall creates exceptions for HTTP (80) and HTTPS (443), but it doesn't enable them by default. You need to enable the appropriate rules for all receiving hosts.

You can enable the rules by using your preferred method of managing the Windows Firewall, such as centrally using Group Policy, or locally on each node by using the Windows Firewall with Advanced Security console or PowerShell. For more information about managing the Windows Firewall and how-to guides, see Windows Firewall tools.

The rules you need to enable depend on the authentication method you chose when you configured the Hyper-V Replica Broker role:

  • Enable Hyper-V Replica HTTP Listener (TCP-In) for Kerberos (HTTP) authentication.
  • Enable Hyper-V Replica HTTPS Listener (TCP-In) for certificate-based (HTTPS) authentication.

Test replication configuration

After you enable and configure Hyper-V Replica and enable the appropriate Windows Firewall rules, test the configuration to ensure that the primary cluster or host can connect to the replica host as expected.

You can use the PowerShell cmdlet Test-VMReplicationConnection to test the connection, as shown in the following examples. Be sure to replace placeholder <values> with your own.

  1. Open a PowerShell session as an administrator on one of the hosts that you want to replicate from, or connect remotely by using the Enter-PSSession cmdlet on a device you use to manage the cluster or host.

  2. Use one of the following example commands:

    • To test a connection to a replica cluster by using Kerberos authentication, run the following command:

      Test-VMReplicationConnection -ReplicaServerName '<Replica host FQDN>' -ReplicaServerPort 80 -AuthenticationType Kerberos
      
    • To test a connection to a replica cluster by using certificate-based authentication, run the following command. You need the thumbprint of a valid certificate for Hyper-V Replica on the primary host or cluster.

      Test-VMReplicationConnection -ReplicaServerName '<Replica host FQDN>' -ReplicaServerPort 443 -AuthenticationType Certificate -CertificateThumbprint AA11BB22CC33DD44EE55FF66AA77BB88CC99DD00
      

    For either of these example commands, here's the output you should see if the test is successful:

    The connection to the specified Replica server with the specified parameters was successful.