How to configure Affinity and Anti-affinity rules for VMWare DRS
Affinity Rule – VM to Host
Step 1:
To configure VM to Host affinity rule, login to vCenter Server, right click on the VMWare Cluster and then click on the “Edit Settings”.
Step 2:
On the Cluster Settings, select “DRS Groups Manager” and click on Add to create new VM DRS Group.
Step 3:
Specify the DRS Group Name and select the servers that you want to add in this DRS Group and then click on OK.
For this practical, we’ll define the DRS Group name as VMDRSGrp and add Node01 and Node02 in this group.
Step 4:
Click on Add to create new Host DRS Group.
Step 5:
Select the ESXi Server and click on right arrow to add the VMWare ESXi Server in the VMWare Host DRS Group.
Click on Ok to create the Host DRS Group.
Step 6:
To create VM to Host affinity rule, click on Rules and then click on Add.
Step 7:
On the Rules tab, specify the name of rule. For this tutorial, we have defined the name as VM2H.
Select the type, we have defined the type “Virtual Machines to Hosts”.
Select the VM Cluster Group i.e. DRSGrp
Select the option “Must run on hosts in group or Should run on hosts in group”. For this practical, we’ll select the option “Must run on hosts in group”.
Select the Cluster Host Group i.e. DRSHost that we created.
Click on OK to create the rule.
Step 12:
As per the rule, Node01 and Node02 which are part of DRSGrp must run on ESX01 server which is part of DRSHost cluster Host group.
Step 13:
Node01 and Node02 are currently running on ESX01. If we try to vMotion Node01 to ESX02 then we’ll see an error message “Virtual Machine ‘Node01’ on host ‘esx02.itingredients.com’ would violate a Virtual Machine- host affinity rule”.
Hope you understood the steps to create and configure affinity and anti-affinity rules for DRS. Please feel free to leave your comments and suggestions in the comment box.