Operational Hint - Pin vCenter to a Host

If you’re hosting your vCenter VM in a DRS enabled cluster, there’s a handy trick that some new admins might not know, but I find super helpful (all the old school admins will nod knowingly how handy this can be). Let’s say you have a cluster with a bunch of hosts in it, and DRS is enabled in fully automated mode. The vCenter VM might be running on any one of these hosts, which is usually fine, but what happens if vCenter itself goes down? How would you quickly identify which host was running the vCenter VM if you can’t log into the vSphere Client? You need to get vCenter up and running again quickly right?

The trick is to pin the vCenter VM (and maybe the PSC VM if you’re running an external PSC) to the first host in the cluster using DRS Groups and VM-Host rules. If you’re unfamiliar with how to do this, it’s pretty simple.

DRS Groups and VM-Host Rules - vSphere Client

Create the Host Group

  1. If it is not already running, open a browser and connect and login to the vSphere (Web) Client on your vCenter Server. DRS and DRS rules cannot be managed when connected to a specific ESXi host; you must connect to a vCenter Server instance.
  2. Navigate to the Hosts and Clusters view.
  3. Select a cluster from the inventory. On the actions menu, select the Settings option or select the Configure tab in the content area.
  4. Click the VM/Host Groups option.
  5. Click the Add button in the VM/Host Groups to create a Host Group.
  6. On the Create VM/Host Group provide a Name for the Group “FirstHost” and select Host Group for the group Type. By default, VM Group will be selected.
  7. Click the Add button to add the host (or 2) as members of the Host Group. Simply select the check box for the host you want to add as a member. Use the filter option to search for specific hosts.
  8. Click OK.
  9. Review the new VM/Host Group configuration and click OK.

Create the VM Group

  1. Click the Add button in the VM/Host Groups to create a VM Group.
  2. On the Create VM/Host Group provide a Name for the Group “vCenterVM” and select VM Group for the group Type.
  3. Click the Add button to add the vCenter VM (and PSC if you wish) as members of the VM Group. Simply select the check box for the VM you want to add as a member. Use the filter option to search for specific VMs.
  4. Click OK.
  5. Review the new VM/Host Group configuration and click OK.

Create the VM/Host Rule

Once you have your Host and VM Groups created it’s time to create the VM/Host Rule to Pin the vCenter VM to the first host(s) in the cluster.

  1. Click the VM/Host Rules option.
  2. Click the Add button in the VM/Host Rules.
  3. On the Create VM/Host Rule provide a Name for the rule “vCenter to First Host” and select Virtual Machines to Hosts for the rule Type. By default, Keep Virtual Machines Together will be selected. Ensure the Enable Rule checkbox is ticked.
  4. Select the VM Group that you created earlier “vCenterVM”.
  5. Select Should run on hosts in group. (Don’t use must rules for this, as you don’t want to run into a situation where vCenter has no host to run).
  6. Select the Host Group that you created earlier “FirstHost”.
  7. Click OK.
  8. Review the new VM/Host Rule configuration and click OK.

DRS Groups and VM-Host Rules - PowerCLI

Here’s an example on how to create the above example using PowerCLI

New-DrsClusterGroup -Name FirstHost -Cluster sfo01-m01-mgmt01 -VMHost sfo01m01esx01.rainpole.local
New-DrsClusterGroup -Name vCenterVM -Cluster sfo01-m01-mgmt01 -VM sfo01m01vc01.rainpole.local
New-DrsVMHostRule -Name 'vCenter to First Host' -Cluster sfo01-m01-mgmt01 -VMGroup vCenterVM -VMHostGroup FirstHost -Type ShouldRunOn

Thats it! Now DRS will move your VMs around as normal, but it will always try to keep the vCenter VM on the first host. Using this trick, you will always know where to first look, when hunting for that VM to get you back up and running as soon as possible.

 
comments powered by Disqus