VMware ESXi 强制关机关闭虚拟机

最近學到一個在VMware ESXi 下面強制關閉一個沒有反應的VM的方法, 一般正常都是使用vSphere Client 去控制VM電源, 但是有時會發生即使用裡面的Power Off 按鈕但是還是無法關閉我的VM, 而且最終會出現一串錯誤訊息「An unexpected error was received from the ESX host while powering off VM ..」這時要解決問題的方法是讓ESXi host整個重開機一次, 但是如果不想整台伺服器重新開機時要怎麼樣呢...

透過Google大神的搜尋下, 找到可以透過Shell的命令來對系統進行一些操作, 我找到一頁對於開關VM有幫助的網頁 "Forcibly Stopping Virtual Machines with EXCLI"

只要使用esxcli 命令打入相關的參數就可以了, 要做遠端shell command的操作首先要在ESXi 打開「Shell Service 和 SSH Service」

esxcli <conn_options> vm process kill --type <kill_type> --world-id <ID>

接下來利用putty連入後打入「esxcli vm process list 」命令去獲取現在系統裡的動作中的VM資訊, 會得到類似下面的訊息...

~ # esxcli vm process list

WinXP CHT (netComputer)
World ID: 4171
Process ID: 0
VMX Cartel ID: 4170
UUID: 56 4d 8b 2a 9c 6c fa b4-b3 77 19 21 69 05 09 25
Display Name: WinXP CHT (netComputer)
Config File: /vmfs/volumes/4ef37e4a-50fb6d27-df84-001018185495/WinXP CHT (netComputer)/WinXP CHT (netComputer).vmx

Windows 7 Eng
World ID: 196949
Process ID: 0
VMX Cartel ID: 196948
UUID: 42 3b 85 7b 89 ee 38 bc-61 c2 70 b9 4b 29 26 62
Display Name: Windows 7 Eng
Config File: /vmfs/volumes/4ef37e4a-50fb6d27-df84-001018185495/Windows 7 Eng/Windows 7 Eng.vmx

接下來你要找尋無法控制開關機的VM, 找到它的「World ID」, 比如說接「Windows 7 Home x64 」失去連線且透過vSphere Client完全無法控制, 我只要輸入以下命令就可以強制將VM關閉, 然後再啟動

esxcli vm process kill --type hard --world-id 211699

如果還是不行可能就要試試用 --type force, 再不行也只能重新開伺服器了。

猜你喜欢

转载自www.cnblogs.com/langzixdj/p/10855383.html