In the previous post, we took a look at the basics of what Hyper-V guest clustering is exactly, why it is used, components, and requirements of this type of solution.

By using guest clustering in a production environment, businesses can have the ultimate configuration for high availability of applications and not just the virtual machine itself inside a single fault domain. Guest clustering can provide tremendous benefits in terms of uptime and general availability of absolutely critical production workloads.

In this second post of the series, we will take a look at steps to create a Hyper-V guest cluster and see how this can easily be done inside a Hyper-V cluster environment.

Steps to Create a Hyper-V Guest Cluster

When looking at the steps required to build a Hyper-V guest cluster, they involve what we will refer to as “nested clustering” essentially of a Windows Failover cluster running inside the physical Hyper-V Windows Failover Cluster that is providing compute, memory, and storage resources for the Hyper-V guest virtual machines.

To build the guest cluster inside the “hosting” Hyper-V hosts, you need:

Download Banner
  • (2) guest virtual machines that will serve as the guest Hyper-V cluster hosts
  • A shared VHDX disk or VHD Set that will serve as shared storage between the hosts
  • A Cluster network
  • Installation of the Windows Failover Cluster feature, testing, and building the cluster
  • Anti-affinity rules to keep the guest cluster hosts on separate physical Hyper-V hostscc

Let’s take a look at how we can go about setting up these requirements for use with the Hyper-V guest cluster to run highly available applications that are extremely resilient to a physical Hyper-V host failure.

Create the Guest Cluster Host Virtual Machines

In the case we are showing here, I am loading up (2) Windows Server 2019 Datacenter hosts that are being loaded inside a Hyper-V Cluster of (3) nodes.

Steps to Create a Hyper-V Guest Cluster

Loading Windows Server 2019 as a guest cluster node

After loading the new Windows Server 2019 nodes as guest virtual machines, I run through a few things as normal:

  • Windows Updates on both VMs
  • Configuring time zone
  • Joining the lab domain

Adding a VHD Set to Windows Server 2019

As discussed in the previous post, the VHD Set or VHDS shared disk configuration is the preferred way of configuring guest cluster shared disks moving forward since Windows Server 2016.
Let’s see how this can easily be done with Windows Server 2019.

Note*** In the following walkthrough we are simply adding a single shared disk. Your clustered application may require different disks and layouts than what is described. The general concepts are the same however.

To do this, we connect to the “parent” Hyper-V cluster nodes that are running the guest virtual machines. Highlight the guest virtual machine and under Actions click New Hard Disk.

Steps to Create a Hyper-V Guest Cluster

Beginning to add a new hard disk in Failover Cluster Manager

Next, you select the node you want to be the owner of the new hard disk clustered resource.

Steps to Create a Hyper-V Guest Cluster

Select the target cluster node for adding the new hard disk

The New Virtual Hard Disk Wizard launches.

Steps to Create a Hyper-V Guest Cluster

The New Virtual Hard Disk Wizard launches

Select the VHD Set option for the Disk Format.

Steps to Create a Hyper-V Guest Cluster

Selecting the VHD Set disk format

Next, choose the Disk Type you want to use for the new Hard Disk. Here I am simply leaving the default Dynamically expanding which is “thin provisioned” compared to the Fixed size or “thick provisioned” disk.

Steps to Create a Hyper-V Guest Cluster

Selecting the Disk Type for the new VHD Set hard disk

Next, we specify the Name and Location of the new VHD Set. As you can see below, I am selecting the shared S2D storage configured on the parent Hyper-V environment.

Steps to Create a Hyper-V Guest Cluster

Configure the Name and Location of the VHD Set disk

On the Configure Disk screen, you can set the size of the new VHD Set disk.

Steps to Create a Hyper-V Guest Cluster

Configure the disk size

Finally, we reach the Summary screen to review the settings for the new VHD Set disk.

Steps to Create a Hyper-V Guest Cluster

Viewing the Summary screen for the new virtual hard disk

Now that the VHD Set disk is created, it can be added to the guest clustered virtual machines using PowerShell.

  • Add-VMHardDiskDrive -VMName “< your Guest VM >” -ControllerNumber “< your controller number >” -ControllerLocation “< your controller location >” -Path “< path to the VHD Set disk >” -SupportPersistentReservation

Steps to Create a Hyper-V Guest Cluster

Using PowerShell to add the VHD Set disk to the Guest Cluster VMs

After running the PowerShell command to add the new VHD Set disk file to the VMs, you can see the new SharedDrive in the properties of the guest virtual machine in Failover Cluster Manager.

Steps to Create a Hyper-V Guest Cluster

Viewing the VHD Set shared drive in Failover Cluster Manager

Online, initialize, format, and assign a drive letter to the new shared VHD Set disk.

Steps to Create a Hyper-V Guest Cluster

Adding a Dedicated Guest Cluster Network Connection

The cluster network is an important part of the Windows Failover Cluster configuration as it allows a dedicated connection for cluster traffic. For the guest cluster, I am simply adding a new virtual NIC adapter with a VLAN tag dedicated to cluster traffic.

Once the new network adapter is added to the guest VM used for guest clustering, the connection can be addressed with a dedicated IP address to be used for cluster traffic. Keep in mind, the underlying physical network switch will need to have traffic tagged for the ports uplinking the physical Hyper-V hosts managing the guest cluster virtual machines.

Steps to Create a Hyper-V Guest Cluster

Adding a new Network Adapter on the properties of each guest virtual machine with a dedicated VLAN tag

Install Windows Failover Clustering Feature on Guest Cluster VMs, Test and Build the Cluster

Next, we need to install the Windows Failover Clustering Feature on Guest Cluster VMs. This is a simple PowerShell one-liner to install the Feature and the Management Tools:

  • Install-WindowsFeature -Name Failover-Clustering -IncludeManagementTools

This will need to be run on all the guest cluster virtual machines to install the feature. A reboot will be required as well.

After the reboot of both the guest virtual machines that will participate in the guest cluster, you can test the cluster for viability.

  • Test-Cluster < node1 >,< node2 >

Steps to Create a Hyper-V Guest Cluster

Testing the guest cluster members for guest clustering viability

To actually build the cluster, run the command:

  • New-Cluster -Name < cluster name > -node < node 1 >,< node 2 > -staticaddress < Cluster IP Address >

Steps to Create a Hyper-V Guest Cluster

Building the Hyper-V guest cluster

You should now be able to connect to the guest cluster with the Failover Cluster Manager.

Steps to Create a Hyper-V Guest Cluster

Connecting to the Failover Cluster using Failover Cluster Manager

Configuring Anti-Affinity for Guest Cluster Virtual Machines

You want to ensure the hosts that make up the guest cluster are separated onto different physical Hyper-V hosts. This is to make sure that if a physical Hyper-V host goes down, it will only take down one of the guest cluster virtual machines. This is easily configurable via a few lines of PowerShell code.

Here, we populate the AntiAffinity Class Name with a custom value and assign it to both virtual machines.

$GuestClusterAntiAffinity = New-Object System.Collections.Specialized.StringCollection
$GuestClusterAntiAffinity.Add(“Separate Guest Cluster Nodes”)
(Get-ClusterGroup –Name win19_01).AntiAffinityClassNames = $GuestClusterAntiAffinity
(Get-ClusterGroup –Name win19_02).AntiAffinityClassNames = $GuestClusterAntiAffinity

Steps to Create a Hyper-V Guest Cluster

Creating the Anti-Affinity rules to keep the guest cluster hosts separated

Checking the Anti-Affinity rules set up for each cluster group (virtual machine).

Steps to Create a Hyper-V Guest Cluster

Verifying the Anti-Affinity rules for each guest cluster virtual machine

Now, both virtual machines should effectively stay separated in the parent Hyper-V cluster they are running on.

Concluding Thoughts

While somewhat detailed, the steps to create Hyper-V guest cluster configurations running under a parent Hyper-V environment are fairly straightforward. All of the details that you need to consider with a physical Windows Failover cluster are involved with the “nested” guest cluster configuration. This includes the requirements for shared storage, cluster network, etc. The benefits as described include higher availability to applications hosted in the Hyper-V environment. With the guest cluster configured, applications will have zero downtime as the application will failover between guest cluster nodes inside the Hyper-V environment. With the Anti-Affinity rules, you ensure the guest cluster nodes are always running on separate Hyper-V hosts to prevent taking down all resources with a single parent host failure.

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

Like what you read? Rate us
Hyper-V Guest Clustering – Part 2 – Steps to Create a Hyper-V Guest Cluster
Rate this post