To identify the host on which the virtual machine runs, use one of these methods:
Method 1
Query the vCenter Server database in MSSQL:
-
Log in to to the Microsoft SQL 2005/2008 Server as an administrator.
-
Open SQL Management Studio.
-
Right-click the database that vCenter Server is using.
- Open a new query window and ensure that the vCenter Server database is selected.
- Run this SQL statement :
SELECT vpxv_vms.vmid, vpxv_vms.NAME, vpxv_vms.hostid, vpxv_hosts.NAME
FROM vpxv_vms
JOIN vpxv_hosts on VPXV_VMS.HOSTID = VPXV_HOSTS.HOSTID
WHERE (
(vpxv_hosts.hostid = vpxv_vms.hostid)
AND (vpxv_vms.NAME = 'virtual_machine_name')
)
This query returns the virtual machine ID, virtual machine name, host ID, and host name.
Method 2
Review the latest vmware.log file for the virtual machine:
- Open an SSH session to an ESX/ESXi host that has access to the shared storage (datastores) for the environment in which the virtual machine resides. For more information, see Connecting to an ESX host using a SSH client (1019852) or Using Tech Support Mode in ESXi 4.1 and ESXi 5.x (1017910).
- Find the working directory for the virtual machine using one of these commands:
- grep -i <virtual_machine_name> /vmfs/volumes/*/*/vmware-*.log
- find /vmfs/volumes/ -name *.vmx | less
- After locating the working directory of the virtual machine, check the latest vmware.log file and do the following steps on each Esxi host:
- Go to the working directory of the Virtual machine.
- grep -i hostname vmware.log to determine the host on which the virtual machine is running
On the host where the VM allocated and running, you see an entry similar to:
2012-10-10T02:04:01.999Z| vmx| Hostname=name_of_host
On the other Esxi hosts, you see an entry similar to; Vmware.log: Device or resource busy
Note: The host where the VM is running lock the vmware.log file and VM_name.vmx file, trying to access these files from another Esxi host will return error with device busy that's The previous steps should be run one each host.