Labels

Thursday, June 23, 2011

How to Reregister Orphaned VMs


I'm not sure what causes orphans but suspect it might be a problem with VMotion where a particular VM gets registered on 2 hosts at the same time.
To check to see if a VM is indeed registered on 2 hosts, open a console session on each host in the farm and run the command:
vmware-cmd –l|grep –I <vmname>
Sample command and output:
 [root@Host1]# vmware-cmd -l|grep -i testvm1
/vmfs/volumes/48ce9a7e-753f5e09-1ba1-001925720534/testvm1/testvm1.vmx
As in the above example, if you receive the location of the VM’s vmx file you know the VM is registered to the given host.  If however, you run the command and receive no output then you know the VM is not registered to the host.  If a VM is registered to 2 different hosts, follow the procedures below.
First, in Virtual Center set DRS to Manual for the cluster that the host belongs to.  Right-click on cluster name Production, select Edit Settings then VMWare DRS, then change setting to Manual.
Next, remove one of the hosts from the farm where the orphaned VM was registered.  Even when the host is out of the farm the VMs will continue to run.  So, from Virtual Center (VC) right-click on the host name and select Disconnect.  Once that is complete, right-click the host and select Remove.  Removing a host from the farm will give you a more accurate view of the VMs running on the host when you logon to the host directly. 
Now, using the VI Client, logon to the host you removed from the farm.  Compare the VMs shown running on the host in the VI Client to what is shown in VC.  If the orphaned VM is shown to be running on the host but in VC is shown to be on a different host, follow the steps below.  (If the VM is not running on the host, close the VI Client, add the host back to the farm then remove the second host from the farm where the VM was shown to be registered. )
Next, after finding the host where the VM is actually running, remove that VM from inventory in VC.  Then add the host back to the cluster.  Finally, open a console session to the host and run the following command:
                service vmware-vpxa restart
This will restart the vmware-vpxa service which the host uses to communicate with Virtual Center.  Restarting the service will not negatively affect the VMs running on the host.  After a couple minutes the orphaned VM should show up running on the correct host in VC.  Once you’re finished fixing the VM make sure to switch the DRS service back to automatic for the cluster.

No comments:

Post a Comment