Today a customer asked me about a specific issue he has in his vSphere environment. They are running a VM that monitors network traffic and they want to make sure the VM is running on esx-1 unless esx-1 goes into maintenance mode.
Easiest way to do this would be to place the VM on host-1 and exclude it from DRS. The problem however is that the VM will not be VMotioned to another host when esx-1 is put into maintenance mode and it will stop the host from entering maintenance mode. Before vCenter 4.1, there would be no other way than to just exclude the VM and VMotion it by hand before entering maintenance mode.
Now in vCenter 4.1, we have DRS Host groups that can help us in this scenario. First create a host group called: HST-Esx-1 and only add the host Esx-1 to this group. Next create a VM group called: VM-NetworkMonitor and only add the VM called NetworkMonitor to this group
Now create a DRS rule of the type “Virtual Machines to Host” and use the two groups you just created and use the policy “Should Run”. For an in-depth explanation of “Should Run” and “Must Run” see Frank Denneman’s blog post: SHOULD OR MUST VM-HOST AFFINITY RULES?
Now with this DRS rule in place, your VM will run on esx-1 and can still be evacuated in case esx-1 has to go into maintenance mode.
13 thoughts on “How to pin a VM to single host and still be able to enter maintenance mode”
Keep in mind though that it is “SHOULD” and not “MUST” so there are situations where this rule will be violated if and when needed.
But that was exactly what i needed ! :-))
But the requirement is the following:”They are running a VM that monitors network traffic and they want to make sure the VM is running on esx-1 unless esx-1 goes into maintenance mode.”
But with a should rule you cannot guarantee that is the case. After you exit maintenance mode it is not guaranteed that the VM will migrate back, so you still might need to manual move it, which brings you back to more or less the same situation.
Copied from Frank’s post:
“How does DRS treat preferential rules?
During a DRS invocation, DRS runs the algorithm with preferential rules as mandatory rules and will evaluate the result. If the result contains violations of cluster constraints; such as over-reserving a host or over-utilizing a host leading to 100% CPU or Memory utilization, the preferential rules will be dropped and the algorithm is run again.”
Yes, it is possible the VM gets moved by DRS even without maintenance mode being the trigger. That is why I referred to Frank’s post to find a clear explanation of the impact of Should and Must.
so I thought DRS will ensure that VM back its initial host (as rule was defined)… so having that rule won’t assure you it will do what you need…does it mean in the scenario below I should tell the customer you konw keep that VM DRS disabled and move it according to your needs…because you might be surprised
While I was reading this I thought DRS will free up resources (in case Host was saturated) to apply that should rule
Hi, thanks for the info, but is there any way to do it on version 4.0?
We have a VM that uses CPUID for licensing, I’ve disabled DRS for it on our cluster. But every time I do maintenance, I shutdown the VM and put the ESX host to maintenance and after I exit the maintenace mode, the VM turns on on another ESX host. I’m not sure how it turns up on another ESX host and even if it shows up there can I set some prefrences to move the VM to the original ESX host.
Your help is much appreciated.
There is no real way in vCenter 4.0 to keep the VM pinned to a certain host. You can maybe write a PowerShell script that moves the VM to the correct host.
any idea what may use vSphere Standard license owners where there is not DRS and they want to stick some VMs to some hosts (MS Licensing limitations) in the HA Cluster?
any ideas are WELCOME
just to know,Can you explain what exactly is the constraint of MS licensing in your scenario.
Just in case we come across this kind of query, in our infrastructure.
Comments are closed.