Export (0) Print
Expand All

Demonstrate Planned Failover in Hyper-V Replica

Published: February 29, 2012

Updated: February 29, 2012

Applies To: Windows Server 2012



This document shows you how to demonstrate using Hyper-V Replica to move virtual machines from one physical server to another without interrupting their operations, a means of maintaining business continuity in virtualized environments called “planned failover.” It will show you how to enable Hyper-V, configure the physical servers for Hyper-V Replica, start and monitor replication, perform a test failover, and perform an actual failover.

In this document

noteNote
This topic includes sample Windows PowerShell cmdlets that you can use to automate some of the procedures described. For more information, see Using Cmdlets.

To demonstrate or evaluate the planned failover of working virtual machines using Hyper-V Replica, ensure that you have two physical servers, each with the characteristics below. These two servers can be physically next to one another for ease of access or in completely separate geographic locations for a more realistic demonstration.

noteNote
If you are doing this test or demonstration with servers located in different sites, ensure that the firewall at each site is properly configured to allow communications between the servers running Hyper-V. Hyper-V Replica includes pre-configured inbound firewall rules that can be enabled depending on the authentication mechanism chosen (HTTP or HTTPS).

  • Hardware that supports the Hyper-V role

  • Sufficient storage to host the files used by whatever virtualized workloads you are using

  • Sufficient network bandwidth between the locations of the primary and Replica sites (if not co-located)

The server that you configure as a Replica server can receive replicated virtual machine data from any number of primary servers. You can configure the Replica server to accept replication from only specific primary servers, from any primary server, or from a collection of primary servers defined by fully qualified domain names with wildcard characters.

In this example, the steps will enable the Replica server to accept replication traffic using Kerberos authentication over port 8080.

Do this step using Windows PowerShell

  1. Ensure that an appropriate inbound firewall rule exists that will allow incoming replication traffic. As an example, you can use the following Windows PowerShell command to create a rule with the name HVRAllowReplicaTraffic over port 8080. Enter each cmdlet on a single line, even though they may appear word-wrapped across several lines here because of formatting constraints.

    Enable-Netfirewallrule -displayname "Hyper-V Replica HTTP Listener (TCP-In)”
    
  2. Start Hyper-V Manager and in the Actions pane for the server that will be the Replica server, click Hyper-V Settings.

  3. In the Hyper-V Settings dialog box, click Replication Configuration.

  4. In the Details pane, select Enable this computer as a Replica server.

  5. In the Authentication and ports section, choose an authentication method and the port to be used (for this example, choose Kerberos authentication and port 8080).

    noteNote
    When using Kerberos authentication, the replicated data is not encrypted over the network. Only certificate-based authentication encrypts the replicated data during transmission.

  6. In the Authorization and storage section, specify the location to store the Replica virtual machine files (or accept the default location). By default, you specify which primary servers will be allowed to send replication data to this Replica server, along with the storage location to use for each virtual machine. To specify a server, use its fully qualified domain name (FQDN) or the international equivalent (FQIDN). You can use “*” as a wildcard character in the first octet (for example, “*.contoso.com”). You can also choose not to specify allowed primary servers and instead allow any server that successfully authenticates to replicate data to this Replica server. Click Apply or OK to finish.

PowerShell Logo Windows PowerShell equivalent commands

The following Windows PowerShell cmdlet or cmdlets perform the same function as the preceding procedure. Enter each cmdlet on a single line, even though they may appear word-wrapped across several lines here because of formatting constraints.

This sequence of cmdlets will enable the server for replication using Kerberos authentication over port 8080 and storing the Replica data on the volume D:\Example. It will allow replication from any server that successfully authenticates. All steps must be completed by a user with administrative privileges.

Enable-Netfirewallrule -displayname "Hyper-V Replica HTTP Listener (TCP-In)”
Import-Module Hyper-V

$RecoveryPort = 8080
$ReplicaStorageLocation = “D:\Example”

Set-VMReplicationServer -ReplicationEnabled $true -AllowedAuthenticationType Integrated -IntegratedAuthenticationPort $RecoveryPort -DefaultStorageLocation $ReplicaStorageLocation -ReplicationAllowedFromAnyServer $true

You can enable replication (or not) for each virtual machine, regardless of the workload the virtual machine is running.

In this example, the steps will enable a virtual machine called “CRMVM” to replicate to the previously enabled Replica server. In this example, only the latest recovery point will be maintained and the initial replication occurs over the network.

Do this step using Windows PowerShell

  1. In Hyper-V Manager, right-click the virtual machine you want to configure and point to Enable Replication…. The Enable Replication wizard opens.

  2. On the Specify Replica Server page, provide the name of the Replica server which will host the virtual machine that will replicate the current virtual machine.

  3. On the Specify Connection Parameters page, enter the port that was configured to receive replication traffic in the port on the Replica server (in this example, 8080). If the system has been able to contact the Replica server already, these values will be pre-populated.

  4. Choose either Kerberos or certificate-based mutual authentication to match the selection you made on the Replica server. For this example, choose Kerberos authentication (HTTP).

  5. On the Choose Replication VHDs page, select those disks which you do not want to replicate for the virtual machine, and then click Next. Disks which contain data that is not necessary for the virtual machine to run once operations have switched to the Replica server can be excluded from replication. VHDs that contain data that is rapidly changing and not used by the Replica server after failover, such as page file disks, should be excluded from replication to conserve network bandwidth.

  6. Use the Configure Recovery History page to specify the number of recovery points to maintain on the Replica server. If you choose not to store any additional recovery points, the Replica server maintains only the latest received replica data. These points are updated approximately every 5-15 minutes, depending on the time required for each replication operation. When you choose to maintain an additional one or more recovery points, they are created once every hour. In addition, you can also select to store application-consistent snapshots at a specified interval. These snapshots use the Volume Shadow Copy Service (VSS) and preserve the state of applications that might be running in the virtual machine that is being replicated.

  7. Use the Choose Initial Replication Method page to specify the method you will use to transfer the initial copy of the virtual machine data to the Replica server. You have three options:

    • Initial replication over the network, which transfers the set of selected VHDs over the network to the Replica server either immediately or at a later time that you specify.

    • Using a pre-existing restored virtual machine on the Replica server (for example, if you have restored an earlier backup of the virtual machine on the Replica server) as the initial copy. With this option, only the changes that have occurred on the production virtual machine since it was stored are sent over the network.

    • Using external media. You can save network bandwidth by copying the initial copy to external media and then physically delivering the media to the Replica site.

    For this example, choose Send initial copy over the network.

  8. On the Completing the Enable Replication Relationship page, review the information in the Summary and then click Finish.

PowerShell Logo Windows PowerShell equivalent commands

The following Windows PowerShell cmdlet or cmdlets perform the same function as the preceding procedure. Enter each cmdlet on a single line, even though they may appear word-wrapped across several lines here because of formatting constraints.

This sequence of cmdlets will enable and start replication for two virtual machines (“CRMVM” and “IISVM”). All steps must be completed by a user with administrative privileges.

Import-Module Hyper-V

$ReplicaServer = “Recovery1.contoso.com”
$RecoveryPort = 8080
$PrimaryVM1 = “CRMVM”
$PrimaryServer = “Primary1.contoso.com”

Set-VMReplication -VMName $PrimaryVM1 -ReplicaServerName $ReplicaServer -ReplicaServerPort $RecoveryPort -AuthenticationType Integrated -CompressionEnabled $true -RecoveryHistory 0

Start-VMInitialReplication –VMName $PrimaryVM1

You can monitor replication status in Hyper-V Manager by adding the appropriate column. In the View menu, use the Add/Remove Columns option and add Replication Health to the list of Available Columns in Hyper-V Manager.You can also view replication health for a given monitoring interval. Select the virtual machine from Hyper-V Manager, right-click the replicating virtual machine, and choose View Replication Health… from the Replication option.

The health report shows the current replication state and the health of the connection. You can also view replication statistics.

To ensure that the replicated virtual machines (and applications running within them) will function properly on the Replica server just as they do on the primary server, you can conduct a test failover at any time. When you conduct a test failover, a temporary virtual machine is created on the Replica server. You can test any applications in that test virtual machine without interrupting the ongoing replication. When you conclude the test, the temporary virtual machine is deleted.

noteNote
This test virtual machine will not by default be connected to any network. If you need to conduct tests that require a network, you can modify the settings of this test virtual machine in the same way you would modify settings of any ordinary virtual machine.

Do this step using Windows PowerShell

  1. Access the Replica server, and in Hyper-V Manager, right-click the virtual machine you want to test failover for, point to Replication…, and then point to Test Failover….

  2. Choose a recovery point to use. This creates and starts a virtual machine with the name “<virtual machine name>-Test” (for example, “CRMVM-Test”).

  3. Conduct your tests on the test virtual machine. For example, you might verify that the virtual machine starts, pauses, and stops, and that any applications in the virtual machine run properly.

    TipTip
    After you have concluded your testing, discard the test virtual machine by choosing Stop Test Failover under the Replication option or simply delete the test virtual machine directly.

PowerShell Logo Windows PowerShell equivalent commands

The following Windows PowerShell cmdlet or cmdlets perform the same function as the preceding procedure. Enter each cmdlet on a single line, even though they may appear word-wrapped across several lines here because of formatting constraints.

This sequence of cmdlets will conduct a test failover of the virtual machine “CRMVM.”

$ReplicaVM1 = “CRMVM”

$TestReplicaVM1 = Start-VMFailover -AsTest -VMName $ReplicaVM1

Start-VM $TestReplicaVM1

To stop the test failover operation and discard the test virtual machine:

Stop-VMFailover –VMName $ReplicaVM1

In a planned failover, the latest changes on the primary virtual machine are replicated to its counterpart Replica virtual machine, then the Replica virtual machine starts, effectively transferring the load from the primary server to the Replica server with no loss of data. You would perform a planned failover, for example, to demonstrate and confirm readiness for a disaster recovery scenario or anytime you need to do any maintenance or upgrades which would require shutting down the physical primary server.

Do this step using Windows PowerShell

  1. If you have not already done so, follow the procedure in Step 2: Configure the Replica server to accept replication to configure the primary server to receive replicated data. You may have already used the procedure to configure the Replica server, but for a planned failover, the primary server must also be enabled for replication, so you might have to repeat Step 2 for the primary server.

  2. Start Hyper-V Manager on the primary server and choose a virtual machine to fail over. Turn off the virtual machine that you want to fail over.

  3. Right-click the virtual machine, point to Replication, and then point to Planned Failover.

  4. Click Fail Over to actually transfer operations to the virtual machine on the Replica server. Failover will not occur if the prerequisites have not been met, but this should not happen after following the instructions in this demonstration.

PowerShell Logo Windows PowerShell equivalent commands

The following Windows PowerShell cmdlet or cmdlets perform the same function as the preceding procedure. Enter each cmdlet on a single line, even though they may appear word-wrapped across several lines here because of formatting constraints.

This sequence of cmdlets will conduct a planned failover of the virtual machine “CRMVM,” provided you have already configured the primary server (in addition to the Replica server) to accept replication traffic using the procedure in Step 2. Run these cmdlets on the primary server:

Stop-VM $PrimaryVM1
Start-VMFailover -VMName $PrimaryVM1 –prepare

Then run these cmdlets on the Replica server:

$ReplicaVM1 = “CRMVM”
Start-VMFailover -VMName $ReplicaVM1
Set-VMReplication -reverse -VMName $ReplicaVM1
Start-VM $ReplicaVM1

Was this page helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft