自動目錄
使用esxcli關機
查看執行中的vm
# esxcli vm process list
Freebsd10
World ID: 3012737
Process ID: 0
VMX Cartel ID: 3012734
UUID: 56 4d 71 f5 bc e0 fa eb-4b 99 ff 09 9a a4 b8 9b
Display Name: Freebsd10
Config File: /vmfs/volumes/5380950f-4cb01916-7c69-d485646613e4/CompactLinux7/CompactLinux7.vmx
注意World ID,關機
# esxcli vm process kill --t soft --w 3012737
type有soft, hard, force 三種
使用vim-cmd關機
查看所有的vm,注意 Vmid
# vim-cmd vmsvc/getallvms
Vmid Name File Guest OS Version Annotation
4 Linux7 [8X_146G_SAS] Linux7/Linux7.vmx centos64Guest vmx-08
5 Freebsd10 [8X_146G_SAS] CompactLinux7/CompactLinux7.vmx centos64Guest vmx-08
6 Centos7(JAVA) [8X_146G_SAS] Centos7(JAVA)/Centos7(JAVA).vmx rhel6_64Guest vmx-08
檔查狀態,下例的5是vmid
# vim-cmd vmsvc/power.getstate 5
Retrieved runtime info
Powered on
關機(VMID 請填數字)
# vim-cmd vmsvc/power.shutdown VMID
# vim-cmd vmsvc/power.off VMID
開機(VMID 請填數字)
# vim-cmd vmsvc/power.on VMID
使用esxtop終極關機
# esxtop
5:53:08pm up 13 days 23:23, 522 worlds, 3 VMs, 7 vCPUs; CPU load average: 0.03, 0.03, 0.02
PCPU USED(%): 0.6 10 1.3 1.9 2.5 0.0 0.5 0.9 59 0.0 0.9 0.0 AVG: 6.5
PCPU UTIL(%): 4.9 38 1.2 5.2 4.7 19 9.5 0.7 99 2.0 0.9 19 AVG: 17
CORE UTIL(%): 22 4.9 4.7 1.6 99 0.9 AVG: 22
ID GID NAME NWLD %USED %RUN %SYS %WAIT %VMWAIT %RDY %IDLE %OVRLP %CSTP %MLMTD %SWPWT
6261925 6261925 esxtop.3237797 1 58.86 78.76 0.00 0.11 - 0.00 0.00 0.02 0.00 0.00 0.00
5671680 5671680 Linux7 10 16.14 35.25 0.41 759.11 0.40 0.81 281.57 0.06 0.00 0.00 0.00
6256827 6256827 Freebsd10 7 2.29 3.19 0.03 561.23 5.31 0.50 152.58 0.02 0.00 0.00 0.00
6252970 6252970 sshd.3233234 1 1.13 1.20 0.00 79.01 - 0.04 0.00 0.00 0.00 0.00 0.00
按f進到選單
Current Field order: ABcDEFghij
* A: ID = Id
* B: GID = Group Id
C: LWID = Leader World Id (World Group Id)
* D: NAME = Name
* E: NWLD = Num Members
* F: %STATE TIMES = CPU State Times
G: EVENT COUNTS/s = CPU Event Counts
H: CPU ALLOC = CPU Allocations
I: SUMMARY STATS = CPU Summary Stats
J: POWER STATS = CPU Power Stats
Toggle fields with a-j, any other key to return:
按c勾選C項,按enter回去,會多一個欄位 LWID就是World ID,找到你的vm記下他的LWID
按k輪入要關機的World id,例如:
World to kill (WID): 3235195
按下後就立即關閉完畢
參考資料
[1] guest vm強制關機方法
[2] VM官網開關機索引 VM CLI5.5 Manual PDF Download