You dont have javascript enabled! Please enable it!

A First Look at VM Groups and VM Start Ordering in Windows Server Hyper-V #HyperV

8 Min. Read

Introduction

Let’s take a first look at VM Groups and VM Start Ordering in Windows Server 2016 Hyper-V.

As the name implies, VM Groups are logical groupings of multiple VMs which allows you to manage multiple virtual machines much easier.

On the other hand, VM Start Ordering provides better control around the starting of VMs and dependencies between clustered virtual machines. This is very important in a failover clustering environment where you have multiple virtual machines that are dependent on other VMs. An example of a complex VM start-ordering scenario is a multi-tier application and all its interdependencies on the Domain Controller, SQL Server, IIS Server, Application Server, Load Balancer, etc.

VM Groups

VM Groups is a new feature introduced in Windows Server 2016 Hyper-V.

There are two different types of VM Groups:

  • VM collection groups
  • Management collection groups

VM collection groups are a logical collection of virtual machines. This type of group makes it possible to carry out tasks on specific VM groups, rather than having to carry them out on each individual VM separately.
Management collection groups are a logical collection of VM collection groups. With this type of group, you can nest VM collection groups as well. In other words, you can have a management collection group inside another management collection group. The main difference between VM collection groups and management collection groups is that management groups can contain both VM groups and other management groups as well.

The two main scenarios for which Microsoft developed VM groups are for backups and VM replications. In some situations, because of distributed applications, virtual machines should be treated as a single unit instead of managing them individually. This is true in both backup and VM replica situations where you want to backup or replicates a multi-tier application.

The following new PowerShell cmdlets have been added into the Hyper-V module to facilitate VM Groups scripting:

Add-VMGroupMember
Get-VMGroup
New-VMGroup
Remove-VMGroup
Remove-VMGroupMember
Rename-VMGroup

At the time of writing, VM group management tools are still being developed and they are managed through Windows PowerShell only.

Let’s now look at how to create and manage VM collection groups and Management collection groups with Windows PowerShell.

VM Collection Groups

In this example, we will create a VM Collection Group and place three virtual machines in it.

# Create new VM Group
New-VMGroup -Name VMCLGR01 -GroupType VMCollectionType –Verbose

VMGrouping-VMStartOrdering-02

Please note the Group Type is “VMCollectionType”. Only the VM collection groups can have virtual machines directly placed within them.

VMGrouping-VMStartOrdering-03

Next, we will add three VMs to the VM Group called “VMCLGR01”.

VMGrouping-VMStartOrdering-14

# Add VMs to VM Collection Group
Add-VMGroupMember -VMGroup (Get-VMGroup VMCLGR01) -VM (Get-VM WS-VM001) -Verbose
Add-VMGroupMember -VMGroup (Get-VMGroup VMCLGR01) -VM (Get-VM WS-VM002) -Verbose
Add-VMGroupMember -VMGroup (Get-VMGroup VMCLGR01) -VM (Get-VM WS-VM003) -Verbose

VMGrouping-VMStartOrdering-04

You can verify the VMs that belongs to VM Group “VMCLGR01” by utilizing either Get-VM or Get-VMGroup cmdlets, respectively:

Get-VM | ft Name, State, Groups -AutoSize

VMGrouping-VMStartOrdering-05

Get-VMGroup VMCLGR01 | ft Name, VMMembers -AutoSize

VMGrouping-VMStartOrdering-06

You can add one of the existing VMs to the membership of a second group as well.
Here is a quick PowerShell script that will do just that:

# Create new VM Group
New-VMGroup -Name VMCLGR02 -GroupType VMCollectionType –Verbose
# Add VMs to VM Collection Group
Add-VMGroupMember -VMGroup (Get-VMGroup VMCLGR02) -VM (Get-VM WS-VM002) -Verbose

# Get-VM, we can see that WS-VM002 now belongs to both the VMCLGR01 Group and the new VMCLGR02 Group
Get-VM | ft Name, State, Groups -AutoSize

VMGrouping-VMStartOrdering-07

As you can see, there are now two VM groups: one group comprising of three VMs, and the second one with single VM as shown in the following figure:

VMGrouping-VMStartOrdering-15

VMGrouping-VMStartOrdering-16

Get-VMGroup * | ft Name, VMMembers -AutoSize

VMGrouping-VMStartOrdering-08

With the two VM groups created, we can start interacting directly with WS-VM001, WS-VM002, and WS-VM003 virtual machines by utilizing “VMCLGR01” VM Group, and we can perform actions directed only at WS-VM002 by utilizing “VMCLGR02” VM Group.

In the following example, we will enable VM replication by utilizing VMCLGR01 VM Group:

# Enable VM Replication
Enable-VMReplication -VM (Get-VMGroup VMCLGR01).VMMembers -ReplicaServerName WS16TP5-HV02 -ReplicaServerPort 80 -AuthenticationType Kerberos `
 -CompressionEnabled 1 -ReplicationFrequencySec 30 -AutoResynchronizeEnabled 1 -Verbose

# Start VM Replication
Start-VMInitialReplication -VM (Get-VMGroup VMCLGR01).VMMembers -Verbose

# Get VM Group
(Get-VMGroup VMCLGR01).VMMembers | ft Name, State, Status, ReplicationMode, ReplicationHealth –AutoSize

VMGrouping-VMStartOrdering-09

VM Collection Groups are fairly simple. They maintain a membership of virtual machines, those VM groups contain actual VMs.

Management Collection Groups

The Management Collection Groups, on the other hand, maintain a membership of VM Collection Groups. Please note that VMs cannot directly belong to the membership of a management collection.

The group name for VM and Management collection groups might be confusing a little bit, in order to differentiate between both groups, we can refer to the collection group using the first name “VM” (membership of individual virtual machines), and “Management” (membership of VM groups).

The creation of Management collection groups is nearly identical to creating VM collection groups. The following Windows PowerShell script creates a new management group type “Management” and adds both of the existing VM groups “VMCLGR01” and “VMCLGR02” to it as shown in the following figure:

VMGrouping-VMStartOrdering-17

# Create new Management Collection Group
New-VMGroup -Name MGMTGR01 -GroupType ManagementCollectionType -Verbose

# Add VM Groups (VMCLGR01 and VMCLGR02) to the Management Group
Add-VMGroupMember -VMGroup (Get-VMGroup MGMTGR01) -VMGroupMember (Get-VMGroup VMCLGR01) -Verbose
Add-VMGroupMember -VMGroup (Get-VMGroup MGMTGR01) -VMGroupMember (Get-VMGroup VMCLGR02) –Verbose

VMGrouping-VMStartOrdering-10

In order to see the VM groups and their members, you can run the following script:

# Get-VMGroup, we can see now VM Groups (VMCLGR01 and VMCLGR02) are members of MGMTGR01 management group
Get-VMGroup MGMTGR01 | ft Name, VMGroupMembers -AutoSize

# Get-VMGroup and expand the VMGroupMembers
# We can see now the virtual machines which are members of VM Groups
Get-VMGroup MGMTGR01 | Select -ExpandProperty VMGroupMembers

VMGrouping-VMStartOrdering-11

As mentioned earlier, we can also nest a management collection group. In other words, nesting allows you to put a management group inside a management group.

This nesting capability opens an entirely new dimension in how you can organize VMs. VMs become objects that you can group much like host groups in Virtual Machine Manager.

In the following example, we will create a new management group named ParentMGTGroup and adds our first management group that we created above “MGMTGR01” to its membership as shown in the following figure:

VMGrouping-VMStartOrdering-18

VMGrouping-VMStartOrdering-12

If you want to delete the management collection group, you need to remove first the VM groups from the management collection and then delete the management group.

The following PowerShell script will allow you to do so:

# Remove VM Group Members from Management Collection
Remove-VMGroupMember -VMGroup (Get-VMGroup MGMTGR01) -VMGroupMember (Get-VMGroup VMCLGR01) -Verbose
Remove-VMGroupMember -VMGroup (Get-VMGroup MGMTGR01) -VMGroupMember (Get-VMGroup VMCLGR02) -Verbose
# Remove Nested Management Collection
Remove-VMGroupMember -VMGroup (Get-VMGroup ParentMGTGroup)  -VMGroupMember (Get-VMGroup MGMTGR01) -Verbose
# Remove Management Collection Groups
Remove-VMGroup -Name MGMTGR01 -Force -Verbose
Remove-VMGroup -Name ParentMGTGroup -Force -Verbose

VMGrouping-VMStartOrdering-13

VM Start Ordering

Virtual machine Start Order is a new feature introduced in Windows Server 2016 Technical Preview 5 Failover Clustering. VM Start Ordering opens an entirely new dimension in how you orchestrate Virtual machines (and all groups) in a cluster. Virtual machines can now be grouped into tiers, and start order dependencies can be created between different tiers. This ensures that the most important virtual machines (such as Domain Controllers or SQL servers) are started first.

As an example, most environments today do not have a single domain controller, they have multiple DCs. In this case, you probably want to group your domain controllers’ VMs into a Set, so it makes sense to group these domain controllers and have all the most important VMs to have a dependency on VM Set for domain controllers.

Another scenario could be a Hyper-Converged deployment (where compute and storage are sharing the same underlying hardware). In this case, you probably want to make sure the most important virtual machines are started before your management or tenant VMs are started.

In order to do so, we need to define the Sets first, place virtual machines in sets, and then specify dependencies.

VM Start Ordering Configuration

VM Start Ordering is still being developed and they are managed through Windows PowerShell only.

The following new PowerShell cmdlets have been added into the Failover Clusters module to manage the groupset and group set/dependencies.

At the time of writing, the cmdlets are divided into 3 groups:

# Managing Group Dependency
Add-ClusterGroupDependency
Get-ClusterGroupDependency
Remove-ClusterGroupDependency

# Managing Group Set
New-ClusterGroupSet
Remove-ClusterGroupSet
Set-ClusterGroupSet
Get-ClusterGroupSet
Add-ClusterGroupToSet
Remove-ClusterGroupFromSet

# Managing Group Set Dependency
Add-ClusterGroupSetDependency
Get-ClusterGroupSetDependency
Remove-ClusterGroupSetDependency

Simple Scenario

Let’s start with a simple scenario, If you just want to create a dependency between two virtual machines, you need to use the first set of cmdlets  (Managing Group Dependency). You need to use the Add-ClusterGroupDependency cmdlet to create a dependency between VM-A and VM-B. If you are familiar with creating dependencies between cluster resources today, this is exactly the same model.

Advanced Scenario

Let’s now look at a complex scenario and see how to create and manage advanced group Set dependencies with Windows PowerShell.

In the following example, we have a multi-tiered application that consists of two domain controllers, two SQL servers, two web servers, and two software load balancers.

The workflow will look something like this:

VMGrouping-VMStartOrdering-19

Step 1. We start by creating the Cluster VM Set for each tier by using the New-ClusterGroupSet cmdlet.

# Cluster Name
$ClusterName = "CN-CLU"

# Create new Cluster VM Set (DC)
New-ClusterGroupSet -CimSession $ClusterName -Name VMDCSET01 –Verbose

# Create new Cluster VM Set (SQL)
New-ClusterGroupSet -CimSession $ClusterName -Name VMSQLSET01 –Verbose

# Create new Cluster VM Set (IIS)
New-ClusterGroupSet -CimSession $ClusterName -Name VMIISSET01 –Verbose

# Create new Cluster VM Set (SLB)
New-ClusterGroupSet -CimSession $ClusterName -Name VMSLBSET01 –Verbose

# Get Cluster VM Set
Get-ClusterGroupSet -CimSession $ClusterName | ft Name, StartupConfig, StartupCount –AutoSize

VMGrouping-VMStartOrdering-20

As you can see in the above screenshot, the StartupConfig and StartupCount are set to the default properties.

Step 2. In the next step, we need to assign the right properties for each VM Set by using the Set-ClusterGroupSet cmdlet.

# Assign properties for your VM Set by using Set-ClusterGroupSet cmdlet
Set-ClusterGroupSet -CimSession $ClusterName -Name VMDCSET01  -ReadySetting OS_Heartbeat -ReadyCount 1 -Verbose
Set-ClusterGroupSet -CimSession $ClusterName -Name VMSQLSET01 -ReadySetting OS_Heartbeat -ReadyCount 2 -Verbose
Set-ClusterGroupSet -CimSession $ClusterName -Name VMIISSET01 -ReadySetting OS_Heartbeat -ReadyCount 3 -Verbose
Set-ClusterGroupSet -CimSession $ClusterName -Name VMSLBSET01 -ReadySetting OS_Heartbeat -ReadyCount 4 -Verbose

# Get Cluster Group Set Properties
Get-ClusterGroupSet -CimSession $ClusterName | ft Name, StartupConfig, StartupCount -AutoSize

VMGrouping-VMStartOrdering-21

The StartupConfig is set to the “OS_HeartBeat” property for each Set and StartupCount is set to sequence numbers from 1 to 4.

Step 3. We need to add virtual machine groups to the VM Set by using the Add-ClusterGroupToSet cmdlet.

# Add Cluster Group (VMs) to the Set by using Add-ClusterGroupToSet cmdlet

# Domain Controllers VMs
Add-ClusterGroupToSet -CimSession $ClusterName -Name VMDCSET01 -Group WS-DC01 -Verbose
Add-ClusterGroupToSet -CimSession $ClusterName -Name VMDCSET01 -Group WS-DC02 -Verbose
# SQL Servers VMs
Add-ClusterGroupToSet -CimSession $ClusterName -Name VMSQLSET01 -Group WS-SQL01 -Verbose
Add-ClusterGroupToSet -CimSession $ClusterName -Name VMSQLSET01 -Group WS-SQL02 -Verbose
# Web Server VMs
Add-ClusterGroupToSet -CimSession $ClusterName -Name VMIISSET01 -Group WS-IIS01 -Verbose
 Add-ClusterGroupToSet -CimSession $ClusterName -Name VMIISSET01 -Group WS-IIS02 -Verbose
# Software Load Balancers VMs
Add-ClusterGroupToSet -CimSession $ClusterName -Name VMSLBSET01 -Group WS-SLB01 -Verbose
Add-ClusterGroupToSet -CimSession $ClusterName -Name VMSLBSET01 -Group WS-SLB02 -Verbose

# Get Cluster Group Set Properties
Get-ClusterGroupSet -CimSession $ClusterName | ft Name, GroupNames, StartupConfig, StartupCount -AutoSize

VMGrouping-VMStartOrdering-22

Step 4. Once you have your VM group Set all setup, the final step is to create dependency between either a single VM or between a VM Group Set by using Add-ClusterGroupSetDependency cmdlet.

If you want to create a dependency for a single VM, then you want to create another group Set that has a single VM in it.

In our example here, we don’t have a single VM, so we will set the dependencies between different VM Sets.

# Creating dependency between VM Set by using Add-ClusterGroupSetDependency cmdlet
Add-ClusterGroupSetDependency -CimSession $ClusterName -Name VMSLBSET01 -ProviderSet VMIISSET01 -Verbose
Add-ClusterGroupSetDependency -CimSession $ClusterName -Name VMIISSET01 -ProviderSet VMSQLSET01 -Verbose
Add-ClusterGroupSetDependency -CimSession $ClusterName -Name VMSQLSET01 -ProviderSet VMDCSET01 -Verbose

# Get Cluster Group Set Properties
Get-ClusterGroupSet -CimSession $ClusterName | ft Name, GroupNames, ProviderNames, StartupConfig, StartupCount -AutoSize

VMGrouping-VMStartOrdering-23

As you can see in the above screenshot, the virtual machines groups “WS-SQL01, WS-SQL02 ” are dependent on DC VM Set “VMDCSET01”, the webserver VMs “WS-IIS01, WS-IIS02” are dependent on SQL Servers VM Set “VMSQLSET01”, and last but not least, the software load balancer VMs “WS-SLB01, WS-SLB02” are dependent on web servers VM Set “VMIISSET01”.

Summary

This is the first look at VM Groups and VM Start Ordering. You might notice some confusion around the PowerShell cmdlets for VM Start Ordering, I totally agree with this. The documentation is still very limited at this point in time. This is a brand-new feature and is still under development, I expect additional functionalities will be added in the future.

With VM Start Ordering, you have the ability to create a dependency between your special (most important) VMs and give us the ability to orchestrate the start ordering between all virtual machines in your cluster. It’s an orchestration of all the VMs in your entire cluster and not just a few VMs you have on a single node.

Do you want to learn about Windows Server Hyper-V, I highly encourage you to check the Windows Server Hyper-V Cookbook for in-depth details about Hyper-V and automation tasks.

As always, comments are welcome and encouraged. Is this something you would use? Do you have another scenario where you can see VM Groups and VM Start Ordering is useful?

__
Thank you for reading my blog.

If you have any questions or feedback, please leave a comment.

-Charbel Nemnom-

Photo of author
About the Author
Charbel Nemnom
Charbel Nemnom is a Senior Cloud Architect, Swiss Certified ICT Security Expert, Certified Cloud Security Professional (CCSP), Certified Information Security Manager (CISM), Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT). He has over 20 years of broad IT experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems with extensive practical knowledge of complex systems build, network design, business continuity, and cloud security.
Previous

Speaking at ITCAMP – Hybrid Infrastructure #AzureStack #Azure

Update Rollup 10 for System Center 2012 R2 is Now Available #SysCtr #SystemCenter #SCVMM

Next

1 thought on “A First Look at VM Groups and VM Start Ordering in Windows Server Hyper-V #HyperV”

Leave a comment...

Let me know what you think, or ask a question...

error: Alert: The content of this website is copyrighted from being plagiarized! You can copy from the 'Code Blocks' in 'Black' by selecting the Code. Thank You!