anti affinity hyper-v 2019

matteu31 467 Reputation points
2022-04-19T16:42:27.587+00:00

Hello,

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
$AntiAffinity.Add("DC")
(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

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

2 answers

Sort by: Most helpful
  1. Matej Jenko 0 Reputation points
    2024-03-14T07:20:43.63+00:00

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

    Regards


  2. Eric Siron 1,256 Reputation points MVP
    2024-03-19T13:40:10.8466667+00:00

    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