AntiAffinity Groups in Failover Cluster. Part 4

1 minute read

AntiAffinity

  • Part 1 covers some theory and GUI configuration.
  • Part 2 will focus on setting Preferred Owners with Powershell.
  • Part 3 will explain logic behind Possible Owners in PowerShell function.
  • Part 4 will cover the last step - setting anti-affinity groups.
  • Part 5 will describe reporting of current configuration in the cluster.

Today is a quick one - AntiAffinity groups.

General concept

There is no PowerShell cmdlet to set up Affinity Groups - like Set-ClusterOwnerNode. To achieve this I must alter a class property AntiAffinityClassNames with an array of strings. Each object represents an affinity group a VM belongs to. If two VMs share the same group - cluster service will try to keep them on separate nodes.

In short, this is all we need to check:

$VMName = 'Windows2016'
(Get-ClusterGroup -Name $VMName).AntiAffinityClassNames 

And to set a simple assignment:

(Get-ClusterGroup -Name $VMName).AntiAffinityClassNames = 'Template'

I’d like to be able to append new Groups if needed.

Full Script

Full script looks like this:

Sample output

Running PSCore 6.1 and targeting one vm on a cluster:

Set

Adding new AntiAffinityGroup to the same VM:

Add

Clearing all on 'windows2016':

Clear

Setting two VMs into same AntiAffinity Group:

Set2

Summary

This one can help in keeping certain VMs on separate nodes (Domain Controllers, VM Guest cluster nodes, etc.) Next we’re going to get some reporting for every setting we’ve configured so far!

Lego

Leave a comment