25 Jul 2011

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.

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?

Licensing Issues
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.

Availability Requirements
You might want to prevent a group of VMs from running on particular ESX servers.

Performance Requirements
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.

DRS Affinity Rules on vSphere 4.1: vSphere Client

Right-click on the cluster in question and, in the corresponding context menu, select Edit Settings.

Configuring DRS Affinity Rules on vSphere 4.1: vSphere Client

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.

VMware DRS Groups Manager

You can now select VMs that you'd like to add to your VM group.

VMware DRS Groups Manager

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.

Host DRS Affinity Rules on vSphere 4.1

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.

VMware DRS: Add Host Group

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.

VMware DRS: Add Host Group

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.

DRS Groups Manager

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.

Create DRS Affinity Rule

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.

Create DRS Affinity Rule

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.

VM to Host DRS Affinity Rule

That's it. You have just created a vSphere 4.1 VM to Host DRS Affinity Rule.

No comments:

Post a Comment