虚拟化之esxi命令行管理

Vmware PowerCLI和Vmware CLI

vMA
A Linux virtual appliance that includes the vSphere SDK for Perl and the vCLI package.Also supports the vi-fastpass authentication component.

ESXi Shell commands
Set of troubleshooting commands to use when vCLI cannot access your ESXi system. Includes ESXCLI commands and esxcfg-commands (deprecated).

VMware vSphere PowerCLI 是一款功能强大的命令行工具,可自动执行 vSphere 的各方面管理,包括主机、网络、存储、虚拟机、客户操作系统等等。 PowerCLI 作为 Windows PowerShell 插件分发,包括超过 150 个 PowerShell cmdlet,以及文档和示例。 PowerCLI 将 vSphere 平台与 Windows 和 .*-NET 无缝地融合在一起,这意味着您可以单独使用 PowerCLI,也可以在众多其他第三方工具中使用。

直接控制台UI

~ # dcui

按ctrl+c退出

~ # esxcfg-vswitch -l
Switch Name      Num Ports   Used Ports  Configured Ports  MTU     Uplinks
vSwitch0         128         5           128               1500    vmnic0

  PortGroup Name        VLAN ID  Used Ports  Uplinks
  VM Network            0        1           vmnic0
  Management Network    0        1           vmnic0

 

两种方法

1.直接在ESXi控制台界面上按住ALT+F1也能进入
2.把ESXi的SSH功能开开,然后用工具连接行了,root/password。

开启后,会有感叹号

主机>配置>安全配置文件

 

~ # esxcfg-vmknic -l
Interface  Port Group/DVPort   IP Family IP Address                              Netmask         Broadcast       MAC Address       MTU     TSO MSS   Enabled Type
vmk0       Management Network  IPv4      172.16.1.17                             255.255.255.128 172.16.1.127    00:e0:4c:21:c7:a5 1500    65535     true    STATIC
vmk0       Management Network  IPv6      fe80::2e0:4cff:fe21:c7a5                64                              00:e0:4c:21:c7:a5 1500    65535     true    STATIC, PREFERRED
~ # esxcfg-nics -l
Name    PCI           Driver      Link Speed     Duplex MAC Address       MTU    Description
vmnic0  0000:01:00.00 r8168       Up   100Mbps   Full   00:e0:4c:21:c7:a3 1500   Realtek Realtek 8168 Gigabit Ethernet
~ # esxcfg-route
VMkernel default gateway is 172.16.1.126

~ # esxcfg-scsidevs  -A
vmhba33     t10.ATA_____ST500DM0022D1BD142___________________________________Z3TFY6H0
~ # esxcfg-scsidevs  -a
vmhba0  ata_piix          link-n/a  sata.vmhba0                             (0:0:31.2) Intel Corporation Cougar Point 4 port SATA IDE Controller
vmhba1  ata_piix          link-n/a  sata.vmhba1                             (0:0:31.5) Intel Corporation Cougar Point 2 port SATA IDE Controller
vmhba32 ata_piix          link-n/a  sata.vmhba32                            (0:0:31.2) Intel Corporation Cougar Point 4 port SATA IDE Controller
vmhba33 ata_piix          link-n/a  sata.vmhba33                            (0:0:31.5) Intel Corporation Cougar Point 2 port SATA IDE Controller
vmhba34 iscsi_vmk         online    iscsi.vmhba34                           iSCSI Software Adapter
~ # esxcfg-scsidevs  -l
t10.ATA_____ST500DM0022D1BD142___________________________________Z3TFY6H0
   Device Type: Direct-Access
   Size: 476940 MB
   Display Name: Local ATA Disk (t10.ATA_____ST500DM0022D1BD142___________________________________Z3TFY6H0)
   Multipath Plugin: NMP
   Console Device: /vmfs/devices/disks/t10.ATA_____ST500DM0022D1BD142___________________________________Z3TFY6H0
   Devfs Path: /vmfs/devices/disks/t10.ATA_____ST500DM0022D1BD142___________________________________Z3TFY6H0
   Vendor: ATA       Model: ST500DM002-1BD14  Revis: KC45
   SCSI Level: 5  Is Pseudo: false Status: on
   Is RDM Capable: false Is Removable: false
   Is Local: true  Is SSD: false
   Other Names:
      vml.01000000002020202020202020202020205a33544659364830535435303044
   VAAI Status: unknown




~ # esxcfg-info -h
Usage: esxcfg-info mode
  -a, --all           Print all information
  -w, --hardware      Print hardware information
  -r, --resource      Print resource information
  -s, --storage       Print storage information
  -n, --network       Print network information
  -y, --system        Print system information
  -o, --advopt        Print advanced options
  -u, --hwuuid        Print hardware uuid
  -b, --bootuuid      Print boot partition uuid
  -e, --boottype      Print boot type (VMVisor Only)
  -c, --cmdline       Print vmkernel command line
  -F, --format        Print the information in the given format
                      Valid values are "xml" and "perl"
  -h, --help          Print this message.

 

~ # esxcli
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:
  esxcli                Commands that operate on the esxcli system itself allowing users to get additional information.
  fcoe                  VMware FCOE 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.
  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.
  vm                    A small number of operations that allow a user to Control Virtual Machine operations.

 

~ # esxcli system -h
Usage: esxcli system {cmd} [cmd options]

Available Namespaces:
  boot                  Operations relating to host boot that allow manipulation of VMkernel boot time configuration.
  coredump              Operations pertaining to the VMkernel Core dump configuration.
  module                Operations that allow manipulation of the VMkernel loadable modules and device drivers. Operations include load, list and setting
                        options.
  process               Commands relating to running processes.
  secpolicy             Options related to VMkernel access control subsystem. These options are typically in place for specific workarounds or debugging.
                        These commands should be used at the direction of VMware Support Engineers.
  settings              Operations that allow viewing and manipulation of system settings.
  stats                 Access to various system statistics
  syslog                Operations relating to system logging
  visorfs               Operations pertaining to the visorfs memory filesytem.
  hostname              Operations pertaining the network name of the ESX host.
  maintenanceMode       Command to manage the system's maintenance mode.
  shutdown              Command to shutdown the system.
  snmp                  Commands pertaining to SNMPv1/v2c/v3 Agent configuration.
  time                  Commands to get and set system time.
  uuid                  Get the system UUID
  version               Commands to get version information.
  welcomemsg            Commands to get and set the welcome banner for DCUI.

~ # esxcli system version
Usage: esxcli system version {cmd} [cmd options]

Available Commands:
  get                   Display the product name, version and build information.
~ # esxcli system version get
   Product: VMware ESXi
   Version: 5.1.0
   Build: Releasebuild-1065491
   Update: 1
~ # esxcli esxcli command list
Namespace                                               Command
------------------------------------------------------  -----------
esxcli.command                                          list
fcoe.adapter                                            list
fcoe.nic                                                disable
fcoe.nic                                                discover
fcoe.nic                                                list
hardware.bootdevice                                     list
hardware.clock                                          get
hardware.clock                                          set
hardware.cpu.cpuid                                      get
hardware.cpu.global                                     get
hardware.cpu.global                                     set
hardware.cpu                                            list
hardware.ipmi.fru                                       get
hardware.ipmi.fru                                       list
hardware.ipmi.sdr                                       get
hardware.ipmi.sdr                                       list
hardware.ipmi.sel                                       get
hardware.ipmi.sel                                       list
hardware.memory                                         get
hardware.pci                                            list
hardware.platform                                       get
hardware.trustedboot                                    get
iscsi.adapter.auth.chap                                 get
iscsi.adapter.auth.chap                                 set
iscsi.adapter.capabilities                              get
iscsi.adapter.discovery                                 rediscover
iscsi.adapter.discovery.sendtarget                      add
iscsi.adapter.discovery.sendtarget.auth.chap            get
iscsi.adapter.discovery.sendtarget.auth.chap            set
iscsi.adapter.discovery.sendtarget                      list
iscsi.adapter.discovery.sendtarget.param                get
iscsi.adapter.discovery.sendtarget.param                set
iscsi.adapter.discovery.sendtarget                      remove
iscsi.adapter.discovery.statictarget                    add
iscsi.adapter.discovery.statictarget                    list
iscsi.adapter.discovery.statictarget                    remove
iscsi.adapter.discovery.status                          get
iscsi.adapter.firmware                                  get
iscsi.adapter.firmware                                  set
iscsi.adapter                                           get
iscsi.adapter                                           list
iscsi.adapter.param                                     get
iscsi.adapter.param                                     set
iscsi.adapter                                           set
iscsi.adapter.target                                    list
iscsi.adapter.target.portal.auth.chap                   get
iscsi.adapter.target.portal.auth.chap                   set
iscsi.adapter.target.portal                             list
iscsi.adapter.target.portal.param                       get
iscsi.adapter.target.portal.param                       set
iscsi.ibftboot                                          get
iscsi.ibftboot                                          import
iscsi.logicalnetworkportal                              list
iscsi.networkportal                                     add
iscsi.networkportal.ipconfig                            get
iscsi.networkportal.ipconfig                            set
iscsi.networkportal                                     list
iscsi.networkportal                                     remove
iscsi.physicalnetworkportal                             list
iscsi.physicalnetworkportal.param                       get
iscsi.physicalnetworkportal.param                       set
iscsi.plugin                                            list
iscsi.session                                           add
iscsi.session.connection                                list
iscsi.session                                           list
iscsi.session                                           remove
iscsi.software                                          get
iscsi.software                                          set
network.diag                                            ping
network.fence                                           list
network.fence.network.bte                               list
network.fence.network                                   list
network.fence.network.port                              list
network.firewall                                        get
network.firewall                                        load
network.firewall                                        refresh
network.firewall.ruleset.allowedip                      add
network.firewall.ruleset.allowedip                      list
network.firewall.ruleset.allowedip                      remove
network.firewall.ruleset                                list
network.firewall.ruleset.rule                           list
network.firewall.ruleset                                set
network.firewall                                        set
network.firewall                                        unload
network.ip.connection                                   list
network.ip.dns.search                                   add
network.ip.dns.search                                   list
network.ip.dns.search                                   remove
network.ip.dns.server                                   add
network.ip.dns.server                                   list
network.ip.dns.server                                   remove
network.ip                                              get
network.ip.interface                                    add
network.ip.interface.ipv4                               get
network.ip.interface.ipv4                               set
network.ip.interface.ipv6.address                       add
network.ip.interface.ipv6.address                       list
network.ip.interface.ipv6.address                       remove
network.ip.interface.ipv6                               get
network.ip.interface.ipv6                               set
network.ip.interface                                    list
network.ip.interface                                    remove
network.ip.interface                                    set
network.ip.interface.tag                                add
network.ip.interface.tag                                get
network.ip.interface.tag                                remove
network.ip.ipsec.sa                                     add
network.ip.ipsec.sa                                     list
network.ip.ipsec.sa                                     remove
network.ip.ipsec                                        set
network.ip.ipsec.sp                                     add
network.ip.ipsec.sp                                     list
network.ip.ipsec.sp                                     remove
network.ip.neighbor                                     list
network.ip.route.ipv4                                   add
network.ip.route.ipv4                                   list
network.ip.route.ipv4                                   remove
network.ip.route.ipv6                                   add
network.ip.route.ipv6                                   list
network.ip.route.ipv6                                   remove
network.ip                                              set
network.nic                                             down
network.nic                                             get
network.nic                                             list
network.nic                                             set
network.nic.stats                                       get
network.nic                                             up
network.nic.vlan.stats                                  get
network.nic.vlan.stats                                  set
network.port.filter.stats                               get
network.port.stats                                      get
network.sriovnic                                        list
network.sriovnic.vf                                     list
network.vm                                              list
network.vm.port                                         list
network.vswitch.dvs.vmware.lacp.get                     config
network.vswitch.dvs.vmware.lacp.get                     stats
network.vswitch.dvs.vmware.lacp.get                     status
network.vswitch.dvs.vmware                              list
network.vswitch.dvs.vmware.vxlan.config.stats           get
network.vswitch.dvs.vmware.vxlan.config.stats           set
network.vswitch.dvs.vmware.vxlan                        list
network.vswitch.dvs.vmware.vxlan.network                list
network.vswitch.dvs.vmware.vxlan.network.mapping        list
network.vswitch.dvs.vmware.vxlan.network.mapping        reset
network.vswitch.dvs.vmware.vxlan.network.port           list
network.vswitch.dvs.vmware.vxlan.network.port.stats     list
network.vswitch.dvs.vmware.vxlan.network.port.stats     reset
network.vswitch.dvs.vmware.vxlan.network.stats          list
network.vswitch.dvs.vmware.vxlan.network.stats          reset
network.vswitch.dvs.vmware.vxlan.stats                  list
network.vswitch.dvs.vmware.vxlan.stats                  reset
network.vswitch.dvs.vmware.vxlan.vmknic                 list
network.vswitch.dvs.vmware.vxlan.vmknic.multicastgroup  list
network.vswitch.dvs.vmware.vxlan.vmknic.stats           list
network.vswitch.dvs.vmware.vxlan.vmknic.stats           reset
network.vswitch.standard                                add
network.vswitch.standard                                list
network.vswitch.standard.policy.failover                get
network.vswitch.standard.policy.failover                set
network.vswitch.standard.policy.security                get
network.vswitch.standard.policy.security                set
network.vswitch.standard.policy.shaping                 get
network.vswitch.standard.policy.shaping                 set
network.vswitch.standard.portgroup                      add
network.vswitch.standard.portgroup                      list
network.vswitch.standard.portgroup.policy.failover      get
network.vswitch.standard.portgroup.policy.failover      set
network.vswitch.standard.portgroup.policy.security      get
network.vswitch.standard.portgroup.policy.security      set
network.vswitch.standard.portgroup.policy.shaping       get
network.vswitch.standard.portgroup.policy.shaping       set
network.vswitch.standard.portgroup                      remove
network.vswitch.standard.portgroup                      set
network.vswitch.standard                                remove
network.vswitch.standard                                set
network.vswitch.standard.uplink                         add
network.vswitch.standard.uplink                         remove
sched.swap.system                                       get
sched.swap.system                                       set
software.acceptance                                     get
software.acceptance                                     set
software.profile                                        get
software.profile                                        install
software.profile                                        update
software.profile                                        validate
software.sources.profile                                get
software.sources.profile                                list
software.sources.vib                                    get
software.sources.vib                                    list
software.vib                                            get
software.vib                                            install
software.vib                                            list
software.vib                                            remove
software.vib                                            update
storage.core.adapter                                    list
storage.core.adapter                                    rescan
storage.core.adapter.stats                              get
storage.core.claiming                                   autoclaim
storage.core.claiming                                   reclaim
storage.core.claiming                                   unclaim
storage.core.claimrule                                  add
storage.core.claimrule                                  convert
storage.core.claimrule                                  list
storage.core.claimrule                                  load
storage.core.claimrule                                  move
storage.core.claimrule                                  remove
storage.core.claimrule                                  run
storage.core.device.detached                            list
storage.core.device.detached                            remove
storage.core.device                                     list
storage.core.device.partition                           list
storage.core.device.partition                           showguid
storage.core.device                                     set
storage.core.device                                     setconfig
storage.core.device.smart                               get
storage.core.device.stats                               get
storage.core.device.vaai.status                         get
storage.core.device.world                               list
storage.core.path                                       list
storage.core.path                                       set
storage.core.path.stats                                 get
storage.core.plugin                                     list
storage.core.plugin.registration                        add
storage.core.plugin.registration                        list
storage.core.plugin.registration                        remove
storage.filesystem                                      automount
storage.filesystem                                      list
storage.filesystem                                      mount
storage.filesystem                                      rescan
storage.filesystem                                      unmount
storage.nfs                                             add
storage.nfs                                             list
storage.nfs                                             remove
storage.nmp.device                                      list
storage.nmp.device                                      set
storage.nmp.path                                        list
storage.nmp.psp.fixed.deviceconfig                      get
storage.nmp.psp.fixed.deviceconfig                      set
storage.nmp.psp.generic.deviceconfig                    get
storage.nmp.psp.generic.deviceconfig                    set
storage.nmp.psp.generic.pathconfig                      get
storage.nmp.psp.generic.pathconfig                      set
storage.nmp.psp                                         list
storage.nmp.psp.roundrobin.deviceconfig                 get
storage.nmp.psp.roundrobin.deviceconfig                 set
storage.nmp.satp.generic.deviceconfig                   get
storage.nmp.satp.generic.deviceconfig                   set
storage.nmp.satp.generic.pathconfig                     get
storage.nmp.satp.generic.pathconfig                     set
storage.nmp.satp                                        list
storage.nmp.satp.rule                                   add
storage.nmp.satp.rule                                   list
storage.nmp.satp.rule                                   remove
storage.nmp.satp                                        set
storage.san.fc.events                                   clear
storage.san.fc.events                                   get
storage.san.fc                                          list
storage.san.fc                                          reset
storage.san.fc.stats                                    get
storage.san.fcoe                                        list
storage.san.fcoe                                        reset
storage.san.fcoe.stats                                  get
storage.san.iscsi                                       list
storage.san.iscsi.stats                                 get
storage.san.sas                                         list
storage.san.sas                                         reset
storage.san.sas.stats                                   get
storage.vmfs.extent                                     list
storage.vmfs.snapshot.extent                            list
storage.vmfs.snapshot                                   list
storage.vmfs.snapshot                                   mount
storage.vmfs.snapshot                                   resignature
storage.vmfs                                            upgrade
system.boot.device                                      get
system.coredump.network                                 check
system.coredump.network                                 get
system.coredump.network                                 set
system.coredump.partition                               get
system.coredump.partition                               list
system.coredump.partition                               set
system.hostname                                         get
system.hostname                                         set
system.maintenanceMode                                  get
system.maintenanceMode                                  set
system.module                                           get
system.module                                           list
system.module                                           load
system.module.parameters                                list
system.module.parameters                                set
system.module                                           set
system.process                                          list
system.process.stats.load                               get
system.process.stats.running                            get
system.secpolicy.domain                                 list
system.secpolicy.domain                                 set
system.settings.advanced                                list
system.settings.advanced                                set
system.settings.kernel                                  list
system.settings.kernel                                  set
system.settings.keyboard.layout                         get
system.settings.keyboard.layout                         list
system.settings.keyboard.layout                         set
system.shutdown                                         poweroff
system.shutdown                                         reboot
system.snmp                                             get
system.snmp                                             hash
system.snmp                                             set
system.snmp                                             test
system.stats.uptime                                     get
system.syslog.config                                    get
system.syslog.config.logger                             list
system.syslog.config.logger                             set
system.syslog.config                                    set
system.syslog                                           mark
system.syslog                                           reload
system.time                                             get
system.time                                             set
system.uuid                                             get
system.version                                          get
system.visorfs                                          get
system.visorfs.ramdisk                                  add
system.visorfs.ramdisk                                  list
system.visorfs.ramdisk                                  remove
system.visorfs.tardisk                                  list
system.welcomemsg                                       get
system.welcomemsg                                       set
vm.process                                              kill
vm.process                                              list

 

~ # esxcli software acceptance get
PartnerSupported

~ # esxcli software vib list
Name                           Version                               Vendor  Acceptance Level  Install Date
-----------------------------  ------------------------------------  ------  ----------------  ------------
ata-pata-amd                   0.3.10-3vmw.510.0.0.799733            VMware  VMwareCertified   2014-05-22
ata-pata-atiixp                0.4.6-4vmw.510.0.0.799733             VMware  VMwareCertified   2014-05-22
ata-pata-cmd64x                0.2.5-3vmw.510.0.0.799733             VMware  VMwareCertified   2014-05-22
ata-pata-hpt3x2n               0.3.4-3vmw.510.0.0.799733             VMware  VMwareCertified   2014-05-22
ata-pata-pdc2027x              1.0-3vmw.510.0.0.799733               VMware  VMwareCertified   2014-05-22
ata-pata-serverworks           0.4.3-3vmw.510.0.0.799733             VMware  VMwareCertified   2014-05-22
~ # esxcli software vib get -n ata-pata-amd
VMware_bootbank_ata-pata-amd_0.3.10-3vmw.510.0.0.799733
   Name: ata-pata-amd
   Version: 0.3.10-3vmw.510.0.0.799733
   Type: bootbank
   Vendor: VMware
   Acceptance Level: VMwareCertified
   Summary: pata_amd: ata driver for VMware ESX
   Description: AMD/NVidia PATA Driver
   ReferenceURLs:
   Creation Date: 2012-08-02
   Depends: vmkapi_2_1_0_0, com.vmware.driverAPI-9.2.1.0, com.vmware.libata-9.2.1.0
   Conflicts:
   Replaces:
   Provides:
   Maintenance Mode Required: True
   Hardware Platforms Required:
   Live Install Allowed: False
   Live Remove Allowed: False
   Stateless Ready: True
   Overlay: False
   Tags: driver, module
   Payloads: ata-pata
~ # esxcli software profile get
(Updated) ESXi-5.1.0-20130402001-standard
   Name: (Updated) ESXi-5.1.0-20130402001-standard
   Vendor: localhost
   Creation Time: 2014-05-23T18:02:36
   Modification Time: 2015-02-16T06:28:57
   Stateless Ready: True
   Description:

      2014-05-23T18:02:29.976940+00:00: The following VIBs are
      installed:
        vmware-fdm    5.1.0-799731
      ----------
      For more information, see http://kb.vmware.com/kb/2041635.

 

你可能感兴趣的:(虚拟化之esxi命令行管理)