Determining the virtual machine's location
Determine the host on which the virtual machine is running. This
information is available in the virtual machine's Summary tab
in VI Client. Subsequent commands will be performed on, or remotely reference,
the ESXi host where the virtual machine is running.
Using the ESXi esxcli command to power off a virtual machine
The esxcli command can be used locally or remotely to power off a
virtual machine running on ESXi 5.x or later.
1.
Open a console session where
the esxcli tool is available, either in the ESXi Shell, the vSphere
Management Assistant (vMA), or the location where the vSphere Command-Line
Interface (vCLI) is installed.
2.
Get a list of running virtual
machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file by running this command:
esxcli vm process list
esxcli vm process list
3.
Power off one of the virtual
machines from the list using this command:
esxcli vm process kill --type= [soft,hard,force] --world-id= WorldNumber
Notes:
Three power-off methods are available. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.
Alternate power off command syntax is: esxcli vm process kill -t [ soft,hard,force] -w WorldNumber
esxcli vm process kill --type= [soft,hard,force] --world-id= WorldNumber
Notes:
Three power-off methods are available. Soft is the most graceful, hard performs an immediate shutdown, and force should be used as a last resort.
Alternate power off command syntax is: esxcli vm process kill -t [ soft,hard,force] -w WorldNumber
4.
Repeat Step 2 and validate that
the virtual machine is no longer running.
For ESXi 4.1:
1.
Get a list of running virtual
machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file by running this command:
esxcli vms vm list
esxcli vms vm list
2.
Power off one of the virtual
machines from the list by running this command:
esxcli vms vm kill --type= [soft,hard,force] --world-id= WorldNumber
esxcli vms vm kill --type= [soft,hard,force] --world-id= WorldNumber
Using the ESXi command-line utility vim-cmd to power off the
virtual machine
1.
On the ESXi console, enter Tech
Support mode and log in as root.
2.
Get a list of all registered
virtual machines, identified by their VMID, Display Name, and path to the .vmx configuration file by
running this command:
vim-cmd vmsvc/getallvms
vim-cmd vmsvc/getallvms
3.
Get the current state of a
virtual machine by running this command:
vim-cmd vmsvc/power.getstate VMID
vim-cmd vmsvc/power.getstate VMID
4.
Shutdown the virtual machine
using the VMID found in Step 2 and run this command:
vim-cmd vmsvc/power.shutdown VMID
Note: If the virtual machine fails to shut down, run this command:
vim-cmd vmsvc/power.off VMID
vim-cmd vmsvc/power.shutdown VMID
Note: If the virtual machine fails to shut down, run this command:
vim-cmd vmsvc/power.off VMID
Sending signals on ESXi to power off the virtual machine
A virtual machine can be halted from the command line by sending
signals to the process.
Warning: This procedure is potentially hazardous to the ESXi host. If you do not identify the appropriate process ID (PID) and kill the wrong process, it may have unexpected results.
In ESXi 4.x and above, you can use the k command in esxtop to send a signal to, and kill, a running virtual machine process.
1.
On the ESXi console, enter Tech
Support mode and log in as root
2.
Run the esxtop utility by running this
command:
esxtop
esxtop
3.
Press c to switch to the CPU
resource utilization screen.
4.
Press Shift+v to limit the view
to virtual machines. This may make it easier to find the Leader World ID in
step 7.
5.
Press f to display the list of
fields.
6.
Press c to add the column for
the Leader World ID.
7.
Identify the target virtual
machine by its Name and Leader World ID (LWID).
8.
Press k.
9.
At the World to kill prompt, type in the
Leader World ID from step 6 and press Enter.
10.
Wait 30 seconds and validate
that the process is not longer listed.
Source: VMware KB
No comments:
Post a Comment