1. 程式人生 > >ESXi 5.x 命令列操作

ESXi 5.x 命令列操作

網路

很多命令的 -h 都包含了詳細的例子

esxcli network:

這是一個命令集, 包含了很多子命令

  • esxcli network nic list 檢視網絡卡資訊
  • esxcli network ip route ipv4 list 檢視路由(ipv4)
  • esxcli network ip dns server list 檢視 dns
  • esxcli network ip interface ipv4 get 檢視ip配置(ipv4)

esxcfg-route:

  • esxcfg-route 檢視預設路由

esxcfg-nics:

  • esxcfg-nics 等價 esxcli network nic list

tcpdump-uw:

類似於Linux下的 tcpdump, 是 ESX 的抓包工具

vsish

ESXi命令列修改密碼

通過 ssh 登入到 ESXi 系統後, 可以通過 passwd root 來修改密碼

For ESXi 5.0, the location of authorized_keys is: /etc/ssh/keys-<username>/authorized_keys

控制虛擬機器開關機

To power on a virtual machine from the command line:

List the inventory ID of the virtual machine with the command:

vim-cmd vmsvc/getallvms |grep <vm name>

Note: The first column of the output shows the vmid.

Check the power state of the virtual machine with the command:

vim-cmd vmsvc/power.getstate <vmid>

Power-on the virtual machine with the command:

vim-cmd vmsvc/power.on <vmid>

關機就是把 power.on

 改為 power.off 就可以了.

另外還有一種方法, 只能控制關機:

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

參考: