目錄
- 【常用命令】
- 【關于esxi常用命令總結】
- 【esxcli命令探究】
ESXi命令行獲取幫助的方法為<命令關鍵字 --help>,常用的命令一般都是以esxcli開頭,如果忘記命令可以使用幫助:esxcli --help;輸出如下:
[root@localhost:~] esxcli --help
Usage: esxcli [options] {namespace}+ {cmd} [cmd options]
Options:
--formatter=FORMATTER
Override the formatter to use for a given command. Available formatter: xml, csv, keyvalue
--debug Enable debug or internal use options
--version Display version information for the script
-?, --help Display usage information for the script
Available Namespaces:
device Device manager commands
elxnet elxnet esxcli functionality
esxcli Commands that operate on the esxcli system itself allowing users to get additional information.
fcoe VMware FCOE commands.
graphics VMware graphics commands.
hardware VMKernel hardware properties and commands for configuring hardware.
iscsi VMware iSCSI commands.
network Operations that pertain to the maintenance of networking on an ESX host. This includes a wide variety of
commands to manipulate virtual networking components (vswitch, portgroup, etc) as well as local host IP, DNS and
general host networking settings.
rdma Operations that pertain to remote direct memory access (RDMA) protocol stack on an ESX host.
sched VMKernel system properties and commands for configuring scheduling related functionality.
software Manage the ESXi software image and packages
storage VMware storage commands.
system VMKernel system properties and commands for configuring properties of the kernel core system and related system
services.
vm A small number of operations that allow a user to Control Virtual Machine operations.
vsan VMware Virtual SAN commands
【常用命令】
1)vmware -v
查看系統版本,例子:
[root@localhost:~] vmware -v
VMware ESXi 6.0.0 build-3620759
2)esxcli system version get
查看系統版本包括patch等信息,例子:
[root@localhost:~] esxcli system version get
Product: VMware ESXi
Version: 6.0.0
Build: Releasebuild-3620759
Update: 2
Patch: 34
3)esxcli system time get
查看系統時間,例子:
[root@localhost:~] esxcli system time get
2016-09-13T02:02:39Z
4)esxcli system time set
修改系統時間,例子:
Cmd options:
-d|--day=<long> Day
-H|--hour=<long> Hour
-m|--min=<long> Minute
-M|--month=<long> Month
-s|--sec=<long> Second
-y|--year=<long> Year
[root@localhost:~] esxcli system time set -y=2016 -M=9 -d=13 -H=10 -m=9
[root@localhost:~] esxcli system time get
2016-09-13T10:09:27Z
5)esxcli system maintenanceMode set --enable true/false
ESXi主機進入/退出,維護模式,例子:
[root@localhost:~] esxcli system maintenanceMode set --enable true
[root@localhost:~] esxcli system maintenanceMode get //查看維護模式的狀態
Enabled
[root@localhost:~] esxcli system maintenanceMode set --enable false
[root@localhost:~] esxcli system maintenanceMode get
Disabled
[root@localhost:~]
6)esxcli system shutdown reboot/poweroff
系統重啟/關機(必須處于維護模式,否則命令不生效)
7)esxcli network ip interface ipv4 get
查看接口ipv4地址,例子:
[root@localhost:~] esxcli network ip interface ipv4 get
Name IPv4 Address IPv4 Netmask IPv4 Broadcast Address Type DHCP DNS
---- ------------- ------------- -------------- ------------ --------
vmk0 10.1.98.165 255.255.255.0 10.1.98.255 STATIC false
8)esxcli network ip route ipv4 list
查看路由表,例子:
[root@localhost:~] esxcli network ip route ipv4 list
Network Netmask Gateway Interface Source
----------- ------------- ------------- --------- ------
default 0.0.0.0 10.1.98.254 vmk0 MANUAL
10.1.98.0 255.255.255.0 0.0.0.0 vmk0 MANUAL
9)esxcli network nic list
查看ESXi主機網卡列表(nic)或up-link列表,例子:
[root@localhost:~] esxcli network nic list
Name PCI Device Driver Admin Status Link Status Speed Duplex MAC Address MTU Description
------ ------------ ------ ------------ ----------- ----- ------ ----------------- ---- ---------------------------------------------------
vmnic0 0000:03:00.0 e1000e Up Up 1000 Full 00:50:56:9d:bd:b7 1500 Intel Corporation 82574L Gigabit Network Connection
vmnic1 0000:0b:00.0 e1000e Up Up 1000 Full 00:50:56:9d:7c:7f 1500 Intel Corporation 82574L Gigabit Network Connection
10)esxcli network nic down/up -n=vmnic1
關閉/打開vmnic1接口
11)esxcli storage core device list
查看磁盤列表
【關于esxi常用命令總結】
services.sh Linux服務通常使用services命令管理,管理ESXi服務是通過使用services.sh命令實現的。Services.sh命令支持的參數包括stop、start、restart,通過這三個參數可以停止、啟動或重啟所有的ESXi服務。
重啟管理服務
/etc/init.d/hostd restart
/etc/init.d/vpxa restart
cat /etc/chkconfig.db 查看所有ESXi服務的運行狀態
查看服務器IP信息
esxcli network ip interface ipv4 get
查宿主機下每個對應的mac
net-stats -l
查看網卡狀態
esxcfg-vmknic -l
vmkping 我們都熟悉ping命令的用法及功能。Vmkping命令更進一步,允許使用Vmkernel的IP堆棧通過特定的接口發送ICMP數據包。這意味著你可以通過vMotion網絡而非管理網絡發送ping包。
例:vmkping –I vmk1 10.10.10.1 通過vmkl接口向10.10.10.1發送ICMP請求
nc 組合使用vmkping、nc命令(netcat),可以確認ESXi主機與特定IP之間的網絡連通性。盡管vmkping命令通過ICMP確認連通性,但有時我們想確認是否可以訪問特定的TCP端口(例如iSCSI的TCP端口是3260)。
例:nc -z 10.10.10.10 3260 測試是否能夠訪問10.10.10.10的3260端口。
vmkfstools 如果需要通過命令行管理VMFS數據卷以及虛擬磁盤,那么vmkfstools命令就派上用場了。使用vmkfstools命令可以創建、克隆、擴展、重命名并刪除VMDK文件。除了虛擬磁盤選項,你還可以使用vmkfstools命令創建、擴展、增大、回收文件系統的數據塊。
例:vmkfstools –i test.vmdk testclone.vmdk 將test.vmdk克隆為testclone.vmdk
esxtop 對ESXi主機進行性能監控以及故障診斷時,很少有工具能夠提供和esxtop同樣多的信息。除提供和Linux top命令類似的功能外,esxtop還可以收集很多VMware專有的指標,包括中斷、內存、網絡、磁盤適配器、磁盤設備以及電源管理。
vscsistats – 需要進一步監控存儲I/O的性能時,vscsiStats命令就能夠派上用場了。vscsiStats命令能夠幫助你收集與虛擬機磁盤I/O負載相關的性能數據。進行容量規劃或者遷移后端存儲時,使用vscsiStats命令收集到的數據可謂價值連城。
vim-cmd vim-cmd是構建在hostd進程之上的命令空間,允許最終用戶調用幾乎所有的vSphere API。Vim-cmd提供了一些ESXi子命令管理不同的虛擬基礎設施,而且和vimsh相比,更容易使用。
dcui 登錄到ESXi主機時,VMware直接用戶控制臺接口(DCUI)提供了基于菜單的主機管理功能。DCUI提供了很多不同的功能,比如root密碼維護、網絡維護。有時你可能只能通過SSH訪問主機,但幸運的是,在命令行下執行dcui命令就可以進入基于菜單的DCUI系統。
vm-support 曾經想過收集ESXi主機所有的支持及日志信息嗎?Vm-support命令恰好能夠滿足你的要求。如果之前與VMware的技術支持熱線聯系過,那么很可能用過這個命令。
【esxcli命令探究】
esxcli命令用途廣泛,我們不能簡單地將其歸為單個命令。esxcli包括許多不同的命名空間,允許你控制ESXi提供的幾乎所有設備。下面列出了使用最頻繁(肯定不是所有)的命名空間:
esxcli hardware 想獲取ESXi主機的硬件及配置信息時,esxcli硬件命名空間就能夠派上用場了。
esxcli hardware cpu list 獲取CPU信息(系列、型號以及緩存)
esxcli hardware memory get 獲取內存信息(可用內存以及非一致內存訪問)
esxcli iscsi iscsi命名空間可以被用于監控并管理硬件iSCSI及軟件iSCSI設置。
esxcli iscsi software 用于啟用/禁用軟件iSCSI initiator。
esxcli iscsi adapter 用于設置軟硬件iSCSI適配器的發現、CHAP以及其他設置
esxcli iscsi sessions 用于列出主機上已建立的iSCSI會話。
esxcli network 需要監控vSphere網絡并對如下網絡組件進行調整時,包括虛擬交換機、VMkernel網絡接口、防火墻以及物理網卡等,esxcli網絡命名空間就派上用場了。
esxcli network nic 列出并修改網卡信息,比如名字、喚醒網卡以及速度。
esxcli network vm list 列出有一個活動網絡端口的虛擬機的網絡信息。
esxcli network vswitch 檢索并管理VMware的標準交換機以及分布式虛擬交換機。
esxcli network ip 管理VMkernel端口,包括管理、vMotion以及FT網絡。還可以修改主機的所有IP棧,包括DNS、IPsec以及路由信息。
esxcli software 軟件命名空間可以用于檢索ESXi主機已安裝的軟件及驅動并可以安裝新組件。
esxcli software vib list 列出ESXi主機上已經安裝的軟件及驅動。
esxcli storage 可能是最常用的esxcli命令命名空間之一,包括了管理連接到vSphere的存儲的所有信息。
esxcli storage core device list 列出當前存儲設備
esxcli storage core device vaai status get 獲得存儲設備支持的VAAI的當前狀態。
esxcli system 通過該命令使你能夠控制ESXi的高級選項,比如設置syslog并管理主機狀態。
esxcli system maintenanceMode set --enabled yes/no 將主機設置為維護模式
esxcli system syslog 查看 Syslog 及配置信息
esxcli vm ESXi的虛擬機命名空間用于列出運行在主機上的虛擬機的各種信息,如果需要可以強制關閉這些虛擬機。
esxcli vm process list 列出已啟動的虛擬機的進程信息。
esxcli vm process kill 停止正在運行的虛擬機的進程,關閉虛擬機或者強制關閉虛擬機電源。
esxcli vsan ESXi的VSAN命名空間包括配置并維護VSAN的很多命令,包括數據存儲、網絡、默認域名以及策略配置。
esxcli vsan storage 配置VSAN使用的本地存儲,包括增加、刪除物理存儲并修改自動聲明。
esxcli vsan cluster 本地主機脫離/加入VSAN集群。
esxcli esxcli esxcli命令包括一個稱為esxcli的命名空間,通過使用esxcli命名空間,你可以獲得更多信息。
esxcli esxcli command list 列出所有的esxcli命令及其提供的功能
以上就是探索VMware ESXI CLI常用命令的詳細內容,更多關于VMware ESXI CLI命令的資料請關注腳本之家其它相關文章!