Monday, November 26, 2012

Kill a VM (The HARD way)!!

Use this method only after you have tried every other method.

If you have a VM that will not power off or reboot first attempt all of the following methods to shutdown the VM:

  • Shutdown in vCenter
  • Connect vCenter client to host and shutdown
  • Perform a Stop-VM command in Powershell
    • Stop-VM -VM -Kill -Confirm:$false


If after all of these methods fail you can still power down a VM by killing the WorldID on the ESXi hosts

1.  SSH into the host
2. Get a list of all running VMs

  • esxcli vm process list

3. Once you have found your VM document is World ID
4. Issue the following command to kill the VM

  • esxcli vm process kill --type=[soft,hard,force] --world-id=WorldNumber
    • This command may require the --type=hard option to be successful.

Wednesday, November 14, 2012

Remove an inactive datastore from the vCenter Server inventory



This issue may occur if the datastore was removed from the ESX host before removing it from the vCenter Server Inventory.

To resolve this issue, you must manually remove the datastore references from the vCenter Server Inventory.

To manually remove the datastore references from the Inventory:

Notes:
  • Back up the database before proceeding.
  • Ensure that the datastore is not referenced by any virtual machine.
  1. Stop the VMware VirtualCenter Server service on the vCenter Server. 
  2. Launch SQL Management studio connected to the vCenter Server database.
  3. Run this query to identify the datastore ID in the vCenter Server database:

    select ID from VPX_ENTITY where name ='';
    Where  is the datastore to be removed. The query returns the ID of the datastore.
  4. To remove the datastore from the vCenter Server database:

    1. Run these queries to delete the datastore from the VPX_DS_ASSIGNMENT and VPX_DATASTORE tables:

      delete from VPX_DS_ASSIGNMENT where DS_ID=;
      delete from VPX_VM_DS_SPACE where DS_ID=;
      delete from VPX_DATASTORE where ID=;
      Where  is the output of Step 3.
    2. Run this query to delete the datastore from the entity table:

      delete from VPX_ENTITY where ID=;
  5. Run these queries to verify if the datastore has been removed from the VPX_ENTITYVPX_DS_ASSIGNMENT, andVPX_DATASTORE tables:

    Note: If the datastore references are successfully removed, these queries do not display any results.

    select * from VPX_DS_ASSIGNMENT where DS_ID=;
    select * from VPX_VM_DS_SPACE where DS_ID=;
    select * from VPX_DATASTORE where ID=;
    select * from VPX_ENTITY where ID=;
  6. For the database changes to take effect, restart the VMware VirtualCenter Server service on the vCenter Server.