11.07.2015 Views

Command Line Interface Tips and Tricks for VMware ESX Server 2 ...

Command Line Interface Tips and Tricks for VMware ESX Server 2 ...

Command Line Interface Tips and Tricks for VMware ESX Server 2 ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>Comm<strong>and</strong></strong> <strong>Line</strong> <strong>Interface</strong> <strong>Tips</strong> <strong>and</strong><strong>Tricks</strong> <strong>for</strong> <strong>VMware</strong> <strong>ESX</strong> <strong>Server</strong> 2 <strong>and</strong> 3Russ HenmiTechnical Trainer


<strong>ESX</strong> <strong>Server</strong> 2.X <strong>Comm<strong>and</strong></strong>sRemoved or replaced scripts in <strong>VMware</strong> Infrastructure 3:vmkpcidivyvmkchdevvmkbootcfgcos-rescan.shRetained in <strong>VMware</strong> Infrastructure 3:vmkfstoolsvmware-cmdNote: Options <strong>for</strong> common comm<strong>and</strong>s such as vmkfstools may vary indifferent versions of <strong>ESX</strong> <strong>Server</strong> – verify option functionality be<strong>for</strong>e use!


vmkpcidivyvmkpcidivy [-i[nteractive]] [-l[abel] name] [-m[emory] memsize] [-q[uery]][-r[efreshnames]] [-k[vmkdumpset]] [-[csv][dev] bus:slot:fcn][-d[rootdev] rootdev]interactive: Interactively go through the PCI divvy process.label: Operate on the LILO configuration with the specified label.memory: Specify memory (in megabytes) reserved <strong>for</strong> Service Console.query: Execute a query.refreshnames: Creates or updates the device names.vmkdumpset: Sets the dump partition to the best available dump partition.[csv]dev: Assign a specified device exclusively to console, shared or virtualmachines.


vmkpcidivy - Interactive Mode


vmkpcidivy SyntaxValid queries (vmkpcidivy -q ...)Get Service Console device-file name of a VMkernel LUN (vmhbaC:T:L):vmkpcidivy -q vmhba_dev vmhba1:3:0vmkpcidivy -q vmhba_devsList all the LILO boot-target menu items:vmkpcidivy -q labelsShow VMkernel modules that are loaded:vmkpcidivy -q vmkmodShow the VMkernel core dump partition (as vmhbaC:T:L:P):vmkpcidivy -q vmkdump_part. . . or, as a Service Console device-file name:vmkpcidivy -q vmkdump_dev


vmkfstools Syntaxvmkfstools -? [ otherarg otherarg … ] VMFS-pathThe option flag -? specifies the action of the comm<strong>and</strong>Actually an entire suite of comm<strong>and</strong>s (hence, “ . . . tools”)VMFS Operations:-C Create a new VMFS file system in a LUN-P Query the file system’s attributes-Z Extend (span) the file system onto an extent (additional LUN)-L Manage SCSI reservations (“locks”)Virtual Disk Operations-c Create a new virtual disk (file)-X Extend a virtual disk-r Create a new RDM in the file system (map a raw LUN to it)


CLI Access in <strong>VMware</strong> Infrastructure 3Direct root user ssh connections are disabled by default in freshinstallations of <strong>ESX</strong> 3.0The recommended way to access the system is to ssh to the server as anon-root user <strong>and</strong> then use the su comm<strong>and</strong> to switch to the rootaccount; this leaves an audit trail <strong>for</strong> accountability purposesAn alternative way to allow root access is to configure ssh to allow theroot user to log inUpdate the ssh configuration file:• # vi /etc/ssh/sshd_config• …• PermitRootLogin yes• …Restart the ssh daemon:• # service sshd restart


CLI in <strong>VMware</strong> Infrastructure 3Changes made via comm<strong>and</strong> line interfaces might not be visible to theVirtualCenter <strong>Server</strong> without restarting the vmware-hostd daemonRestarting vmware-hostd will cause the system to re-read the <strong>ESX</strong>configuration file /etc/vmware/esx.confTo halt the daemon prior to changes:• # service mgmt-vmware stopTo start the daemon after changes:• # service mgmt-vmware startTo <strong>for</strong>ce a re-read of /etc/vmware/esx.conf:• # service mgmt-vmware restart


Configuration File ChangesThe /etc/vmware/esx.conf file is the master configuration file <strong>for</strong><strong>ESX</strong> <strong>Server</strong> 3.0Old File New file Noteshwconfigesx.confdevnames.confNo longer necessary, wasduplicated in hwconfignow in esx.confvmkmodule.conf esx.conf Keys start with/vmkmodulenetmap.conf esx.conf See the prettyNameentry <strong>for</strong> each portgroupvmkconfig esx.conf Keys start with /advUse the esxcfg-* tools or Virtual Infrastructure Client to configure <strong>ESX</strong>!


esxcfg-*Suite of comm<strong>and</strong>s kept in /usr/sbinNamed <strong>for</strong> easy correlation between comm<strong>and</strong> <strong>and</strong> functionOnline help available <strong>for</strong> most comm<strong>and</strong>s by using the –h optionDesigned to replace functionality from retired comm<strong>and</strong>s such asvmkpcidivy <strong>and</strong> cos-rescan.shOld:# vmkpcidivy –q vmhba_devs# cos-rescan.sh vmhba1New:# esxcfg-vmhbadevs# esxcfg-rescan vmhba1Hint: Type esxcfg- <strong>for</strong> a complete list of the comm<strong>and</strong>s.


CLI ComparisonsThe esxcfg-* comm<strong>and</strong>s replace many st<strong>and</strong>ard options from theprevious versionOld <strong>Comm<strong>and</strong></strong> New <strong>Comm<strong>and</strong></strong> Notescos-rescan.sh esxcfg-rescan Rescan <strong>for</strong> new LUNsvmkbootcfg esxcfg-boot Manage the boot partitionsvmkchdev esxcfg-info Print out device configurationsvmkpcidivy -qesxcfg-dumppart -lvmkdump_partManage the vmkdump partitionvmkpcidivy -q vmhba_devs esxcfg-vmhbadevs Map vmhbaC:T:L names toLinux device filesvmkpcidivy -q vmkmod esxcfg-module -l List modules loaded in theservice console


esxcfg-* <strong>Comm<strong>and</strong></strong> TypesNetworkingesxcfg-firewallesxcfg-routeesxcfg-vmknicesxcfg-vswifesxcfg-vswitchesxcfg-nicsStorageesxcfg-dumppartesxcfg-mpathesxcfg-nasesxcfg-swiscsiesxcfg-vmhbadevsService Console Administrationesxcfg-infoesxcfg-advcfgesxcfg-resgrp


Network ManagementService console networking problems might require manual virtualswitch reconfiguration from the physical consoleUse the esxcfg-vswitch comm<strong>and</strong> to reassign physical NICs tovirtual switchesDisplay current configurations:• # esxcfg-vswitch -lDetach a physical NIC from a virtual switch:• # esxcfg-vswitch –U Link a physical NIC to a virtual switch:• # esxcfg-vswitch –L


Modifying Service Console Networking# esxcfg-nics –lName PCI Driver Link Speed Duplex Descriptionvmnic0 02:02.00 tg3 Up 1000Mbps Full Broadcom …vmnic1 02:02.01 tg3 Up 1000Mbps Full Broadcom …vmnic2 0a:01.00 tg3 Up 1000Mbps Full Broadcom …# esxcfg-vswitch –lSwitch Name Num Ports Used Ports … UplinksvSwitch0 64 3 … vmnic0PortGroup Name Internal ID … UplinksService Console portgroup0 vmnic0


Modifying Service Console Networking (cont.)# esxcfg-vswitch –U vmnic0 vSwitch0# esxcfg-vswitch –L vmnic2 vSwitch0# esxcfg-vswitch –lSwitch Name Num Ports Used Ports … UplinksvSwitch1 64 3 … vmnic2PortGroup Name Internal ID … UplinksService Console portgroup1 vmnic2


esxcfg-infoThe /proc/vmware interface is deprecatedSome data items are no longer presented thereLittle will be added to /proc/vmware in the futureAll in<strong>for</strong>mation now comes from the <strong>VMware</strong> SysInfo (VSI)interfaceTo view from comm<strong>and</strong>-line:esxcfg-info –a | moreTo access programmatically, use SDK


Service Console FirewallThe service console in <strong>ESX</strong> 3.0 is protected by an iptables firewallUse esxcfg-firewall to administerBy default, only services required by <strong>VMware</strong> Infrastructure are enabled;all other services must be activated by the administrator via the VI Clientor CLIService ports are opened either by known service name or by individualport numberOpening a port by service name:# esxcfg-firewall –e smbClientOpening a port by service name:# esxcfg-firewall –o 123,udp,out,ntp


iptables Known ServicesAAMClient*CIMHttp<strong>Server</strong>*CIMHttps<strong>Server</strong>*CIMSLP*commvaultDynamiccommvaultStaticftpClientftp<strong>Server</strong>LicenseClient*nfsClientnisClientntpClientsmbClientsnmpdsshClientssh<strong>Server</strong>*swISCSIClienttelnetClientTSMveritasBackupExecveritasNetBackupvnc<strong>Server</strong>vpxHearbeats** Indicates the service is enabled by default


usr/lib/vmware/bin/storageMonitorNew feature of VI-3Monitors SCSI sense errors experienced by storage devices attached toan <strong>ESX</strong> <strong>Server</strong>Can be used to troubleshoot storage problems in the <strong>ESX</strong> <strong>Server</strong>environmentPolls the storageMonitor running in the vmkernel <strong>and</strong> can send output tost<strong>and</strong>ard output, a user-defined log file or the system logConfiguration files can be created to filter which sense error messageswill be displayed or omitted from the outputDefault configuration file (/etc/vmware/storageMonitor.conf) can beoverridden with custom configuration file created by the administratorRuns in either interactive or daemon mode


storageMonitor SyntaxstorageMonitor [-c ] [-d [-l ] [-s]] [-h] [-p ]-c : Specify non-st<strong>and</strong>ard configuration file-d: Run in daemon mode.(default: /etc/vmware/storageMonitor.conf)-l : Log in<strong>for</strong>mation in a user-defined log file (default: syslog).-s: Send log in<strong>for</strong>mation to stdout.-h: Creates or updates the device names.-p : Sets the interval (in seconds) used <strong>for</strong> polling kernelresident storage <strong>and</strong> retrieving status/errors of the storage devices(default: 10 sec.)


esxcfg-* <strong>Comm<strong>and</strong></strong>sesxcfg-advcfgesxcfg-authesxcfg-boot †esxcfg-dumppartesxcfg-firewallesxcfg-infoesxcfg-init †Sets advanced VMkernel optionsAuthentication configurationConfigure boot, including PCI allocationSet, activate, deactivate, list potential <strong>and</strong>current VMkernel dump partitionsConfigure firewalling options.Prints in<strong>for</strong>mation about the serviceconsole, the VMkernel, various subsystems inthe virtual network <strong>and</strong> storage resource hardwarePer<strong>for</strong>m initialization steps in the initrdesxcfg-linuxnet Converts vswif devices to eth when bootinginto Linux debugging modeesxcfg-upgrade † Upgrade from <strong>ESX</strong> <strong>Server</strong> 2.X to 3.0†Should not be run unless instructed to do so by <strong>VMware</strong> Technical SupportRepresentative


esxcfg-* <strong>Comm<strong>and</strong></strong>s (cont.)esxcfg-mpathesxcfg-nasesxcfg-nicsesxcfg-rescanesxcfg-resgrpesxcfg-routeesxcfg-swscsiesxcfg-vmhbadevsesxcfg-vmknicesxcfg-vswifesxcfg-vswitchMultipathing configurationAdd, delete or manage NAS file systemsPresents physical NIC in<strong>for</strong>mationRescan LUNs on SCSI deviceCreate, delete <strong>and</strong> list resource groupsEnable or disable routing <strong>for</strong> vmknicsConfigures software iSCSI adaptersMaps COS device files to vmhba namesCreate & configure VMkernel NICsCreate & configure vswifs <strong>for</strong> the COSCreate & configure virtual switches <strong>and</strong>port groupsMore complete descriptions available in Appendix A of the <strong>Server</strong> Configuration Guide


Questions?


Presentation DownloadPlease remember to complete yoursession evaluation <strong>for</strong>m<strong>and</strong> return it to the room monitorsas you exit the sessionThe presentation <strong>for</strong> this session can be downloaded athttp://www.vmware.com/vmtn/vmworld/sessions/Enter the following to download (case-sensitive):Username: cbv_repPassword: cbv<strong>for</strong>9v9r


Some or all of the features in this document may be representative offeature areas under development. Feature commitments must not beincluded in contracts, purchase orders, or sales agreements of any kind.Technical feasibility <strong>and</strong> market dem<strong>and</strong> will affect final delivery.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!