I have a situation where I have 5 hosts in a cluster and 10 VMs I need to separate. I don't want any more than 2 VMs running on the same host. I created 2 "Separate VMs" rules. One with the odd VMs and one with the even VMs. In theory, this should put, one even VM and one odd VM on each host. If we end up with 11 VMs then, it might be an issue but, of now, it's fine.
What happens if we have and HA event? Am I going to get a "Violates affinity rule" error when it powers up the VM on the other hosts or, do HA events override DRS rules?
If I uses groups instead and setup a "Should run on these hosts" rule, does that change things?
If I setup group A with odd VMs and Group B with even VMs and a host group with all the hosts in it, there is nothing that says all the VMs in group A should run on different hosts.
HA now respects DRS affinity rules. If you configure the rule to "must" run on host(s), HA will prevent the VM from being started if it cannot find an allowable host. If you configure the rule to be "should" then it will allow the rule to be violated so HA can power up the VM, then it will be migrated back to an acceptable host.
Thank you. That's kind of what I thought. So, if I have to do a "should" in order to not break HA, I wish I could also do a "Separate" too.
Seems like DRS affinity rules needs a "Best effort" option. Run these VMs on separate hosts if you can. If there's 6 VMs but 5 hosts well, 2 VMs will have to run on one host. If a host goes down then 3 VMs may have to run on a host.
Yes, do "VM to Host" affinity groups, that is what it is for. Use the should rule so that in the case of an HA scenario the rule is overruled.
Some add. Infos
- The default behaviour changed between vCenter/vSphere Versions
- For a short period of time there was a Option in the WebClient for configure this. Dont know where its located in HTML5 GUI
- Luke, use the adv. HA Options!
das.respectVmHostSoftAffinityRules true|false
das.respectVmVmAntiAffinityRules true|false
Regards,
Joerg
So, if I just use a regular affinity rule that says keep VMs on separate hosts then add "das.respectVmVmAntiAffinityRules false", that will allow HA to restart a VM on any host? Because, that would be exactly what I'm looking for. Keep the VMs on separate hosts unless something more important (An HA event) prevents you from doing that.
das.respectvmvmantiaffinityrules really is a great find. I found this article:
It says:
das.respectvmvmantiaffinityrules | Determines if vSphere HA enforces VM-VM anti-affinity rules. Default value is "false", whereby the rules are not enforced. Can also be set to "true" and rules are enforced (even if vSphere DRS is not enabled). In this case, vSphere HA does not fail over a virtual machine if doing so violates a rule, but it issues an event reporting there are insufficient resources to perform the failover. |
I read this as "in an HA event, your affinity rules go out the window". Does anybody else read it like that? I wish I had somewhere to test this.
if rule configure as must this will make VM to shutdown with host
rule (Must not run on hosts in group. Virtual machines in VM Group 1 must never run on host in Host Group A) in this case the VM will not restart on any other host and will still shutdown until host came back or powered on
if Rule configured as should Rule example
(Should not run on hosts in group. Virtual machines in VM Group 1 should not, but might, run on hosts in Host Group A.)
in this case the Vm can restart on any other host