다음을 통해 공유


Windows: FailoverCluster AntiAffinity

AntiAffinity is a means in Microsoft FailoverClustering to influence how resources are failed over. Assume you have a 3 node cluster. In this cluster, you run 2 VMs serving as Domain Controllers. Ideally, you always want those two DCs running on different nodes, so in case of a failure, there is always one of those DCs available. If you assign both VMs the same AntiAffinityClassNames, the cluster will try to restart those VMs on different nodes in case of a failure. Trying to configure this with preferred owner would not achieve this.

There is no option to configure this using the GUI, however, you can configure it using PowerShell. While on a node of the cluster, you can check if already AntiAffinity values are defined using:

Get-ClusterGroup | Select Name, AntiAffinityClassNames

This also gives you the resource names you can assign values to. Next you have to create the collection of strings you want to use to identify your AntiAffinity Group:

$AntiAffinityCollection = New-Object System.Collections.Specialized.StringCollection
$AntiAffinityCollection.Add("myDomainControllers")

Note that you can assign more than one AntiAffinity group. For example, you could also add "myDFSNameservers" if there are servers that have multiple roles you want to have separated.

Now you can assign this StringCollection to the AntiAffinityClassNames property:

(Get-ClusterGroup -Name "mydc01.mydomain.local").AntiAffinityClassNames = $AntiAffinityCollection
(Get-ClusterGroup -Name "mydc02.mydomain.local").AntiAffinityClassNames = $AntiAffinityCollection

Note that this overwrites already set values, so if you already had AntiAffinityClassNames configured, you'll have to read out those values and add them to the Collection before setting them.