When it comes to the logistics of a host failure, there is nothing special about the virtual machine recovery process with vSphere HA when combined with ActiveCluster. vSphere HA finds a host that has access to the storage of the failed virtual machines and restarts it. That process is no different.
With that being said, it might be desirable to help vSphere HA choose what host (or hosts) to restart recovered VMs on. Since ActiveCluster can present the same storage in two separate datacenters and vMSC allows for hosts in separate datacenters to be in the same cluster, a recovered virtual machine could be on a host in datacenter A that then fails and be restarted on a host in datacenter B. Even though there are healthy any available hosts in datacenter A still left in that cluster.
There is nothing intrinsically wrong with that, but due to application relationships it might be preferential to keep certain VMs in the same physical datacenter for performance, network, or even business compliance reasons.
vSphere HA offers a useful tool to make ensuring this simple—VM/host affinity rules.
VM/host affinity rules allow the creation of groups of hosts and groups of VMs and rules to control/dictate their relationships. In this scenario, I have 10 hosts. 5 in datacenter A and 5 in datacenter B.
Click on the cluster object in the inventory view, then the Configure tab followed by VM/Host rules in the side panel that appears. Click on the Add button to create a host group.
In the window that appears, assign the host group a name and choose the type of Host Group. Then click Add to add hosts.
Select the hosts that are in the same datacenter and click OK.
Confirm the configuration and click OK.
Repeat the process for the hosts in the other datacenter by putting them in their host group, in this case, datacenter B.
The next step is to create a VM group. Create as many VM groups as needed, but before their creation, keep in the mind the types of rules that can associated with VM and host groups:
- Keep all VMs in a group on the same host—this makes sure that all VMs in a given VM group are all on the same host. This is useful for certain clustering applications or for possible multi-tenant environments where VMs must be grouped in a specific way.
- Keep all VMs in a group on separate hosts—this makes sure all VMs in a group are never run on the same host. This is useful for clustered applications to survive a host failure (i.e. not-all-eggs-in-the-same-basket) or possibly performance sensitive applications that use too many resources to ever be on the same host.
- Keep all VMs on the same host group—this is a bit more flexible. This allows for VMs in a group to be required to be on a specific host group, or to never be on a specific host group. It also offers the ability to set preference with “should” rules. Rules can be set that they “should” be on a specific host group or they “should not” be on a specific host group. When a “should” rule is created, vSphere will always use the preferred host group if one or more of those hosts are available. If none are, then and only then will it use non-preferred hosts. If a “must” rule is selected, then in the absence of a preferred host in the host group, the VMs in the VM group will not be recovered automatically.
- Boot one group of VMs up prior to booting up a second group of VMs—this allows some priority of rebooting. This is useful if certain VMs rely on applications in other VMs. If those applications are not running first, the dependent VMs will either fail to boot, or its applications will fail to start. This is common in the case of database servers, application servers or services like DNS or LDAP.
BEST PRACTICE: When creating host affinity rules, it is generally advisable to use a “should” or “should not” rule over a “must” or “must not” rule as a “must” rule could prevent recovery.
With these in mind, VM groups can be created. In this environment, all four of the eight VMs will be put into the VM group A and four will be put in group B. To do this, click on the Add button in VM/Host Groups like shown earlier for the host groups.
Assign the group a name, choose VM group as the type and then click Add to select VMs.
Click OK and then OK again to create the VM group. Repeat as necessary for any VM groupings that are needed.
Note that VMs can be placed into more than one group—though it is recommended to keep VM membership to as few groups as possible for ease of rule management.
One VM groups and/or host groups have been created, rules can also be specified. To create and assign a rule, click on the VM/Host Rules section under the cluster Configure tab. Click Add to create a new rule.
Give the rule an informative name and choose a rule type, the definitions of which are described earlier in this section.
Depending on the chosen rule type, the options for the rule are different. In the above example, VMs in group A should be put on hosts in group A. Since the “should” rule was chosen, it could be broken in the case that no hosts in group A are available.
In the above environment, a second rule was created to keep VM group B VMs running on host group B hosts. Since this environment has vSphere DRS enabled and set to automatic, DRS automatically moved the VMs to the proper hosts as soon as the rule was committed.
Creating VM and host affinity rules provides the administrator with more direct and proactive control in preparation for an outage and subsequent HA and DRS VM placement response.