vSphere Command-Line Interface Concepts and Examples ESXi 6.5 vCenter Server 6.5 This document supports the version of each product listed and supports all subsequent versions until the document is replaced by a new edition. To check for more recent editions of this document, see http://www.vmware.com/support/pubs.
vSphere Command-Line Interface Concepts and Examples You can find the most up-to-date technical documentation on the VMware Web site at: http://www.vmware.com/support/ The VMware Web site also provides the latest product updates. If you have comments about this documentation, submit your feedback to: docfeedback@vmware.com Copyright © 2007–2017 VMware, Inc. All rights reserved. Copyright and trademark information. VMware, Inc. 3401 Hillview Ave. Palo Alto, CA 94304 www.vmware.com 2 VMware, Inc.
Contents About This Book 9 1 vSphere CLI Command Overviews 11 Introduction 11 Documentation 12 Command-Line Help 12 List of Available Host Management Commands 13 Targets and Protocols for vCLI Host Management Commands 15 Supported Platforms for vCLI Commands 15 Commands with an esxcfg Prefix 16 ESXCLI Commands Available on Different ESXi Hosts 17 Trust Relationship Requirement for ESXCLI Commands 17 Download and Install the vCenter Server Certificate 17 Using the --cacertsfile Option 18 Using the --thumb
vSphere Command-Line Interface Concepts and Examples 3 Managing Files 29 Introduction to Virtual Machine File Management 29 Managing the Virtual Machine File System with vmkfstools 30 Upgrading VMFS3 Volumes to VMFS5 31 Managing VMFS Volumes 31 Managing Duplicate VMFS Datastores 32 Mounting Datastores with Existing Signatures 32 Resignaturing VMFS Copies 33 Reclaiming Unused Storage Space 34 Using vifs to View and Manipulate Files on Remote ESXi Hosts 35 vifs Options 36 vifs Examples 37 4 Managing Storag
Contents Running svmotion in Interactive Mode 64 Running svmotion in Noninteractive Mode Configuring FCoE Adapters 65 Scanning Storage Adapters 66 Retrieving SMART Information 66 64 5 Managing iSCSI Storage 69 iSCSI Storage Overview 69 Discovery Sessions 70 Discovery Target Names 71 Protecting an iSCSI SAN 71 Protecting Transmitted Data 71 Securing iSCSI Ports 72 Setting iSCSI CHAP 72 Command Syntax for esxcli iscsi and vicfg-iscsi 73 esxcli iscsi Command Syntax 74 Key to esxcli iscsi Short Options 74 v
vSphere Command-Line Interface Concepts and Examples 6 Managing Third-Party Storage Arrays 101 Managing NMP with esxcli storage nmp 101 Device Management with esxcli storage nmp device 102 Listing Paths with esxcli storage nmp path 102 Managing Path Selection Policy Plug-Ins with esxcli storage nmp psp Fixed Path Selection Policy Operations 104 Customizing Round Robin Setup 105 Managing SATPs 106 Path Claiming with esxcli storage core claiming 108 Using the Reclaim Troubleshooting Command 109 Unclaiming P
Contents Setting Up vSphere Networking with vSphere Standard Switches 136 Setting Up Virtual Switches and Associating a Switch with a Network Interface Retrieving Information About Virtual Switches 137 Adding and Deleting Virtual Switches 138 Checking, Adding, and Removing Port Groups 139 Managing Uplinks and Port Groups 140 Setting the Port Group VLAN ID 141 Managing Uplink Adapters 142 Adding and Modifying VMkernel Network Interfaces 145 136 Setting Up vSphere Networking with vSphere Distributed Swit
vSphere Command-Line Interface Concepts and Examples 8 VMware, Inc.
About This Book vSphere Command-Line Interface Concepts and Examples explains how to use the commands in the VMware ® vSphere Command-Line Interface (vCLI) and includes command overviews and examples. Intended Audience This book is for experienced Windows or Linux system administrators who are familiar with vSphere administration tasks and data center operations and know how to use commands in scripts.
vSphere Command-Line Interface Concepts and Examples 10 VMware, Inc.
vSphere CLI Command Overviews 1 This chapter introduces the command set, presents supported commands for different versions of vSphere, lists connection options, and discusses vCLI and lockdown mode.
vSphere Command-Line Interface Concepts and Examples vCLI Commands Description Other commands (vmware-cmd, vifs, vmkfstools) Commands implemented in Perl that do not have a vicfg- prefix. These commands are scheduled to be deprecated or replaced by ESXCLI commands. DCLI commands Manage VMware SDDC services. DCLI is a CLI client to the vSphere Automation SDK interface for managing VMware SDDC services.
Chapter 1 vSphere CLI Command Overviews List of Available Host Management Commands vCLI host management commands from earlier versions have been replaced with commands that have equivalent functionality. The following table lists vCLI host management commands in alphabetical order and the corresponding ESXCLI command if available. For ESXCLI, new commands and namespaces are added with each release. See the Release Notes for the corresponding release for information.
vSphere Command-Line Interface Concepts and Examples vCLI 4.1 Command vCLI 5.1 and later Command vicfg-module esxcli system module Enables VMkernel options. Use this command with the options listed in this document, or as instructed by VMware. See “Managing VMkernel Modules,” on page 25. vicfg-mpath vicfg-mpath35 esxcli storage core path Configures storage arrays. See “Managing Paths,” on page 50. vicfg-nas esxcli storage nfs Manages NAS/NFS filesystems.
Chapter 1 vSphere CLI Command Overviews vCLI 4.1 Command vCLI 5.1 and later Command vmkfstools vmkfstools (No ESXCLI equivalent) Creates and manipulates virtual disks, file systems, logical volumes, and physical storage devices on an ESXi host. See “Managing the Virtual Machine File System with vmkfstools,” on page 30. vmware-cmd vmware-cmd (No ESXCLI equivalent) Performs virtual machine operations remotely.
vSphere Command-Line Interface Concepts and Examples Command ESXi 5.x and 6.x vCenter Server 5.x and 6.x ESXi 4.x ESX 4.x vCenter Server 4.
Chapter 1 vSphere CLI Command Overviews Command with vicfg Prefix Command with esxcfg Prefix vicfg-mpath esxcfg-mpath vicfg-nas esxcfg-nas vicfg-nics esxcfg-nics vicfg-ntp esxcfg-ntp vicfg-rescan esxcfg-rescan vicfg-route esxcfg-route vicfg-scsidevs esxcfg-scsidevs vicfg-snmp esxcfg-snmp vicfg-syslog esxcfg-syslog vicfg-vmknic esxcfg-vmknic vicfg-volume esxcfg-volume vicfg-vswitch esxcfg-vswitch ESXCLI Commands Available on Different ESXi Hosts The available ESXCLI commands depend
vSphere Command-Line Interface Concepts and Examples 5 Add the trusted root certificates to the list of trusted roots. The process differs depending on the platform that you are on. What to do next You can now run ESXCLI commands against any host that is managed by the trusted vCenter Server system without supplying additional information if you specify the vCenter Server system in the --server option and the ESXi host in the --vihost option.
Chapter 1 vSphere CLI Command Overviews Using ESXCLI Output Many ESXCLI commands generate output you might want to use in your application. You can run esxcli with the --formatter dispatcher option and send the resulting output as input to a parser. The --formatter options supports three values - csv, xml, and keyvalue and is used before any namespace. The following example lists all file system information in CSV format. esxcli --formatter=csv storage filesystem list You can pipe the output to a file.
vSphere Command-Line Interface Concepts and Examples To make changes to ESXi systems in lockdown mode, you must go through a vCenter Server system that manages the ESXi system as the user vpxuser and include both the --server and --vihost parameters. esxcli --server MyVC --vihost MyESXi storage filesystem list The command prompts for the vCenter Server system user name and password. The following commands cannot run against vCenter Server systems and are therefore not available in lockdown mode.
Managing Hosts 2 Host management commands can stop and reboot ESXi hosts, back up configuration information, and manage host updates. You can also use a host management command to make your host join an Active Directory domain or exit from a domain. For information on updating ESXi 5.0 hosts with the esxcli software command and on changing the host acceptance level to match the level of a VIB that you might want to use for an update, see the vSphere Upgrade documentation in the vSphere 5.
vSphere Command-Line Interface Concepts and Examples Stopping, Rebooting, and Examining Hosts with vicfg-hostops You can shut down or reboot an ESXi host by using the vSphere Web Client, or ESXCLI or the vicfg-hostops vCLI command. Shutting down a managed host disconnects it from the vCenter Server system, but does not remove the host from the inventory. You can shut down a single host or all hosts in a data center or cluster.
Chapter 2 Managing Hosts When you run the vicfg-hostops vCLI command, you can specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . Procedure 1 To enter maintenance mode, run the following command. esxcli system maintenanceMode set --enable true After all virtual machines on the host have been suspended or migrated, the host enters maintenance mode.
vSphere Command-Line Interface Concepts and Examples Backing Up Configuration Information with vicfg-cfgbackup After you configure an ESXi host, you can back up the host configuration data. You should always back up your host configuration after you change the configuration or upgrade the ESXi image. Important The vicfg-cfgbackup command is available only for ESXi hosts. The command is not available through a vCenter Server system connection. No equivalent ESXCLI command is supported.
Chapter 2 Managing Hosts 4 (Optional) To restore the host to factory settings, run vicfg-cfgbackup with the -r option. vicfg-cfgbackup -r Using vicfg-cfgbackup from vMA To back up a host configuration, you can run vicfg-cfgbackup from a vMA instance. The vMA instance can run on the host that you are backing up or restoring, also referred to as the target host, or on a remote host. To restore a host configuration, you must run vicfg-cfgbackup from a vMA instance running on a remote host.
vSphere Command-Line Interface Concepts and Examples 4 Set the parameter. esxcli system module parameters set --module=module_name --parameterstring="parameter_string" 5 Verify that the module is configured. esxcli system module parameters list --module=module_name Manage Modules with vicfg-module Not all VMkernel modules have settable module options. The following example illustrates how the examine and enable a VMkernel modules.
Chapter 2 Managing Hosts 2 Configure the ESXi system’s DNS to be in the Active Directory domain. Set Up Active Directory to Work with ESXi You can run vicfg-authconfig to add the ESXi host to the Active Directory domain. You can run the command directly against the host or against a vCenter Server system, specifying the host with --vihost. Prerequisites n Verify that you have installed the ESXi host, as explained in the vSphere Installation and Setup documentation.
vSphere Command-Line Interface Concepts and Examples 28 n Update ESXi 5.5 hosts with esxcli software vib commands discussed in the vSphere Upgrade documentation included in the vSphere 5.5 documentation set. n Update ESXi 6.0 hosts with esxcli software vib commands discussed in the vSphere Upgrade documentation included in the vSphere 6.0 documentation set. n Update ESXi 6.5 hosts with esxcli software vib commands discussed in the vSphere Upgrade documentation included in the vSphere 6.
Managing Files 3 The vSphere CLI includes two commands for file manipulation. vmkfstools allows you to manipulate VMFS (Virtual Machine File System) and virtual disks. vifs supports remote interaction with files on your ESXi host. Note See Chapter 4, “Managing Storage,” on page 41 for information about storage manipulation commands.
vSphere Command-Line Interface Concepts and Examples n Network File System (NFS) - The NFS client built into ESXi uses the NFS protocol over TCP/IP to access a designated NFS volume that is located on a NAS server. The ESXi host can mount the volume and use it for its storage needs. vSphere supports versions 3 and 4.1 of the NFS protocol. Typically, the NFS volume or directory is created by a storage administrator and is exported form the NFS server.
Chapter 3 Managing Files You use the vmkfstools vCLI to create and manipulate virtual disks, file systems, logical volumes, and physical storage devices on an ESXi host. You can use vmkfstools to create and manage a virtual machine file system on a physical partition of a disk and to manipulate files, such as virtual disks, stored on VMFS-3 and NFS. You can also use vmkfstools to set up and manage raw device mappings (RDMs).
vSphere Command-Line Interface Concepts and Examples esxcli storage vmfs snapshot commands can be used for listing, mounting, and resignaturing snapshot volumes. See “Mounting Datastores with Existing Signatures,” on page 32 and “Resignaturing VMFS Copies,” on page 33. Managing Duplicate VMFS Datastores In some cases VMFS datastores can have duplicate UUIDs. Each VMFS datastore created in a LUN has a unique UUID that is stored in the file system superblock.
Chapter 3 Managing Files What to do next You can later run esxcli storage filesystem volume unmount to unmount the snapshot volume. esxcli storage filesystem volume unmount --volume-label=
vSphere Command-Line Interface Concepts and Examples You can resignature a VMFS copy with ESXCLI or with vicfg-volume. See “Resignature a VMFS Copy with ESXCLI,” on page 34 or “Resignature a VMFS Copy with vicfg-volume,” on page 34. Resignature a VMFS Copy with ESXCLI The esxcli storage vmfs snapshot commands support resignaturing a snapshot volume. Specify one of the connection options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of .
Chapter 3 Managing Files The following examples illustrate how to use the command.
vSphere Command-Line Interface Concepts and Examples vSphere 4.x vSphere 5.0 Host Host configuration files. You must specify the file’s unique name identifier. Specify host locations by using the /host/ syntax. Host configuration files. You must specify the file’s unique name identifier. Specify host locations by using the /host/ syntax. You cannot list subdirectories of /host. Temp The /tmp directory and files in that directory. Specify temp locations by using the /tmp/dir/subdir syntax.
Chapter 3 Managing Files Command Description Target Syntax --get -g Downloads a file from the ESXi host to the machine on which you run vCLI. This operation uses HTTP GET. Datastore Host get src_dstore_file_path dst_local_file_path get src_d store_dir_path dst_local_file_path --listdc -C Lists the data center paths available on an ESXi system. Datastore Host --listds -S Lists the datastore names on the ESXi system.
vSphere Command-Line Interface Concepts and Examples You can use each name that has been returned to refer to datastore paths by using square bracket notation. '[my_datastore] dir/subdir/file' n List the content of a directory in a datastore. vifs --server --username root --password --dir '[Storage1]' vifs --server --username root --password --dir '[Storage1] WindowsXP' The command lists the directory content.
Chapter 3 Managing Files n Forcibly remove a file on the remote server with --rm --force. vifs --server --username root --password --rm '[Storage1] test2/testfile2' --force n Move a file from one location on the remote server to another location with --move . If you specify a file name, the file is moved and renamed at the same time.
vSphere Command-Line Interface Concepts and Examples 40 VMware, Inc.
Managing Storage 4 A virtual machine uses a virtual disk to store its operating system, program files, and other data associated with its activities. A virtual disk is a large physical file, or a set of files, that can be copied, moved, archived, and backed up. To store virtual disk files and manipulate the files, a host requires dedicated storage space. ESXi storage is storage space on a variety of physical storage systems, local or networked, that a host uses to store virtual machine disks.
vSphere Command-Line Interface Concepts and Examples Introduction to Storage Fibre Channel SAN arrays, iSCSI SAN arrays, and NAS arrays are widely used storage technologies supported by VMware vSphere to meet different data center storage needs. The storage arrays are connected to and shared between groups of servers through storage area networks. This arrangement allows aggregation of the storage resources and provides more flexibility in provisioning them to virtual machines. Figure 4‑1.
Chapter 4 Managing Storage Figure 4‑2. Virtual Machines Accessing Different Types of Storage Host requires TCP/IP connectivity local ethernet SCSI software initiator VMFS fibre channel HBA iSCSI hardware initiator ethernet NIC ethernet NIC LAN LAN LAN LAN VMFS VMFS VMFS NFS fibre array iSCSI array NAS appliance You can use vCLI commands to manage the virtual machine file system and storage devices.
vSphere Command-Line Interface Concepts and Examples n Virtual Flash storage - Use commands in the esxcli storage vflash namespace to manage VMware vSphere Flash Read Cache. n Virtual volumes - Virtual volumes offer a different layer of abstraction than datastores. As a result, finer-grained management is possible. Use commands in the esxcli storage vvol namespace.
Chapter 4 Managing Storage Typically, the path to the device has the following format. vmhba:C:T:L n vmbh is the name of the storage adapter. The name refers to the physical adapter on the host, not the SCSI controller used by the virtual machines. n C is the storage channel number. Software iSCSI adapters and dependent hardware adapters use the channel number to show multiple paths to the same target. n T is the target number.
vSphere Command-Line Interface Concepts and Examples Examining LUNs with esxcli storage core You can use esxcli storage core to display information about available LUNs on ESXi 5.0. You can run one of the following commands to examine LUNs. Specify one of the connection options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . n List all logical devices known on this system with detailed information.
Chapter 4 Managing Storage Examining LUNs with vicfg-scsidevs You can use vicfg-scsidevs to display information about available LUNs on ESXi 4.x hosts. Important You can run vicfg-scsidevs --query and vicfg-scsidevs --vmfs against ESXi version 3.5. The other options are supported only against ESXi version 4.0 and later. You can run one of the following commands to examine LUNs.
vSphere Command-Line Interface Concepts and Examples n Print HBA devices with identifying information. vicfg-scsidevs --hbas The return value includes the adapter ID, driver ID, adapter UID, PCI, vendor, and model. n Print a mapping between HBAs and the devices it provides paths to.
Chapter 4 Managing Storage Reattach a Device When you have completed storage reconfiguration, you can reattach the storage device, mount the datastore, and restart the virtual machines. Prerequisites Make sure you are familiar with datastore mounting. See“Mounting Datastores with Existing Signatures,” on page 32. Procedure 1 (Optional) Check whether the device is detached. esxcli storage core device detached list 2 Attach the device. esxcli storage core device set -d naa.
vSphere Command-Line Interface Concepts and Examples 2 Remove any users of the device. You cannot bring a device back without removing active users. The ESXi host cannot know whether the device that was added back has changed. ESXi must be able to treat the device similarly to a new device being discovered. 3 Perform a rescan to get the device back in working order. Managing Paths To maintain a constant connection between an ESXi host and its storage, ESXi supports multipathing.
Chapter 4 Managing Storage Figure 4‑4. FC Multipathing Host 2 Host 1 HBA2 HBA1 HBA3 HBA4 switch switch SP1 SP2 storage array If SP1 or the link between SP1 and the switch breaks, SP2 takes over and provides the connection between the switch and the storage device. This process is called SP failover. ESXi multipathing supports HBA and SP failover. After you have set up your hardware to support multipathing, you can use the vSphere Web Client or vCLI commands to list and manage paths.
vSphere Command-Line Interface Concepts and Examples You can display information about paths by running esxcli storage core path. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . n List all devices with their corresponding paths, state of the path, adapter type, and other information. esxcli storage core path list n Limit the display to only a specified path or device.
Chapter 4 Managing Storage n List detailed information for the paths for the device specified with --device. vicfg-mpath -l -d mpx.vmhba32:C0:T1:L0 vicfg-mpath --list --device naa.60060... Changing the State of a Path You can change the state of a path with ESXCLI or with vicfg-mpath. Disable a Path with ESXCLI You can temporarily disable a path with ESXCLI for maintenance or other reasons, and enable the path when you need it again.
vSphere Command-Line Interface Concepts and Examples Managing Path Policies For each storage device managed by NMP, and not PowerPath, an ESXi host uses a path selection policy. If you have a third-party PSP installed on your host, its policy also appears on the list. Supported Path Policies The following path policies are supported by default. Policy Description VMW_PSP_FIXED The host uses the designated preferred path, if it has been configured.
Chapter 4 Managing Storage n If VMW_SATP_ALUA is assigned to a specific storage device, but the device is not ALUA-aware, no claim rule match occurs for this device. The device is claimed by the default SATP based on the device's transport type. n The default PSP for all devices claimed by VMW_SATP_ALUA is VMW_PSP_MRU. The VMW_PSP_MRU selects an active/optimized path as reported by the VMW_SATP_ALUA, or an active/unoptimized path if there is no active/optimized path.
vSphere Command-Line Interface Concepts and Examples 4 (Optional) If you specified the VMW_PSP_FIXED policy, you must make sure the preferred path is set correctly. a Check which path is the preferred path for a device. esxcli storage nmp psp fixed deviceconfig get --device naa.xxx b If necessary, change the preferred path. esxcli storage nmp psp fixed deviceconfig set --device naa.xxx --path vmhba3:C0:T5:L3 The command sets the preferred path to vmhba3:C0:T5:L3.
Chapter 4 Managing Storage No vicfg- command exists for performing the operations. The ESXCLI commands for setting round robin path options have changed. The commands supported in ESXi 4.x are no longer supported. Procedure 1 Retrieve path selection settings for a device that is using the roundrobin PSP. esxcli storage nmp psp roundrobin deviceconfig get --device na.xxx 2 Set the path selection. You can specify when the path should change, and whether unoptimized paths should be included.
vSphere Command-Line Interface Concepts and Examples Typically, the NFS volume or directory is created by a storage administrator and is exported from the NFS server. The NFS volume does not need to be formatted with a local file system, such as VMFS. You can mount the volume directly on ESXi hosts, and use it to store and boot virtual machines in the same way that you use VMFS datastores.
Chapter 4 Managing Storage 2 Add a new NAS file system to the ESXi host. Specify the NAS server with --host, the volume to use for the mount with --volume-name, and the share name on the remote system to use for this NAS mount point with --share. esxcli storage nfs add --host=dir42.eng.vmware.com --share=/ -volume-name=nfsstore-dir42 This command adds an entry to the known NAS file system list and supplies the share name of the new NAS file system.
vSphere Command-Line Interface Concepts and Examples For FC and FCoE devices, you can retrieve FC events such as RSCN, LINKUP, LINKDOWN, Frame Drop and FCoE CVL. The commands log a warning in the VMkernel log if it encounters too many Link Toggling or frame drops. The following example examines and resets SAN storage through a FibreChannel adapter. Instead of fc, the information retrieval commands can also use iscsi, fcoe, and sas. Procedure 1 List adapter attributes.
Chapter 4 Managing Storage Procedure 1 Join the target host to a given Virtual SAN cluster. esxcli vsan cluster join --cluster-uuid Note The UUID of the cluster is required. 2 Verify that the target host is joined to a Virtual SAN cluster. esxcli vsan cluster get 3 Remove the target host from the Virtual SAN cluster. esxcli vsan cluster leave Add and Remove Virtual SAN Storage You can use ESXCLI commands to add and remove Virtual SAN storage.
vSphere Command-Line Interface Concepts and Examples Monitoring vSphere Flash Read Cache Flash Read Cache™ lets you accelerate virtual machine performance through the use of host resident flash devices as a cache. The vSphere Storage documentation discusses vSphere Flash Read Cache in some detail. You can reserve a Flash Read Cache for any individual virtual disk.
Chapter 4 Managing Storage The following ESXCLI commands are available for managing display information about virtual volumes and for unbinding all Virtual Volumes from all vendor providers. See the vSphere Storage documentation for information on creating Virtual Volumes and configuring multipathing and SCSI-based endpoints. Table 4‑2. VVol Commands Command Description storage vvol daemon unbindall Unbinds all Virtual Volume instances from all storage providers that are known to the ESXi host.
vSphere Command-Line Interface Concepts and Examples n Virtual machine disks must be in persistent mode or be raw device mappings (RDMs). For physical and virtual compatibility mode RDMs, you can migrate the mapping file only. For virtual compatibility mode RDMs, you can use the vSphere Web Client to convert to thick-provisioned or thin-provisioned disks during migration as long as the destination is not an NFS datastore. You cannot use the svmotion command to perform this conversion.
Chapter 4 Managing Storage 2 Choose the VMX file for the virtual machine of interest. By default, the virtual disk file has the same name as the VMX file but has a .vmdk extension. 3 (Optional) Use vifs to verify that you are using the correct VMDK file. Relocate a Virtual Machine's Storage You can relocate a virtual machine's storage including the disks. Procedure 1 Determine the path to the virtual machine configuration file. 2 Run svmotion by using the following syntax.
vSphere Command-Line Interface Concepts and Examples n A software FCoE adapter is a software code that performs some of the FCoE processing. The adapter can be used with a number of NICs that support partial FCoE offload. Unlike the hardware FCoE adapter, the software adapter must be activated. Scanning Storage Adapters You must perform a rescan operation each time you reconfigure your storage setup.
Chapter 4 Managing Storage Driver Rated Max Temperature Write Sectors TOT Count Read Sectors TOT Count Initial Bad Block Count VMware, Inc.
vSphere Command-Line Interface Concepts and Examples 68 VMware, Inc.
Managing iSCSI Storage 5 ESXi systems include iSCSI technology to access remote storage using an IP network. You can use the vSphere Web Client, commands in the esxcli iscsi namespace, or the vicfg-iscsi command to configure both hardware and software iSCSI storage for your ESXi system. See the vSphere Storage documentation for additional information.
vSphere Command-Line Interface Concepts and Examples n Independent hardware iSCSI adapter - Leverages its own iSCSI management and configuration interfaces. See the vSphere Storage documentation for details on setup and failover scenarios. You must configure iSCSI initiators for the host to access and display iSCSI storage devices. Figure 5-1 depicts hosts that use different types of iSCSI initiators.
Chapter 5 Managing iSCSI Storage Discovery Target Names The target name is either an IQN name or an EUI name. The IQN and EUI names use specific formats. n The IQN name uses the following format. iqn.yyyy-mm.{reversed domain name}:id_string The following IQN name contains example values. iqn.2007-05.com.mydomain:storage.tape.sys3.abc The ESXi host generates an IQN name for software iSCSI and dependent hardware iSCSI adapters. You can change that default IQN name.
vSphere Command-Line Interface Concepts and Examples You can also configure your iSCSI SAN on its own VLAN to improve performance and security. Placing your iSCSI configuration on a separate VLAN ensures that no devices other than the iSCSI adapter can see transmissions within the iSCSI SAN. With a dedicated VLAN, network congestion from other sources cannot interfere with iSCSI traffic.
Chapter 5 Managing iSCSI Storage Table 5‑1. Supported Levels for CHAP Level Description Supported chapProhibited Host does not use CHAP authentication. If authentication is enabled, specify chapProhibited to disable it. Software iSCSI Dependent hardware iSCSI Independent hardware iSCSI chapDiscouraged Host uses a non-CHAP connection, but allows a CHAP connection as fallback.
vSphere Command-Line Interface Concepts and Examples esxcli iscsi Command Syntax The esxcli iscsi command includes a number of nested namespaces. The following table illustrates the namespace hierarchy. Commands at each level are included in bold. Many namespaces include both commands and namespaces.
Chapter 5 Managing iSCSI Storage Table 5‑3. Short Options for iSCSI ESXCLI Command Options (Continued) Lower-case Option Option Upper-case Option Option g --gateway i --ip I --inherit k --key l --level m --method M --module n --nic N --authname, --name o --option p --plugin s --isid, subnet, switch S --state, secret v --value Number Option vicfg-iscsi Command Syntax vicfg-iscsi supports a comprehensive set of options. Table 5‑4.
vSphere Command-Line Interface Concepts and Examples Table 5‑4. Options for vicfg-iscsi (Continued) Option Suboptions Description -D --discovery -a -i ] --add --ip [:] Adds a dynamic discovery address. -D --discovery -l --list Lists dynamic discovery addresses.
Chapter 5 Managing iSCSI Storage Table 5‑4. Options for vicfg-iscsi (Continued) Option Suboptions Description -M --mtu -p -M --pnp - -mtu Sets MTU size. Used with the --pnp option. -S --static -l --list Lists static discovery addresses.
vSphere Command-Line Interface Concepts and Examples iSCSI Storage Setup with ESXCLI You can set up iSCSI storage by using commands in the esxcli iscsi namespace. You can also set up iSCSI storage by using the vSphere Web Client or vicfg-iscsi commands. See “iSCSI Storage Setup with vicfg-iscsi,” on page 84. Set Up Software iSCSI with ESXCLI Software iSCSI setup requires a number of high-level tasks. You should be familiar with the corresponding command for each task.
Chapter 5 Managing iSCSI Storage 6 Add a dynamic discovery address or a static discovery address. n With dynamic discovery, all storage targets associated with a host name or IP address are discovered. You can run the following command. esxcli iscsi adapter discovery sendtarget add --address= -adapter= n With static discovery, you must specify the host name or IP address and the iSCSI name of the storage target. You can run the following command.
vSphere Command-Line Interface Concepts and Examples 9 10 (Optional) Set iSCSI parameters. Option Command Adapter-level CHAP esxcli iscsi adapter param set --adapter= -key= --value= Discovery-level CHAP esxcli iscsi adapter discovery sendtarget param set -adapter= --key= --value= -address= Target-level CHAP esxcli iscsi adapter target portal param set -adapter= --key= --value= -address= --name=
Chapter 5 Managing iSCSI Storage 3 Set up port binding. a Identify the VMkernel port of the dependent hardware iSCSI adapter. esxcli iscsi logicalnetworkportal list --adapter= b Connect the dependent hardware iSCSI initiator to the iSCSI VMkernel ports by running the following command for each port. esxcli iscsi networkportal add --nic= -adapter= c Verify that the ports were added to the dependent hardware iSCSI initiator.
vSphere Command-Line Interface Concepts and Examples 6 (Optional) Set the authentication information for mutual CHAP by running esxcli iscsi adapter auth chap set again with --direction set to mutual and a different authentication user name and secret.
Chapter 5 Managing iSCSI Storage Prerequisites n Verify that you are familiar with iSCSI authentication. See “Enabling iSCSI Authentication,” on page 94. n Verify that you are familiar with CHAP. See “Setting iSCSI CHAP,” on page 72. n Verify that you are familiar with iSCSI parameters. See “Listing and Setting iSCSI Parameters,” on page 90. Procedure 1 Determine the iSCSI adapter type and retrieve the iSCSI adapter ID.
vSphere Command-Line Interface Concepts and Examples 5 (Optional) Set the authentication information for CHAP. You can set per-target CHAP for static targets, per-adapter CHAP, or apply the command to the discovery address.
Chapter 5 Managing iSCSI Storage Set Up Software iSCSI with vicfg-iscsi Software iSCSI setup requires a number of high-level tasks. You should be familiar with the corresponding command for each task. You can refer to the relevant documentation for each command. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . Prerequisites n Verify that you are familiar with iSCSI authentication.
vSphere Command-Line Interface Concepts and Examples The target (-i) and name (-n) option determine what the command applies to. 7 Option Result -i and -n Command applies to per-target CHAP for static targets. Only -i Command applies to the discovery address. Neither -i nor -n Command applies to per-adapter CHAP. (Optional) Set the authentication information for mutual CHAP by running vicfg-iscsi -A again with the -b option and a different authentication user name and password.
Chapter 5 Managing iSCSI Storage 3 Set up port binding. a Identify the VMkernel port of the dependent hardware iSCSI adapter. esxcli swiscsi vmknic list -d b Connect the dependent hardware iSCSI initiator to the iSCSI VMkernel ports by running the following command for each port. esxcli swiscsi nic add -n -d c Verify that the ports were added to the dependent hardware iSCSI initiator.
vSphere Command-Line Interface Concepts and Examples Hardware iSCSI setup requires a number of high-level tasks. You should be familiar with the corresponding command for each task. You can refer to the relevant documentation for each command or the manpage (Linux). Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . Prerequisites n Verify that you are familiar with iSCSI authentication.
Chapter 5 Managing iSCSI Storage The target (-i) and name (-n) option determine what the command applies to. Option Result -i and -n Command applies to per-target CHAP for static targets. Only -i Command applies to the discovery address. Neither -i nor -n Command applies to per-adapter CHAP. Note Mutual CHAP is not supported for independent hardware iSCSI storage. 6 (Optional) Set iSCSI parameters by running vicfg-iscsi -W.
vSphere Command-Line Interface Concepts and Examples The system returns information about the vendor, model, description, and serial number of the HBA. n Run vicfg-iscsi -T | --target to list target information. vicfg-iscsi -T -l vicfg-iscsi --target --list The system returns information about targets for the specified adapter, including the iSCSI name, in IQN or EUI format, and alias. See “Discovery Target Names,” on page 71.
Chapter 5 Managing iSCSI Storage Parameter Type Command Adapter-level parameters esxcli iscsi adapter param set --adapter= --key= -value= Target-level parameters esxcli iscsi adapter target portal param set --adapter= -key= --value= --address= --name= Discovery-level parameters esxcli iscsi adapter discovery sendtarget param set --adapter= -key= --value= --address= The following table lists all settable parameters.
vSphere Command-Line Interface Concepts and Examples n Run esxcli iscsi adapter discovery sendtarget param get or esxcli iscsi adapter target portal param set to set iSCSI parameter options. If special characters are in the = sequence, for example, if you add a space, you must surround the sequence with double quotes (" = ").
Chapter 5 Managing iSCSI Storage Table 5‑6. Settable iSCSI Parameters (Continued) Parameter Description NoopOutInterval Time interval, in seconds, between NOP-Out requests sent from your iSCSI initiator to an iSCSI target. The NOP-Out requests serve as the ping mechanism to verify that a connection between the iSCSI initiator and the iSCSI target is active. Supported only at the initiator level. NoopOutTimeout Amount of time, in seconds, that can lapse before your host receives a NOP-In message.
vSphere Command-Line Interface Concepts and Examples The target (-i) and name (-n) option determine what the command applies to. Option Result -i and -n Command applies to per-target CHAP for static targets. Only -i Command applies to the discovery address. Neither -i nor -n Command applies to per-adapter CHAP. If special characters are in the = sequence, for example, if you add a space, you must surround the sequence with double quotes (" = ").
Chapter 5 Managing iSCSI Storage Procedure 1 (Optional) Set the authentication information for CHAP. esxcli iscsi adapter auth chap set --direction=uni --chap_username= -chap_password= --level=[prohibited, discouraged, preferred, required] --secret= --adapter= You can set per-target CHAP for static targets, per-adapter CHAP, or apply the command to the discovery address.
vSphere Command-Line Interface Concepts and Examples Procedure 1 Enable authentication. esxcli iscsi adapter auth chap set --direction=uni --chap_username= -chap_password= --level=[prohibited, discouraged, preferred, required] --secret= --adapter= The specified chap_username and secret must be supported on the storage side. 2 List possible VMkernel NICs to bind. esxcli iscsi logicalnetworkportal list 3 Enable mutual authentication.
Chapter 5 Managing iSCSI Storage Set Up Ports for iSCSI Multipathing With port binding, you create a separate VMkernel port for each physical NIC using 1:1 mapping. You can add all network adapter and VMkernel port pairs to a single vSwitch. The vSphere Storage documentation explains in detail how to specify port binding. You cannot set up ports for multipathing by using vicfg-iscsi.
vSphere Command-Line Interface Concepts and Examples Managing iSCSI Sessions To communicate with each other, iSCSI initiators and targets establish iSCSI sessions. You can use esxcli iscsi session to list and manage iSCSI sessions for software iSCSI and dependent hardware iSCSI. Introduction to iSCSI Session Management By default, software iSCSI and dependent hardware iSCSI initiators start one iSCSI session between each initiator port and each target port.
Chapter 5 Managing iSCSI Storage Logging in to iSCSI Sessions You can use esxcli iscsi session to log in to a session. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . n Log in to a session on the current software iSCSI or dependent hardware iSCSI configuration at the adapter level. esxcli iscsi session add --adapter= The following example applies custom values.
vSphere Command-Line Interface Concepts and Examples n Remove sessions from the current software iSCSI or dependent hardware iSCSI configuration with target and session ID. esxcli iscsi session remove --name= --isid= -adapter= iqn.xxxx is the target IQN, which you can determine by listing all sessions. session_id is the session's iSCSI ID. The following example applies custom values. esxcli --config /host-config-file iscsi session remove --name=iqn.
Managing Third-Party Storage Arrays 6 VMware partners and customers can optimize performance of their storage arrays in conjunction with VMware vSphere by using VMware PSA (pluggable storage architecture). The esxcli storage core namespace manages VMware PSA and the esxcli storage nmp namespace manages the VMware NMP plug-in.
vSphere Command-Line Interface Concepts and Examples Device Management with esxcli storage nmp device The device option performs operations on devices currently claimed by the VMware NMP. esxcli storage nmp device list The list command lists the devices controlled by VMware NMP and shows the SATP and PSP information associated with each device. To show the paths claimed by NMP, run esxcli storage nmp path list to list information for all devices, or for just one device with the --device option.
Chapter 6 Managing Third-Party Storage Arrays Managing Path Selection Policy Plug-Ins with esxcli storage nmp psp You can use esxcli storage nmp psp to manage VMware path selection policy plug-ins included with the VMware NMP and to manage third-party PSPs. Important When used with third-party PSPs, the syntax depends on the third-party PSP implementation.
vSphere Command-Line Interface Concepts and Examples Options Description --config -c Configuration string to set for the device or path specified by --device or --path. See “Managing Path Policies,” on page 54. --device -d Device for which you want to customize the path policy. --path -p Path for which you want to customize the path policy.
Chapter 6 Managing Third-Party Storage Arrays Customizing Round Robin Setup You can use the esxcli storage nmp psp roundrobin commands to set round robin path options on a device controlled by the VMW_PSP_RR PSP. Specifying and Customizing Round Robin Path Policies You can use esxcli storage nmp commands to set path policies. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . 1 Set the path policy to round robin.
vSphere Command-Line Interface Concepts and Examples Options Description --type -t Type of round robin path switching to enable for this device. The following values for type are supported. n bytes: Sets the trigger for path switching based on the number of bytes sent down a path. n default: Sets the trigger for path switching back to default values. iops: Sets the trigger for path switching based on the number of I/O operations on a path.
Chapter 6 Managing Third-Party Storage Arrays Option Description --model -M Model string to set when adding the SATP claim rule. Can be the model name or a pattern ^mod*, which matches all devices that start with mod. That is, the pattern successfully matches mod1 and modz, but not mymod1. The command supports the start/end (^) and wildcard (*) functionality but no other regular expressions. --transport -R Transport string to set when adding the SATP claim rule.
vSphere Command-Line Interface Concepts and Examples Retrieving and Setting SATP Configuration Parameters The esxcli storage nmp satp generic deviceconfig get and esxcli storage nmp satp generic pathconfig get commands retrieve per-device or per-path SATP configuration parameters. You cannot retrieve paths or devices for all SATPs, you must retrieve the information one path or one device at a time.
Chapter 6 Managing Third-Party Storage Arrays Using the Reclaim Troubleshooting Command The esxcli storage core claiming reclaim troubleshooting command is intended for PSA plug-in developers or administrators who troubleshoot PSA plug-ins. The command performs the following tasks. n Attempts to unclaim all paths to a device. n Runs the loaded claim rules on each of the unclaimed paths to reclaim those paths. It is normal for this command to fail if a device is in use.
vSphere Command-Line Interface Concepts and Examples Options Description --lun -L If --type is location, specifies the SCSI LUN for the paths to unclaim. If you do not specify --lun, unclaiming runs on paths with any LUN number. --model -m If --type is vendor, attempts to unclaim all paths to devices with specific model information (for multipathing plug-ins) or unclaim the device itself (for filter plug-ins).
Chapter 6 Managing Third-Party Storage Arrays Adding Claim Rules The esxcli storage core claimrule add command adds a claim rule to the set of claim rules on the system. You can use this command to add new claim rules or to mask a path using the MASK_PATH claim rule. You must load the rules after you add them. Options Description --adapter -A Adapter of the paths to use. Valid only if --type is location. --autoassign -u Adds a claim rule based on its characteristics.
vSphere Command-Line Interface Concepts and Examples Options Description --type -t Type of matching to use for the operation. Valid values are vendor, location, driver, and transport. --vendor -V Vendor of the paths to use. Valid only if --type is vendor. Valid values are values of the vendor string from the SCSI inquiry string. Run vicfgscsidevs -l on each device to see vendor string values. --wwnn World-Wide Node Number for the target to use in this operation.
Chapter 6 Managing Third-Party Storage Arrays Option Description --rule -r ID of the rule to be removed. Run esxcli storage core claimrule list to see the rule ID. The following example removes rule 1015. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . esxcli storage core claimrule remove -r 1015 Listing Claim Rules The list command lists all claim rules on the system.
vSphere Command-Line Interface Concepts and Examples Load and Apply Path Claim Rules You can run the esxcli storage core claimrule run command to apply claim rules that are loaded. If you do not call run, the system checks for claim rule updates every five minutes and applies them. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . Procedure 1 Modify rules and load them.
Chapter 6 Managing Third-Party Storage Arrays Options Description --type -t Type of claim to perform. By default, uses all, which means claim rules run without restriction to specific paths or SCSI addresses. Valid values are location, path, and all. --wait -w You can use this option only if you also use --type all. If the option is included, the claim waits for paths to settle before running the claim operation.
vSphere Command-Line Interface Concepts and Examples 116 VMware, Inc.
Managing Users 7 An ESXi system grants access to its resources when a known user with appropriate permissions logs on to the system with a password that matches the one stored for that user. You can use the vSphere SDK for all user management tasks. You cannot create ESXi users by using the vSphere Web Client. You can use the vicfg-user command to create, modify, delete, and list local direct access users on an ESXi host. You cannot run this command against a vCenter Server system.
vSphere Command-Line Interface Concepts and Examples vicfg-user Command Syntax The vicfg-user syntax differs from other vCLI commands. You specify operations by using the following syntax. vicfg-user -e -o If you create a user without specifying the role (--role), the user has no permissions. You cannot change the user's role, you can only change the user's permission.
Chapter 7 Managing Users You can manage users defined on the vCenter Server system and users defined on individual hosts separately. n Manage users defined on ESXi with the vSphere Web Services SDK or vicfg-user. n Manage vCenter Server users with the vSphere Web Client or the vSphere Web Services SDK. Important You cannot use the vicfg-user command to modify users created with the vSphere Client in vSphere 6.0 or earlier.
vSphere Command-Line Interface Concepts and Examples Full Name -: root UID -: 0 Shell Access -> 1 ------------------... -------------------Principal -: user27 Full Name -: UID -: 501 Shell Access -> 0 4 Modify the password for user user27. vicfg-user -e user -o modify -l user27 -p 27_password2 The system might return Updated user user27 successfully. 5 Assign read-only privileges to the user, who currently has no access.
Chapter 7 Managing Users The system displays permission information. The second column indicates whether the information is for a user or group. Principal Is Group Role ----------------------------------ABCDEFGH\esx^admins true Admin dcui false Admin root false Admin vpxuser false Admin test1 false ReadOnly 2 Set permissions for a user or group. Specify the ID of the user or group, and set the --group option to true to indicate a group. Specify one of three roles, Admin, ReadOnly or NoAccess.
vSphere Command-Line Interface Concepts and Examples 122 VMware, Inc.
Managing Virtual Machines 8 You can manage virtual machines with the vSphere Web Client or the vmware-cmd vCLI command. By using vmware-cmd you can register and unregister virtual machines, retrieve virtual machine information, manage snapshots, turn the virtual machine on and off, add and remove virtual devices, and prompt for user input. Some virtual machine management utility applications are included in the vSphere SDK for Perl.
vSphere Command-Line Interface Concepts and Examples Connection Options for vmware-cmd The vmware-cmd vCLI command supports only a specific set of connection options. Other vCLI connection options are not supported, for example, you cannot use variables because the corresponding option is not supported. The following connection options are supported. Option Description --server -H Target ESXi or vCenter Server system.
Chapter 8 Managing Virtual Machines List and Register Virtual Machines You can list, unregister, and register virtual machines by using vmware-cmd. Registering or unregistering a virtual machine means adding the virtual machine to the vCenter Server or ESXi inventory or removing the virtual machine. Important If you register a virtual machine with a vCenter Server system, and then remove it from the ESXi host, an orphaned virtual machine results.
vSphere Command-Line Interface Concepts and Examples You can use vmware-cmd options to retrieve a number of different virtual machine attributes. For a complete list of options, see the vSphere CLI Reference. n The guestinfo option allows you to retrieve information about the guest operating system. For example, you can retrieve the number of remote consoles allowed by a virtual machine by using guestinfo with the RemoteDisplay.maxConnections variable.
Chapter 8 Managing Virtual Machines n 100 – No heartbeat. Guest operating system might have stopped responding. Note You usually use the vmware-cmd guestinfo option only when VMware Support instructs you to do so. The command is therefore not discussed in this document. Managing Virtual Machine Snapshots with vmware-cmd You can manage virtual machine snapshots by using vmware-cmd. A snapshot captures the entire state of the virtual machine at the time you take the snapshot.
vSphere Command-Line Interface Concepts and Examples 4 Check that the virtual machine has a snapshot by using the hassnapshot option. The call returns 1 if the virtual machine has a snapshot and returns 0 otherwise. vmware-cmd -H -U -P --vihost /vmfs/volumes/Storage2/testvm/testvm.vmx hassnapshot hassnapshot () = 1 Reverting and Removing Snapshots You can use vmware-cmd to revert to the current snapshot or to remove a snapshot.
Chapter 8 Managing Virtual Machines If VMware Tools is not currently installed on the virtual machine, you can perform only a hard reset operation. a Check that VMware tools is installed so that you can reset the virtual machine with the default powerop_mode, which is soft. vmware-cmd -H -U -P --vihost /vmfs/volumes/Storage2/testvm/testvm.vmx gettoolslastactive See “Retrieving Virtual Machine Attributes,” on page 125.
vSphere Command-Line Interface Concepts and Examples The following examples illustrate connecting and disconnecting a virtual device. Device names are case sensitive. n The connectdevice option connects the virtual IDE device CD/DVD Drive 2 to the specified virtual machine. vmware-cmd -H -U -P --vihost /vmfs/volumes/Storage2/testvm/testvm.vmx connectdevice "CD/DVD drive 2" n The disconnectdevice option disconnects the virtual device.
Managing vSphere Networking 9 The vSphere CLI networking commands allow you to manage the vSphere network services. You can connect virtual machines to the physical network and to each other and configure vSphere standard switches. Limited configuration of vSphere distributed switches is also supported. You can also set up your vSphere environment to work with external networks such as SNMP or NTP.
vSphere Command-Line Interface Concepts and Examples Virtual switches allow your ESXi host to migrate virtual machines with VMware vMotion and to use IP storage through VMkernel network interfaces. n Using vMotion, you can migrate running virtual machines with no downtime. You can enable vMotion with vicfg-vmknic --enable-vmotion. You cannot enable vMotion with ESXCLI. n IP storage refers to any form of storage that uses TCP/IP network communication as its foundation and includes iSCSI and NFS for ESXi.
Chapter 9 Managing vSphere Networking n Associated with the standard switch are port groups (3). Port group is a unique concept in the virtual environment. You can configure port groups to enforce policies that provide enhanced networking security, network segmentation, better performance, high availability, and traffic management.
vSphere Command-Line Interface Concepts and Examples n The distributed switch itself (3) functions as a single virtual switch across all associated hosts. Because the switch is not associated with a single host, virtual machines can maintain consistent network configuration as they migrate from one host to another. Like a standard switch, each distributed switch is a network hub that virtual machines can use.
Chapter 9 Managing vSphere Networking 2 List the ports for one of the virtual machines by specifying its World ID. esxcli network vm port list -w 10408 The command returns port information, as in the following example. Port: Port ID: XXXXXXXX vSwitch: vSwitch0 Portgroup: VM Network DVPort ID: MAC Address: 00:XX:XX:aa:XX:XX IP Address: 10.XXX.XXX.XXX Team Uplink: vmnic0 Uplink Port ID: 12345678 Active Filters: 3 Retrieve the switch statistics for a port.
vSphere Command-Line Interface Concepts and Examples Setting Up vSphere Networking with vSphere Standard Switches You can use ESXCLI and vicfg-vswitch to set up the vSphere networking. You can set up your virtual network by performing a set of tasks. 1 Create or manipulate virtual switches by using esxcli network vswitch or vicfg-vswitch. By default, each ESXi host has one virtual switch, vSwitch0. You can create additional virtual switches or manage existing switches.
Chapter 9 Managing vSphere Networking c Add an uplink adapter. See “Linking and Unlinking Uplink Adapters with ESXCLI,” on page 144 and “Linking and Unlinking Uplink Adapters with vicfg-vswitch,” on page 144. d (Optional) Change the MTU or CDP settings. See “Setting Switch Attributes with ESXCLI,” on page 138 and “Setting Switch Attributes with vicfg-vswitch,” on page 139. Retrieving Information About Virtual Switches You can retrieve information about virtual switches by using ESXCLI or vicfg-vswitch.
vSphere Command-Line Interface Concepts and Examples Adding and Deleting Virtual Switches You can add and delete virtual switches with ESXCLI and with vicfg-vswitch. Adding and Deleting Virtual Switches with ESXCLI You can add and delete virtual switches by using the esxcli network vswitch standard namespace. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . n Add a virtual switch.
Chapter 9 Managing vSphere Networking The MTU is the size, in bytes, of the largest protocol data unit the switch can process. When you set this option, it affects all uplinks assigned to the virtual switch. n Set the CDP value for a vSwitch. You can set status to down, listen, advertise, or both.
vSphere Command-Line Interface Concepts and Examples Managing Port Groups with vicfg-vswitch You can use vicfg-vswitch to check, add, and remove port groups. Network services connect to virtual switches through port groups. A port group allows you to group traffic and specify configuration options such as bandwidth limitations and VLAN tagging policies for each port in the port group. A virtual switch must have one port group assigned to it. You can assign additional port groups.
Chapter 9 Managing vSphere Networking Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . n Connect a port group with an uplink adapter. vicfg-vswitch --add-pg-uplink --pg This command fails silently if the uplink adapter does not exist. n Remove a port group from an uplink adapter.
vSphere Command-Line Interface Concepts and Examples n Disable VLAN for port group g42. vicfg-vswitch --vlan 0 --pg g42 vSwitch2 Run vicfg-vswitch -l to retrieve information about VLAN IDs currently associated with the virtual switches in the network. Managing Uplink Adapters You can manage uplink adapters, which represent the physical NICs that connect the ESXi host to the network by using the esxcli network nic or the vicfg-nics command.
Chapter 9 Managing vSphere Networking Option Description -t|--transceiver-type= Selects transceiver type. The following transceiver types are available. n n -w|--wake-on-lan= 4 external internal Sets Wake-on-LAN options. Not all devices support this option. The option value is a string of characters specifying which options to enable.
vSphere Command-Line Interface Concepts and Examples Linking and Unlinking Uplink Adapters with ESXCLI You can use ESXCLI to link and unlink uplink adapters. When you create a virtual switch by using esxcli network vswitch standard add, all traffic on that virtual switch is initially confined to that virtual switch. All virtual machines connected to the virtual switch can talk to each other, but the virtual machines cannot connect to the network or to virtual machines on other hosts.
Chapter 9 Managing vSphere Networking Adding and Modifying VMkernel Network Interfaces VMkernel network interfaces are used primarily for management traffic, which can include vMotion, IP Storage, and other management traffic on the ESXi system. You can also bind a newly created VMkernel network interface for use by software and dependent hardware iSCSI by using the esxcli iscsi commands. The VMkernel network interface is separate from the virtual machine network.
vSphere Command-Line Interface Concepts and Examples 3 List information about all VMkernel network interfaces on the system. esxcli network ip interface list The command displays the network information, port group, MTU, and current state for each virtual network adapter in the system. Add and Configure an IPv6 VMkernel Network Interface with ESXCLI You can add and configure an IPv6 VMkernel NIC by using ESXCLI.
Chapter 9 Managing vSphere Networking Add and Configure an IPv4 VMkernel Network Interface with vicfg-vmknic You can add and configure an IPv4 VMkernel NIC by using vicfg-vmknic. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . Procedure 1 Add a new VMkernel network interface. You must specify the IP address by using --ip, the netmask, and the name.
vSphere Command-Line Interface Concepts and Examples 2 Enable IPv6. vicfg-vmknic --enable-ipv6 true VMSF-VMK-363 3 Supply an IPv6 address. vicfg-vmknic --ip VMSF-VMK-363 For IPv6, the IP address can have one of the following formats. 4 n - Static IPv6 address. n DHCPV6 – Use DHCP IPv6 address. The VMkernel supports DHCP only for ESXi 4.0 and later. n AUTOCONF – Use the IPv6 address advertised by the router.
Chapter 9 Managing vSphere Networking See the vSphere Networking documentation and the white paper available through the Resources link at http://www.vmware.com/go/networking for information about distributed switches and how to configure them using the vSphere Web Client. You can add and remove distributed switch uplink ports by using vicfg-vswitch. Important You cannot add and remove uplink ports with ESXCLI.
vSphere Command-Line Interface Concepts and Examples Procedure 1 Print a list of DNS servers configured on the system in the order in which they will be used. esxcli network ip dns server list If DNS is not set up for the target server, the command returns an empty string. 2 Add a server by running esxcli network ip dns server add and specifying the server IPv4 or IPv6 address. esxcli network ip dns server add --server= 3 Change the DNS settings.
Chapter 9 Managing vSphere Networking 2 If the DNS properties are set, and you want to change the DHCP settings, you must specify the virtual network adapter to use when overriding the system DNS. You can override the existing DHCP setting by using the following commands.
vSphere Command-Line Interface Concepts and Examples Procedure 1 Run vicfg-dns without command-specific options to display DNS properties for the specified server. vicfg-dns The information includes the host name, domain name, DHCP setting (true or false), and DNS servers on the ESXi host. 2 If the DNS properties are set, and you want to change the DHCP settings, you must specify the virtual network adapter to use when overriding the system DNS.
Chapter 9 Managing vSphere Networking Procedure 1 Add a route entry to the VMkernel and make it the default. n For IPv4 networks, no additional options are required. vicfg-route --add For example, to add a route to 192.XXX.100.0 through 192.XXX.0.1 by using the following syntax. vicfg-route -a 192.XXX.100.0/24 192.XXX.0.1 You can also use the following syntax. vicfg-route -a 192.XXX.100.0 255.255.255.0 192.XXX.0.
vSphere Command-Line Interface Concepts and Examples The VMware implementation of IPsec adheres to the following IPv6 RFCs.
Chapter 9 Managing vSphere Networking Managing Security Associations You can specify an SA and request that the VMkernel use that SA. The following options for SA setup are supported. vicfg-ipsec Option esxcli Option Description sa-src sa-source Source IP for the SA. sa-dst sa-destination Destination IP for the SA. spi sa-spi Security Parameter Index (SPI) for the SA. Must be a hexadecimal number with a 0x prefix.
vSphere Command-Line Interface Concepts and Examples --encryption-key 0x6970763672656164796c6f676f336465736362636f757432 --integrity-algorithm hmac-sha1 --integrity-key 0x6970763672656164796c6f67736861316f757432 --sa-name sa_2 n List an SA by using esxcli network ip ipsec sa list. This command returns SAs currently available for use by an SP. The list includes SAs you created. n Remove a single SA by using esxcli network ip ipsec sa remove.
Chapter 9 Managing vSphere Networking You can perform the following main tasks with SPs. n Create an SP by using esxcli network ip ipsec add. You identify the data to monitor by specifying the selector’s source and destination IP address and prefix, source port and destination port, upper layer protocol, direction of traffic, action to take, and SP mode. The last two option are the name of the SA to use and the name of the SP that is being created.
vSphere Command-Line Interface Concepts and Examples 2 Enable the sshServer ruleset if it is disabled. esxcli network firewall ruleset set --ruleset-id sshServer --enabled true 3 Obtain access to the ESXi Shell and check the status of the allowedAll flag.
Chapter 9 Managing vSphere Networking 5 View statistics for a VXLAN segment ID. n List the available segment IDs. esxcli network vswitch dvs vmware vxlan network list -vds-name Cluster01-VXLAN-VDS n View the network statistics for a particular segment ID. esxcli network vswitch dvs vmware vxlan network stats list --vds-name Cluster01-VXLANVDS --vxlan-id 5000 n Retrieve network mapping if some virtual machine communication is occurring.
vSphere Command-Line Interface Concepts and Examples 160 VMware, Inc.
Monitoring ESXi Hosts 10 Starting with the vSphere 4.0 release, vCenter Server makes performance charts for CPU, memory, disk I/O, networking, and storage available. You can view performance charts by using the vSphere Web Client and read about them in the vSphere Monitoring documentation. You can also perform some monitoring of your ESXi system by using vCLI commands.
vSphere Command-Line Interface Concepts and Examples The following considerations apply. n A diagnostic partition cannot be located on an iSCSI LUN accessed through the software iSCSI or dependent hardware iSCSI adapter. For more information about diagnostic partitions with iSCSI, see General Boot from iSCSI SAN Recommendations in the vSphere Storage documentation. n A standalone host must have a diagnostic partition of 110 MB.
Chapter 10 Monitoring ESXi Hosts Procedure 1 Show the diagnostic partition the VMkernel uses and display information about all partitions that can be used as diagnostic partitions. esxcli system coredump partition list 2 Deactivate the current diagnostic partition. esxcli system coredump partition set --unconfigure The ESXi system is now without a diagnostic partition, and you must immediately set a new one. 3 Set the active partition to naa..
vSphere Command-Line Interface Concepts and Examples Manage Core Dumps with vicfg-dumppart You can use vicfg-dumppart to manage core dumps. The following example scenario changes the diagnostic partition. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . Procedure 1 Show the diagnostic partition the VMkernel uses.
Chapter 10 Monitoring ESXi Hosts n Log rotation policies - Sets maximum log size and the number of archives to keep. You can specify policies both globally, and for individual subloggers. For example, you can set a larger size limit for the vmkernel log. Important The esxcli system syslog command is the only supported command for changing ESXi 5.0 and later logging configuration. The vicfg-syslog command and editing configuration files is not supported for ESXi 5.0 and can result in errors.
vSphere Command-Line Interface Concepts and Examples 4 Send logs to remote host myhost.mycompany.com. The logs will use the default transport (UDP) and port (514). esxcli system syslog config set --loghost='myhost.mycompany.com' 5 Save the local copy of logs to /scratch/mylogs and send another copy to the remote host. esxcli system syslog config set --loghost='tcp://myhost.mycompany.
Chapter 10 Monitoring ESXi Hosts Configure a Trap Destination with ESXCLI You can use ESXCLI to configure a trap destination and send traps. Specify one of the options listed in “Connection Options for vCLI Host Management Commands,” on page 19 in place of . Procedure 1 Make sure a community is set up. esxcli system snmp get Current SNMP agent settings: Enabled: 1 UDP port: 161 Communities: public Notification targets: 2 Set the target address, port number, and community.
vSphere Command-Line Interface Concepts and Examples Each time you specify a target with this command, the settings you specify overwrite all previously specified settings. To specify multiple targets, separate them with a comma. You can change the port that the SNMP agent sends data to on the target using the --targets option. That port is UDP 162 by default. 3 (Optional) Enable the SNMP agent if it is not yet running.
Chapter 10 Monitoring ESXi Hosts Example: Running Commands in Sequence The following example shows how the commands are run in sequence. vicfg-snmp –c public –t example.com@162/private --enable # next validate your config by doing these things: vicfg-snmp -–test walk –v1 –c public esx-host Configure the SNMP Agent for Polling with vicfg-snmp You can use vicfg-snmp to configure the SNMP agent for polling.
vSphere Command-Line Interface Concepts and Examples 170 VMware, Inc.
Index C resignature VMFS copies 33 resignaturing VMFS copies with ESXCLI 34 resignaturing VMFS copies with vicfgvolume 34 unmounting a datastore with ESXCLI 32 unmounting a datastore with vicfg-volume 33 unused storage space reclamation 34 vifs examples 37 vifs options 36 vifs usage 35 VMFS volumes 31 VMFS3 to VMFS5 upgrade 31 vmkfstools 30 commands, overview 11 connection options DCLI commands 19 vCLI host management commands 19 D datastore management capabilities 57 NAS 57–59 NFS 57 DCLI commands, con
vSphere Command-Line Interface Concepts and Examples VMkernel module management with vicfgmodule 26 VMkernel module management with esxcli 25 host management commands, targets and protocols 15 set iSCSI options with vicfg-iscsi 89 set iSCSI parameters with vicfg-iscsi 92 software iSCSI setup with ESXCLI 78 software iSCSI setup with vicfg-iscsi 85 vicfg-iscsi setup 84 vicfg-iscsi syntax 73, 75 I intended audience 9 iSCSI SAN protection iSCSI CHAP 72 iSCSI port security 72 transmitted data 71 iSCSI session
Index S T sending traps with the SNMP agent ESXCLI 167 vicfg-snmp 167 set switch attributes ESXCLI 138 vicfg-vswitch 139 SNMP agent polling configuration ESXCLI 168 vicfg-snmp 169 storage management APD 49 datastore management 57 datastores 44 device detaching 48 device naming 44 device reattaching 49 FCoE adapter configuration 65 FibreChannel SAN 59 I/O scheduling 57 introduction 42 LUN examination 45–47 LUN removal 48 monitor vSphere Flash Read Cache 62 multipathing 56 path disabling with ESXCLI 53 pat
vSphere Command-Line Interface Concepts and Examples connect virtual devices 129 disconnect virtual devices 129 list virtual machines 125 power off 128 power on 128 register virtual machines 125 remove snapshots 128 revert snapshots 128 stop a virtual machine forcibly 130 taking a snapshot 127 vmware-cmd 123 Virtual SAN adding storage 61 cluster management 60 removing storage 61 retrieving information 60 virtual switch addition ESXCLI 138 vicfg-vswitch 138 virtual switch deletion ESXCLI 138 vicfg-vswitch 1