Explore common commands for VMware ESXI CLI

  • 2021-11-01 05:27:55
  • OfStack

Directory Common Commands
[Summary of Common Commands of esxi] [Exploration of esxcli Commands]

The ESXi command line gets help by < Command keywords-help > The commonly used commands 1 generally start with esxcli. If you forget the command, you can use help: esxcli-help; The output is as follows:


[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 

"Common commands"

1) vmware-v
View the system version, example:


[root@localhost:~] vmware -v
VMware ESXi 6.0.0 build-3620759

2) esxcli system version get
View the system version including patch and other information, example:


[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
View system time, example:


[root@localhost:~] esxcli system time get
2016-09-13T02:02:39Z

4) esxcli system time set
Modify system time, example:


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 Host Entry/Exit, Maintenance Mode, Example:


[root@localhost:~] esxcli system maintenanceMode set --enable true
[root@localhost:~] esxcli system maintenanceMode get   // View the status of maintenance mode 
Enabled
[root@localhost:~] esxcli system maintenanceMode set --enable false
[root@localhost:~] esxcli system maintenanceMode get
Disabled
[root@localhost:~] 

6)esxcli system shutdown reboot/poweroff
System restart/shutdown (must be in maintenance mode, otherwise the command will not take effect)
7) esxcli network ip interface ipv4 get
Look at the interface ipv4 address, example:


[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
View the routing table, for example:


[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
View the list of ESXi host network cards (nic) or the list of up-link, for example:


[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
Close/open vmnic1 interface
11) esxcli storage core device list
View the list of disks

Summary of Common Commands for esxi


services.sh  Linux服务通常使用services命令管理,管理ESXi服务是通过使用services.sh命令实现的。Services.sh命令支持的参数包括stop、start、restart,通过这3个参数可以停止、启动或重启所有的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命令更进1步,允许使用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 � 需要进1步监控存储I/O的性能时,vscsiStats命令就能够派上用场了。vscsiStats命令能够帮助你收集与虚拟机磁盘I/O负载相关的性能数据。进行容量规划或者迁移后端存储时,使用vscsiStats命令收集到的数据可谓价值连城。

vim-cmd  vim-cmd是构建在hostd进程之上的命令空间,允许最终用户调用几乎所有的vSphere API。Vim-cmd提供了1些ESXi子命令管理不同的虚拟基础设施,而且和vimsh相比,更容易使用。

dcui  登录到ESXi主机时,VMware直接用户控制台接口(DCUI)提供了基于菜单的主机管理功能。DCUI提供了很多不同的功能,比如root密码维护、网络维护。有时你可能只能通过SSH访问主机,但幸运的是,在命令行下执行dcui命令就可以进入基于菜单的DCUI系统。

vm-support  曾经想过收集ESXi主机所有的支持及日志信息吗?Vm-support命令恰好能够满足你的要求。如果之前与VMware的技术支持热线联系过,那么很可能用过这个命令。

"esxcli Command Exploration"

The esxcli command is so versatile that we cannot simply classify it as a single command. esxcli includes a number of different namespaces that allow you to control almost all the devices that ESXi offers. Here is a list of the most frequently used (certainly not all) namespaces:


[root@localhost:~] vmware -v
VMware ESXi 6.0.0 build-3620759
0

The above is the details of exploring the common commands of VMware ESXI CLI. Please pay attention to other related articles on this site for more information about VMware ESXI CLI commands!


Related articles: