Wednesday, December 9, 2015

Creating a Hyper-V Guest Cluster using SCVMM - Part 1

One of the really cool features that was added to Hyper-V in Windows Server 2012 R2 is something called Shared VHDX. Basically, this feature allows you to share a VHDX file between multiple guest VM's. With this, you can create a failover cluster between the guest VM's, using the Shared VHDX file as your shared storage for the cluster.

There are many great guides and articles out on the Internet for how to setup a Shared VHDX for your Hyper-V guests. Some even go so far as showing how to setup the failover cluster once the Shared VHDX is in place. However, most of these guides and blogs describe how to set this up using only Failover Cluster Manager.

If you have a larger Hyper-V implementation and are using System Center Virtual Machine Manager to help manage your Hyper-V environment, there is a caveat you need to be aware of when using Shared VHDX. If you setup a Shared VHDX outside of SCVMM, you'll be unable to use SCVMM to manage your guest VM's, as SCVMM will throw error 23317 anytime you try to modify the properties of the guest VM's.

SCVMM Error 23317 when using Shared VHDX
SCVMM Error 23317 when using Shared VHDX
Of the blog posts that mention this error, the common solution is to make your changes using PowerShell instead. While this is certainly valid, it's not always practical depending on the change you wish to make. There must be a better way...

And there is! Service Templates allow you to define an entire “service” that could consist of multiple servers and multiple tiers of servers (i.e. database tier, application tier, webserver tier, etc.). Using the SCVMM services functionality, we can create our guest cluster and Shared VHDX from directly within SCVMM, rather than using Failover Cluster Manager. Once we do this, SCVMM is now fully aware of the Shared VHDX and can continue to manage the VM's like normal.

Creating the SCVMM Service Template

Before creating the Service Template in SCVMM, we'll need to create the virtual disks that will shared between the virtual servers. Objects in SCVMM need to be stored in the VMM Library, so we'll create the VHDX files and then add them to the Library.

Connect to one of your Hyper-V hosts, open an administrative PowerShell prompt, and enter the following commands:
Import-Module Hyper-V
New-VHD -Path <FileName.vhdx> -SizeBytes 512MB
New-VHD -Path <FileName2.vhdx> -SizeBytes 10GB

These commands will create the virtual hard disk files that will be shared between both nodes of the cluster. The smaller 512MB virtual disk will be used as the disk witness in Failover Clustering. The larger disk will actually be used as the shared storage for your cluster. Use whichever size disk you need for your cluster shared storage. Once the virtual disks have been created, copy them into the VMM library share and refresh the VMM library so the virtual disks are present in SCVMM.

Open the SCVMM console, select the Library workspace in the lower left pane, then in the upper left pane, expand Templates and select Service Templates.

On the ribbon, click on Create Service Template.

Give the Service Template a name, release number (1.0 is fine), make sure the Blank pattern is selected, and then click OK.

The Service Template Designer will open. You will see a box representing your Service.

From the left pane, select the VM template you wish to add to the service template, and drag it onto the designer.

When you release the mouse, VMM will create the “tier” using the VM template you selected.

Right click the tier and select Properties.

On the General tab, give the tier a name and description, and then set the following options:
  • This machine tier can be scaled out – enabled
  • Default instance count – 2
  • Maximum instance count – 2
  • Minimum instance count – 2
  • Number of upgrade domains – 2
  • Create an availability set for the tier – enabled

On the Hardware Configuration tab, select New and then Disk.

Select the “Use an existing virtual hard disk” option and click Browse.

Select the 512MB VHDX file you created earlier and click OK. This disk will be shared between both nodes of the cluster and will act as the quorum disk witness.

Perform the same operation again, this time selecting the larger data disk that will be used as the shared storage for the cluster. This disk will be converted to a Cluster Shared Volume once the cluster is created.

Back on the tier properties, click OK.

Go back into the properties of the tier, select the Hardware Configuration tab, select the disks that were just added, and enable the option to “Share the disk across the service tier”. Enable this for both disks that were just added. Then click OK. This will allow the VHDX files to be shared between both nodes of the cluster.

Back in the designer, click the Save and Validate button on the ribbon. This will save the service template and alert you to any incompatible settings. Then you can close the designer.

Back in the Library, right-click the Service Template and select Publish. This means the Service Template is ready to be deployed.

Now that the service template has been created and published, you are ready to deploy the service and provision the servers. In the next part of this series, I'll go over deploying the service from the service template. Stay tuned for part 2!

No comments:

Post a Comment