Configuring vSphere 4.1 VM to Host DRS Affinity Rules
VMWare vSphere’s DRS (Distributed Resource Scheduler) is mainly used for load balancing virtual machines (VMs) on a cluster. While most virtualization admins will want to run DRS in fully automated mode – i.e., vSphere decides on its own which VM is assigned to which ESX Server – there may be certain instances when you would want to enforce some conditions by setting what are known as DRS Affinity Rules.
Note that while there are two types of DRS Affinity Rules, the other one being VM to VM, this article focuses on VM to Host Affinity Rules, a feature which has just been introduced in vSphere 4.1. These rules allow you to take individual VMs or Groups of VMs and assign them to individual ESX Servers or Groups of ESX Servers.
Read the Best Personal and Business Tech without Ads
Staying updated on what is happening in the technology sector is important to your career and your personal life but ads can make reading news, distracting. With Thurrott Premium, you can enjoy the best coverage in tech without the annoying ads.
(Instructional video below provides a walkthrough of the steps contained in this article.)
Instances wherein you would want to enforce DRS Affinity Rules
So what are some of those instances wherein you would want to dictate which VM or VMs should (or should not) be assigned to a particular ESX Server or group of ESX Servers?
Some applications running on your VMs may have licensing peculiarities such as:
- Those that require the application to be run on only one CPU; a restriction that can have complications if you have a single-CPU server along with a bunch of dual-CPU servers.
- Those that restrict the application to one specific server with a specific serial number.
You might want to prevent a group of VMs from running on particular ESX servers.
You might want to assign some VMs to your newly acquired multiple-CPU server.
How to configure VM to Host DRS Affinity Rules
Let’s now proceed to see how you can keep a single VM or a group of VMs to either a single ESX server or a group of ESX servers.
Open your vSphere Client and find the cluster on which the rules will be enforced.
In the screenshot below, we’ll be enforcing the rules on DRS Cluster 1, which contains four ESX servers and a bunch of virtual machines.
Right-click on the cluster in question and, in the corresponding context menu, select Edit Settings.
First, we’ll create a Virtual Machines DRS Group and assign virtual machines to it.
To do that, go to the left-hand-side panel and select DRS Groups Manager. Next, go to the Virtual Machines DRS Groups panel and click that panel’s Add button.
You can now select VMs that you’d like to add to your VM group.
Click the “>>” button to add the selected VMs to the VM group. Once you’re done, give your group a name (e.g. vCenter-VM-Group), then click the OK button.
Back at the DRS Groups Manager, you can then create a Host DRS Group. This is the host DRS group where you’ll be assigning your newly created virtual machines DRS group.
Go to the Host DRS Groups panel and click the corresponding Add button.
You’ll then see a similar window as the one where you added VMs to a group (see two screenshots back). Just like what you did with the VMs, select hosts that you want to add to the host DRS group and click the “>>” button.
Note: Assigning the VM group to a host group is optional. It is possible to assign your VM group to a single host or ESX server.
Now, give the host group a name (e.g. ESX-DR-Group-1) and click the OK button.
So now you have both a Virtual Machines DRS Group and a Host DRS Group. Notice that the screenshot below shows the DRS Groups Manager tab. This is also exactly what you’ll see if you select the DRS Groups Manager in the left-hand-side panel.
Create DRS Affinity Rule
You are finally ready to create your DRS Affinity Rule. Click the Rule tab and come up with a name for your rule (e.g. Pin-vCenter-VMs-to-ESX-Group-1).
Now, for the following drop-down lists, select the following items:
- Type = Virtual Machines to Hosts
- Cluster VM Group = the Virtual Machines DRS Group you created (e.g. vCenter-VM-Group)
- Cluster Host Group = the Host DRS Group you created (e.g. ESX-DR-Group-1). This is where the VM group is supposed to run.
Notice that we skipped one drop-down list. In the screenshot, it’s the one that says “Must run on hosts in group”. That drop-down list is where you’re supposed to select the actual rule that will apply to the VM group-host group pair.
Expand that list, select the rule you wish to implement, and click OK.
That should create your VM to Host DRS Affinity Rule.
You’ll see something like this (see screenshot below) in the succeeding window. You’ll have to click the “+” symbol to expand the VM to Host Rule and reveal the corresponding Cluster VM Group and Cluster Host Group on which the rule will apply.
That’s it. You have just created a vSphere 4.1 VM to Host DRS Affinity Rule.