Administering DRS and Storage DRS

by admin

This post will look at the VCAP-DCA objective around administering DRS and SDRS. I’ve previously written posts on creating DRS clusters and creating datastore clusters, so there will be some overlap with those topics here.

There are a number of tasks you should be familiar with. These include:

  • Adding and removing hosts from a cluster
  • Configuring EVC
  • Configuring DRS Affinity Rules

I talked about adding hosts to clusters in this post, however it’s worth mentioning here that if you need to remove a host from a cluster then you must put the host into maintenance mode. If you try and move a host out of a cluster without putting it in maintenance mode first you will receive an error:


Once it has been placed in maintenance mode, you will be able to move the host out of the cluster or remove it from vCenter entirely if required. You can accomplish the same by using PowerCLI. To place the host in maintenance mode you can run:

PowerCLI C:\Temp> set-vmhost -VMHost esxi2.vmlab.loc -State Maintenance

Then to move it out of the cluster you can run:

PowerCLI C:\Temp> Move-VMHost -VMHost esxi2.vmlab.loc -Destination VMLAB

Name                 ConnectionState PowerState NumCpu CpuUsageMhz CpuTotalMhz   MemoryUsageGB   MemoryTotalGB Version
----                 --------------- ---------- ------ ----------- -----------   -------------   ------------- -------
esxi2.vmlab.loc      Maintenance     PoweredOn       2          57        6184           0.977           4.000   5.1.0

Finally, you can take it out of maintenance mode with:

PowerCLI C:\Temp> set-vmhost -VMHost esxi2.vmlab.loc -State Connected

DRS Affinity Rules

I’ve written about DRS affinity rules before, without going into detail on how to configure them. Affinity rules settings can be found in the cluster’s settings under ‘rules’:


As previously discussed, there are two types of DRS Affinity rules:

  • VM-VM affinity
  • VM-Host affinity

The first step to configuring VM-Host rules is to configure groups using the DRS Groups Manager:


We can use the DRS Groups Manager to define groups of hosts and virtual machines that we can then refer to when creating the affinity rules. In the example above, I have created a VM group that contains a single virtual machine, and two host groups, each containing one ESXi host in the cluster. We can then create the rule as follows:


You can test the rule by attempting to vMotion the virtual machine to a host that would violate the rule. If it’s configured correctly, you should receive an error:


Because we specified a ‘must’ rule, DRS will not let us move the virtual machine to a host that would violate the rule. If we changed it to a ‘should’ rule, we will be able to migrate the VM, however DRS will generate a recommendation to move the VM back to a host defined in the rule:


VM-VM Affinity rules don’t require DRS groups to be created, you can simply list the virtual machines and decide whether you want to keep VMs together or apart:


Remember that if you have conflicting rules, older rules will take precedence.

As with other cluster features, you can also work with DRS rules using PowerCLI. For example, to list the DRS rules configured on a cluster you could run:

PowerCLI C:\Temp> get-drsrule -cluster CLUSTER01

Name                                Enabled Type            VMIDs
----                                ------- ----            -----
Keep VMs Together Rule              True    VMAffinity      {VirtualMachine-vm-306, VirtualMachine-vm-312}
Keep up to date with new posts on - Follow us on Twitter:
Be Sociable, Share!

Leave a Comment


Previous post:

Next post: