如何关闭一个无法停止的VMware虚拟机?

26

我有一个在服务器上运行的虚拟机,无法停止或重新启动 - 我不能再登录它,也不能使用VMware服务器控制台停止它。由于其他虚拟机正在运行,因此重启主机不是可行的选择。是否还有其他方法强制停止一台虚拟机?

8个回答

18

如果您使用 Linux 操作系统,则可以使用以下命令获取客户机进程:

ps axuw | grep vmware-vmx

正如@Dubas所指出的,您应该能够通过VMD的路径名选出错误的进程


2
太好了。使用这个命令,你可以轻松查看机器的路径,以便选择正确的PID。 - Dubas

17

如果您正在使用Windows系统,则虚拟机应该有自己在任务管理器中可见的进程。使用Sysinternals Process Explorer找到正确的进程,然后从那里终止它。


6
在某些情况下,您可能无法暂停虚拟机,或者进行任何“电源”操作。您可能已经有多个虚拟机正在运行。使用此过程来识别要终止的正确PID。
在 Windows 7 中 - 打开任务管理器 - 查找名称为“vmware-vmx.exe”的进程,并记录PIDs。
切换到性能选项卡并启动“资源监视器”。展开“磁盘活动”面板。对“文件”列进行排序。查找要终止的虚拟机的适当vmdk文件。 “映像”列将列出“vmware-vmx”进程。注意PID。
切换回“进程”选项卡并终止PID。

4
请看来自VMware网页的以下内容:

关闭ESXi主机上的虚拟机(1014165) 症状

您遇到以下问题:

You cannot power off an ESXi hosted virtual machine.
A virtual machine is not responsive and cannot be stopped or killed.

使用 ESXi 5.x esxcli 命令关闭虚拟机
esxcli 命令可用于本地或远程关闭运行在 ESXi 5.x 上的虚拟机。更多信息,请参阅 vSphere 命令行接口参考手册中的 esxcli vm 命令部分。
链接:http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1014165
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.

Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file, using this command:

esxcli vm process list

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

Repeat Step 2 and validate that the virtual machine is no longer running.

对于ESXi 4.1版本:

Get a list of running virtual machines, identified by World ID, UUID, Display Name, and path to the .vmx configuration file, using this command:

esxcli vms vm list

Power off one of the virtual machines from the list using this command:

esxcli vms vm kill --type=[soft,hard,force] --world-id=WorldNumber"

4

基于以下两点考虑,a) @Espo的评论和b) 我只能使用Windows任务管理器……

我登录主机,打开了任务管理器,并在“视图”菜单中将PID列添加到“进程”选项卡中。

我用纸和笔记录了在该系统上正在运行的每一个vmware-wmx.exe进程的PID号码。

使用VMWare控制台,我暂停了出现问题的虚拟机。

当我恢复它后,我就可以识别与我的虚拟机相对应的vmware-vmx进程并杀死它。

到目前为止似乎没有产生任何不良影响。


1
不会有任何负面影响。VMWare为每个虚拟机单独处理进程。实际上,它也单独处理虚拟机引擎和虚拟机图形。因此,您的图形可能会崩溃,但您的虚拟机仍将继续工作。 - Martin Marconcini
很高兴看到它有所帮助。如果您使用了“进程资源管理器”,您可以看到窗口标题和磁盘文件的名称,这将节省您的打字时间。(现在谁还用笔和纸呢? :) ) - Espo

4

类似的,但使用WMIC命令行获取进程ID和路径:

WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid

这将创建一个文本文件,其中包含每个进程及其参数。您可以在文件中搜索您的VM文件路径,并获取正确的进程ID以结束任务。

感谢http://windowsxp.mvps.org/listproc.htm提供正确的命令行参数。


3

3

对于ESXi 5,您首先需要通过vSphere控制台启用ssh,然后登录并使用以下命令查找进程ID:

ps -c | grep -i "machine name"

您可以通过使用 kill 命令来查找进程 ID 并结束该进程。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接