我在服务器上运行了一个无法停止或重新启动的虚拟机 - 我无法再登录它,也无法使用 VMware 服务器控制台停止它。还有其他 VM 正在运行,因此重新启动主机是不可能的。有没有其他方法可以强制一台机器停止?
8 回答
如果您使用的是 linux,那么您可以使用以下命令获取来宾进程
ps axuw | grep vmware-vmx
正如@Dubas 指出的那样,您应该能够通过 VMD 的路径名找出错误的进程
如果您使用的是 Windows,则虚拟机应该有自己的进程,该进程在任务管理器中可见。使用 sysinternals Process Explorer找到正确的,然后从那里杀死它。
在某些情况下,您可能无法暂停,或者就此而言对 VM 执行任何“电源”操作。您可能还已经启动并运行了多个 VM。使用此过程来识别要杀死的正确 PID。
在 Windows 7 上 - 打开任务管理器 - 查找名称为“vmware-vmx.exe”的进程,记下 PID。
切换到性能选项卡并启动“资源监视器”。展开“磁盘活动”面板。对“文件”列进行排序。为要杀死的 VM 查找适当的 vmdk 文件。“映像”列将列出“vmware-vmx”进程。注意PID。
切换回“进程”选项卡并终止 PID。
这是我根据
a)@Espo 的评论和
b)我只有 Windows 任务管理器可以玩的事实......
我登录到主机,打开任务管理器并使用视图菜单将 PID 列添加到进程选项卡。
我写下了(是的,用纸和笔)在盒子上运行的 vmware-wmx.exe 进程的每个实例的 PID。
使用 VMWare 控制台,我暂停了错误的虚拟机。
当我恢复它时,我可以识别与我的机器对应的 vmware-vmx 进程并可以杀死它。
到目前为止,似乎没有任何不良影响。
类似,但使用 WMIC 命令行获取进程 ID 和路径:
WMIC /OUTPUT:C:\ProcessList.txt PROCESS get Caption,Commandline,Processid
这将创建一个包含每个进程及其参数的文本文件。您可以在文件中搜索您的 VM 文件路径,并获取正确的进程 ID 以结束任务。
感谢http://windowsxp.mvps.org/listproc.htm提供了正确的命令行参数。
对于 ESXi 5,您首先需要通过 vSphere 控制台启用 ssh,然后登录并使用以下命令查找进程 ID
ps -c | grep -i "machine name"
然后,您可以找到进程 ID 并使用结束进程kill
从 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 命令部分。
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"
对于 VmWare fusion,按住alt键,同时单击“重新启动虚拟机”