In this post series I started here with a release date announced in Windows Server Blog (by the way it was announced yesterday (1st of August) that Windows Server 2012 is RTM today), then I start highlighting the main areas of enhancements that I will focus on in this series starting from Virtualization Enhancements started from scalability & flexibility and shown how to host Virtual Machine on Windows Server 2010 file server here.
Today I am going to move to different area which is Hyper-V Mobility, and will cover one of my favorite features in Windows Server 2012 which is Hyper-V Replica, Hyper-V Replica is new functionality added to the Hyper-V Role in Windows Server 2012 that allow virtual machines running on a host or cluster in a primary site to be replicated to a server or cluster in secondary site using available network bandwidth. Hyper-V Replica replication is efficient, periodic, and asynchronous over IP-based networks and allows a system administrator, in the event of a failure at a primary site (e.g. disaster, server failure, etc.), to execute a failover of production workloads to replica servers at a secondary location within a very short time, let me show you how to configure Hyper-V Replica.
Consider that you have a very simple Hyper-V environment consists of consists of one Domain Controller “DC” and two Hyper-V Hosts “HV1” & “HV2” in the same Active Directory Domain “contoso.com”, and the high level steps to configure and test Hyper-V Replica are as follows:
- Configure the Firewall to allow Hyper-V Replication.
- Create Virtual Network and a Virtual Machine to Replicate.
- Configure Hyper-V Replication Settings on the two Hosts HV1 & HV2.
- Configure Guest IP Injection.
- Test Failover (Planned and Unplanned).
- View Replication Status Health.
Let us start showing you how it is easy to configure and test this amazing feature .
Configure the Firewall to Allow Hyper-V Replication
- On HV1 login as Domain Administrator and click Server Manager.
- From Tools menu click Windows Firewall with Advanced Security.
- In the Console Tree pane, click Inbound Rules.
- Right-click the Hyper-V replica HTTP listener (TCP-In) rule, and the click Enable Rule, and close the Windows Firewall with Advanced Security console.
- Switch to HV2, and repeat the same above steps.
Create Virtual Network and a Virtual Machine to Replicate
- On DC login as Domain Administrator and click Server Manager.
- On the Tools menu, click Hyper-V Manager.
- In the Console Tree pane, right-click Hyper-V Manager, and then click Connect to Server, and in Another computer, type HV1, and then click Virtual Switch Manager.
- Ensure External is selected, and then click Create Virtual Switch.
- In Name, Type TestNet, and then click Ok, and in Apply Networking Changes dialog box, click Yes.
- Repeat steps above using HV2 as target server to create a virtual network on HV2.
- Then from Hyper-V Manager create new virtual machine and name it TestVM.
Configure Hyper-V Replication Settings on the two Hosts HV1 & HV2:
- On DC, in the Hyper-V Management console, in the console tree pane, click HV1.
- Right-click TestVM, and click Enable Replication, and click Next.
- On the Specify Replica page, type HV2.contoso.com, and then click Next, and you should expect error stating that the specified Replica server is not configured to receive replication from this server.
- Click Configure Server to configure HV2 as replica server.
- On the Hyper-V Settings for HV2 page, check the Enable this computer as a Replica server check box.
- In the Authentication and Ports section, check the Use Kerberos (HTTP) check box, and then ensure the port is 80.
- In the Authentication and storage section, click Allow replication from any authenticated server, and click Ok.
- On the Specify Server page, ensure hv2.contoso.com is in the Replica server field, and click Next.
- On the Connection Parameters page, ensure the replica server is hv2.contoso.com, the Replica server port is 80, and Use Kerberos authentication (HTTP) is selected, and also ensure that the Compress the data that is transmitted over the network check box is checked, and click Next.
- On the Choose Replication VHDs page, ensure that C:UsersPublicDocumentsHyper-VVirtual Hard DisksTestVM.vhdx check box is checked, and click Next, and then click Next on the Configure Recovery History page.
- On the Choose Initial Replication Method page, select to Send initial copy over the network and Start replication immediately, then click Finish.
- Now from Hyper-V console right-click HV1, and then click Hyper-V Settings.
- In the Hyper-V Settings for HV1 windows, click Replication Configuration.
- Check the Enable this computer as a Replica server check box.
- In Authentication and Ports section, check the User Kerberos (HTTP) check box, and ensure that the port is 80.
- In the Authentication and storage section, click Allow replication from any authenticated server, and then click Ok.
Configure Guest IP Injection:
Let me explain more why we need guest IP Injection, when a virtual machine is replicated from a primary server to a replica server, all the machine properties, including its IP address, are replicated. Hyper-V allows an administrator to place a new IP address on the replica of the virtual machine so that when it starts, it is configured with an IP address suitable to the network where the replica server is located.
- On DC login as Domain Administrator, and in the Hyper-V Manager console, in the Console Tree pane, click HV2.
- In the Details pane, right-click TestVM, and then click Settings.
- Click Network Adapter, and the expand it.
- Click Failover TCP/IP, and in IPV4 settings area, check the User the following IPv4 address schema for the virtual machine check box.
- Configure the address from IP range same as Replica Server HV2 range, and click Apply.
- Under the Network Adapter, click Test Failover.
- In the Virtual Switch drop-down menu, click TestNet, and click Ok.
Test Failover (Planned and Unplanned):
Hyper-V allows an administrator to test whether or not a virtual machine is successfully replicating by starting it on the replica server. The test is done by starting the virtual machine on a replica server and ensuring a successful start. In the test, the virtual machine does not connect to the network; therefore it will not interfere with the original virtual machine running on the primary server. In addition, replication from the primary server to the replica server is not interrupted.
- On DC login as Domain Administrator.
- In the Hyper-V Manager console, in the Console Tree pane, click HV2.
- In the details pane, right-click TestVM, click Replication, and then click Test Failover.
- In the Test Failover dialog box, click Test Failover.
- Notice that in the Hyper-V details window, a new virtual machine named TestVM-Test is displayed.
- In the Hyper-V Manager console, right-click TestVM, click Replication, click Stop Test Failover, and then in the Stop Test Failover dialog box, click Stop Test Failover.
And to execute a planned failover such as during hardware upgrades or during a planned disaster recover test follow the below steps:
- On DC, in Hyper-V Manager console, in the Console Tree pane, click HV1.
- In the Details pane, right-click TestVM, click Replication, and then click Planned Failover, and click Failover.
- Wait for the Planned Failover dialog box to appear indicating a failover.
- In the Planned Failover dialog box, click Close.
- In Hyper-V Manager console, in the Console Tree pane, click HV2, and note that HV2 is now the primary server and HV1 is now the replica server for the TestVM.
And now let us simulate unplanned failover, something that can happened if primary datacenter failed.
- On DC, in the Hyper-V Manager console, in the Console Tree pane, click HV2.
- In the details pane, right-click TestVM, and click Shut Down., and wait until the virtual machine completely shuts down.
- In the Hyper-V Manager console, in the Console Tree pane, click HV1.
- In the Details pane, right-click TestVM, click Replication, and then click Failover.
- In the Failover dialog box, click Fail Over, and you should note that HV2.contoso.com become the current Primary Server for TestVM.
- In the Hyper-V Manager console, right-click TestVM, click Replication, and then click Reverse Replication.
- In the Reverse Replication Wizard for TestVM, click Next.
- On the Specify Replica page, ensure that the replica server failed contains HV2.contoso.com.
- Click Next four times, accepting the default values on each page in the wizard, and then click Finish.
- In the Reverse Replication Wizard for TestVM, click Close, and note that now HV1 is the primary server and HV2 is replica server for the TestVM.
View Status Replication Health:
Hyper-V Replication provides information as to the status and health of the replicated virtual machines, in this step we will determine the replication health of a virtual machine, and then we will determine the primary and replica servers for a virtual machine.
Determine the replication health of a virtual machine:
- In Hyper-V Manager console, in the Console Tree pane, click HV1.
- In the Details pane, in the Virtual Machine pane, right-click any of the column headers, for example, Name, State, CPU Usage, etc., and then click Add/Remove Column.
- In the Available Columns list, click Replication Health, and then click Add, and click Ok.
- Adjust the column sizes so as to view the Replication Health column in the window.
- In the Details pane, right-click TestVM, click Replication, and then click View Replication Health.
- Review the information found in the Replication Health window, and then click Close.
I did not decide yet about what I am going to cover in the next post, but almost I will keep digging into Virtualization Enhancements specially Mobility area that has a lot of new good features and capabilities that put Microsoft Hyper-V Virtualization Platform on top of Virtualization technologies, stay tuned, get ready, get excited.
- Windows Server 2012 – Part1: Release Date can be found here http://blogs.technet.com/b/meamcs/archive/2012/07/10/windows-server-2012-part1-release-date.aspx
- Windows Server 2012 – Part2: Virtualization Enhancements “Scalability & Flexibility” shows how to host Virtual Machine on Windows Server 2010 file server can be found here http://blogs.technet.com/b/meamcs/archive/2012/07/19/windows-server-2012-part2-virtualization-enhancements-scalability-amp-flexibility.aspx
- Windows Server 2012 – Part3: Virtualization Enhancements “Mobility” – Hyper-V Replica can be found here http://blogs.technet.com/b/meamcs/archive/2012/08/03/windows-server-2012-part3-virtualization-enhancements-mobility-hyper-v-replica.aspx