anti affinity hyper-v 2019

matteu31 467 Reputation points


I setup a new Hyper-v 2019 cluster 2 nodes and build anti affinity rules but it's not working. Is there any special requirements or limitations ?

VM stay on the same node.

I use microsoft documentation :

$AntiAffinity = New-Object System.Collections.Specialized.StringCollection
(Get-ClusterGroup -Name "DC1").AntiAffinityClassNames = $AntiAffinity
(Get-ClusterGroup -Name "DC2").AntiAffinityClassNames = $AntiAffinity

I can see both DC1 and DC2 with DC anti affinity group DC with the following command
Get-ClusterGroup | fl AntiAffinityClassNames

A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,597 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Matej Jenko 0 Reputation points

    Got any luck with this? It's not working for me neither.


  2. Eric Siron 1,256 Reputation points MVP

    Anti-affinity doesn't automatically migrate VMs out. It tries to prevent them from migrating to the same node during failover. It's kind of a useless feature in a two node cluster.

    For the record, since this seems like we're talking about domain controller VMs, I recommend storage migrating the first DC to local storage on the first node and the second DC to local storage on the second node, removing them both from the cluster, and setting them both to auto-start with a delay of 0. You don't need every DC online all the time and AD replication works perfectly. In addition to making the anti-affinity into a non-issue, this also gives you domain controller resiliency if something goes wrong with the cluster.

    0 comments No comments