http://www.youtube.com/watch?v=RmSB2s1lWvg&feature=player_embedded
遇過 VM 無法關機或停止的狀況嗎? 當透過 GUI 畫面無法動作時,就必須用 command line 來將 VM power off。 以下是在 COS 下的幾個 command,供您參考:
1. vmware-cmd -l:秀出此 host 上的每個 VM 路徑名稱,找出關不掉的 VM vmx 路徑。
2. vmware-cmd getstate:向 ESX host 探詢 VM 目前狀態,記得這只是 ESX 自認為的 VM 狀態。
3. vmware-cmd stop:請 ESX 將 VM power off。
4. 再用 getstate 探詢,若仍為 on,則使用 stop hard。
5. 如果 stop hard 後,VM 還是一直在運作的話,那麼最後的辦法就是 kill process。 但此舉可能會造成 ESX 或 VM 產生不可預期的狀況,有潛在的危險性。VMware 建議如果不想這麼做,可以找 support。( 請參閱之前的文章 : http://vlife.pixnet.net/blog/post/31582502 ) 以上為 ESX host 的使用方式,
如果是 ESXi 的話,請參閱
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=1014165
Powering off a virtual machine on an ESXi host
Symptoms
You are experiencing these issues:
- You cannot power off an ESXi hosted virtual machine.
- A virtual machine is not responsive and cannot be stopped or killed.
Purpose
Resolution
-
Connect VMware Infrastructure (VI) Client to VMware VirtualCenter Server.
-
Right-click on the virtual machine and click Power off.
-
Connect VI Client directly to the ESXi host.
-
Right-click on the virtual machine and click Power off.
If this does not work, you will need to install the Remote Command-Line Interface (RCLI) or vMA tools.
Installing the Remote Command-Line Interface tool
The Remote Command-Line Interface (RCLI) is used for the parts of this article. Ensure that it is installed before you proceed.
For ESXi 3.5 hosts, see Remote CLI Installation and Execution in the Remote Command-Line Interface Installation and Reference Guide.
Using the ESXi command line tool to power off the virtual machine
This procedure uses additional ESXi command line tools. Attempt each process before proceeding to the next, as they are listed in order of potential impact to the system if performed incorrectly.
-
On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support mode for Emergency Support (1003677) or Using Tech Support Mode in ESXi 4.1 (1017910).
-
Get the World_ID with the command:
# vm-support -x -
Kill the virtual machine by using the following command in the home directory of the virtual machine.
-
-
For ESXi 3.x, run the command:
# vm-support -X <World_ID> -f –w <dir>
where
-f allows you to force vm-support to use a VMFS working directory.
-w sets the working directory used for the output files. This is the directory where vm-support saves its final .tar archive. If this option is not specified, the working directory will be the directory from which vm-support is run. -
For ESXi 4.x:
# vm-support -X <World_ID> –w <dir>
Note: If the vm-support command is slow with the -X switch, add -d0 to speed up the process.
-
Using alternate ESXi command line methods to power off the virtual machine
- On the ESXi console, enter Tech Support mode and log in as root. For more information, see Tech Support mode for Emergency Support (1003677).
- To list all running virtual machines and their corresponding VMIDs, run the command:
vim-cmd vmsvc/getallvms - Power off the virtual machine using the VMID found in Step 2 and run:
vim-cmd vmsvc/power.off <vm id> for ESXi 3.5 and 4.0
vim-cmd vmsvc/power.off <vmid> for ESXi 4.1
Using the ESXi command line method to kill the virtual machine
-
To determine if the virtual machine process is running on the ESXi host, run the command:
# ps | grep vmx
On an ESXi 3.x host, if the .vmx process is running, the output appears similar to:
ps|grep vmx
7662 7662 vmx /bin/vmx
7667 7662 vmx /bin/vmx
7668 7662 mks:VMtoKill /bin/vmx
7669 7662 vcpu-0:VMtoKill /bin/vmx
On an ESXi 4.0 host, if the .vmx process is running, the output appears similar to:
ps |grep vmx
7662 7662 vmx /bin/vmx
7663 7662 mks :VMtoKill /bin/vmx
7664 7662 vcpu-0:VMtoKill /bin/vmx
The parent process ID (PID) for this process is in bold. In this example, the PID is 7662. Several rows are returned, but you must make sure you identify the parent process. The first column contains the PID, and the second contains the parent's PID. Ensure you terminate only the parent process. Take note of this number for use in the following steps.
Caution: Ensure that you identify the line specific only to the virtual machine you are attempting to repair. If you continue this process for another virtual machine the one in question, you can cause downtime for the other virtual machine. -
If the .vmx process is listed, it is possible that the process has runaway and must be stopped manually. To kill the process, run the command:
# kill <PID> -
Wait 30 seconds and check for the process again.
-
If it is not terminated, run the command:
# kill -9 <PID> -
Wait 30 seconds and check for the process again.
-
If it is not terminated, the ESXi host must be rebooted to clear the process. This is a last resort option, and should be attempted only if the preceding steps in this article are unsuccessful.
- Run esxtop.
- Press c to switch to the CPU resource utilization screen.
- Press f to add the column for the world ID.
- Press k and type in that ID.
留言列表