VMWareCookbook - henk52/knowledgesharing GitHub Wiki

Introduction

References

  • VIX

  • VIM - VMware Infrastructure (VI) Perl Toolkit

  • Downloads

Clone VM in vSphere

installing ESXi

Installing ESXi on kvm

  • set the nic to 'e1000e' (just type it in)
  • set disc to 80GB (25GB is too small)

vmrun

  • vmrun -T server -h IP_ADDR -u root -p ROOT_PW list
    • list all apps
  • vmrun -T server -h IP_ADDR -u root -p ROOT_PW -gu GUEST_ROOT -gp GUEST_ROOT_PW runProgramInGuest "[DATASTORAGE] SOMETHING.vmx" /test_run.sh
    • Please note that on, some?, Linux the /tmp directory is a special mount when run via vmrun...

fin

Installing vmrun

  • sh /VMware-VIX-1.15.0-2985596.x86_64.bundle --required --eulas-agreed --console ** get at:

vmtool

vmtool installation

  1. download:
  2. sudo dnf install ncurses-compat-libs libnsl
  3. TERM=DUMB sh /VMware-ovftool-4.2.0-4586971-lin.x86_64.bundle --required --eulas-agreed --console
Extracting VMware Installer...done.
Installing VMware Installer 2.1.0
Copying files...
Configuring...
Installing VMware OVF Tool component for Linux 4.2.0
Copying files...
Configuring...
Installation was successful.
  • User interface initialization failed. Exiting. Check the log for details.
    • sudo dnf install ncurses-compat-libs libnsl
    • cat /tmp/vmware-root/vmware-vmis-19222.log

Instantiating an OVF on an ESXi server

ovftool --name=ESXI_NAME_OF_VM --datastore=ESXI_STORAGE --net:cp1=ESXI_NETWORK_A --net:cp2=ESXI_NETWORK_B --net:cp3=ESXI_NETWORK_C /export//release/SOME_OVF.ovf vi://root:ESXI_ROOT_PASSWORD@ESXI_IP

  • ESXI_ROOT_PASSWORD: Please note that special char like '!' and '*' etc must be provided as Hex numbers prepended by '%':
    • E.g. '!' is "%21"
  • ESXI_NAME_OF_VM: Name shown in vSphere and lists, not the hostname in the guest.

Converting KVM image to ESXi

Converting qcow2 to vmdk and import it

Firewall

Add new service port to ESXi firewall

  1. esxcli network firewall ruleset list
  2. cp /etc/vmware/firewall/service.xml /etc/vmware/firewall/service.xml.bak
  3. chmod 644 /etc/vmware/firewall/service.xml
  4. chmod +t /etc/vmware/firewall/service.xml
  5. vi /etc/vmware/firewall/service.xml
  6. chmod 444 /etc/vmware/firewall/service.xml
  7. esxcli network firewall refresh
  8. esxcli network firewall ruleset list
  <!-- Enable reporting to graphite host -->
  <service id='0038'>
    <id>graphite</id>
    <rule id='0000'>
      <direction>outbound</direction>
      <protocol>tcp</protocol>
      <porttype>dst</porttype>
      <port>2003</port>
    </rule>
    <rule id='0001'>
      <direction>outbound</direction>
      <protocol>tcp</protocol>
      <porttype>dst</porttype>
      <port>2004</port>
    </rule>
    <enabled>true</enabled>
    <required>false</required>
  </service>

escli - CLI on the ESXi host

  • esxcli network ip interface ipv4 get

vSphere

vSpehere info

Add a new NIC to the kernel

  • Configure physical NIC
  1. Start vSphere
  2. Click configure
  3. Click Network
  4. Click Add
  5. Select vmkernel and click next
  6. Select the NIC you want to use and click next
  7. Click next
  8. Input the IP info and click next
  9. Clic finish

Tools in guest

    • PowerCLI
      • get-vm VM-NAME | New-AdvancedSetting -Name isolation.tools.guestInitiatedUpgrade.disable -Value FALSE -Force
    • Linux
      • ? VirtualMachine.Config.AdvancedConfig if changing values in extraConfig

Performance analysis

esxtop

Starting esxtop:

  • ssh -l root ESXI_IP
  • or: login to the console/terminal directly on the physical server.

You can find a description of each field in: Using the resxtop Utility

  • %SYS Percentage of time spent in the ESXi VMkernel on behalf of the resource pool, virtual machine, or world to process interrupts and to perform other system activities. This time is part of the time used to calculate %USED. %USED = %RUN + %SYS - %OVRLP
  • %WAIT Percentage of time the resource pool, virtual machine, or world spent in the blocked or busy wait state. This percentage includes the percentage of time the resource pool, virtual machine, or world was idle. 100% = %RUN + %RDY + %CSTP + %WAIT
  • %VMWAIT The total percentage of time the Resource Pool/World spent in a blocked state waiting for events.
  • %IDLE Percentage of time the resource pool, virtual machine, or world was idle. The difference, %WAIT- %IDLE, of the VCPU worlds can be used to estimate guest I/O wait time. To find the VCPU worlds, use the single-key command e to expand a virtual machine and search for the world NAME starting with "vcpu". (The VCPU worlds might wait for other events in addition to I/O events, so this measurement is only an estimate.)
  • Percentage of total time scheduled. This time does not account for hyperthreading and system time. On a hyperthreading enabled server, the %RUN can be twice as large as %USED.
    • %RUN > %USED the pCPU is not running at its rated clock frequency. Probably due Power saving.
    • %USED might depend on the frequency with which the CPU core is running. When running with lower CPU core frequency, %USED can be smaller than %RUN. On CPUs which support turbo mode, CPU frequency can also be higher than the nominal rated) frequency, and %USED can be larger than %RUN. %MLMTD (max limited) - Percentage of time the ESXi VMkernel deliberately did not run the resource pool, virtual machine, or world because doing so would violate the resource pool, virtual machine, or world's limit setting. Because the resource pool, virtual machine, or world is ready to run when it is prevented from running in this way, the %MLMTD (max limited) time is included in %RDY time. %LAT_C Percentage of time the resource pool or world was ready to run but was not scheduled to run because of CPU resource contention. %LAT_M Percentage of time the resource pool or world was ready to run but was not scheduled to run because of memory resource contention. %DMD CPU demand in percentage. It represents the average active CPU load in the past minute.
  • co-stop when vCPUs have to be held back because they have been running more than some of the other vCPUs in the same VM.
  • e Toggles whether CPU statistics are displayed expanded or unexpanded. The expanded display includes CPU resource utilization statistics broken down by individual worlds belonging to a resource pool or virtual machine. All percentages for the individual worlds are percentage of a single physical CPU.
  • U Sorts resource pools, virtual machines, and worlds by the resource pool’s or virtual machine’s %Used column. This is the default sort order.
  • R Sorts resource pools, virtual machines, and worlds by the resource pool’s or virtual machine’s %RDY column.
  • N Sorts resource pools, virtual machines, and worlds by the GID column.
  • V Displays virtual machine instances only.
  • L Changes the displayed length of the NAME column.

If you expand a world? GID then you can see the processes. use 'e' and then give the GID.

Seems like it is the 'vmx' that has the %RDY. See:

  • vmx - The VMX world assists the vcpu worlds (the hypervisor). The usage of the VMX world is out of the scope of this document. In ESX 4.0, there is only one vmx world.

  • vmxast - Memory scan?

  • vmx-vthread-4: Possible explanation: vthread is just a platform independent threading library

  • vmx-vthread-5:

  • vmx-mks - mouse, keyboard, screen

  • vmx-svga - svga is a process to handle the mks thread. ()

  • vmx-vcpu - there is one vcpu (hypervisor) world corresponding to each VCPU of the VM.

    • the guest activities are represented mostly by the vcpu worlds.
  • On conventional operating systems, the execution context corresponds to a process or a thread; on ESXi, it corresponds to a world.

Information from:

  • CPU
    • %RDY- Indicates the percentage of time a VM was ready to run but could not because there wasn’t enough CPU resources available. Could be due to too many vCPUs, vSMP VMs or a CPU limit enforced on a VM. Threshold: Higher than 10.
    • %SWPWT – Indicates the percentage of time a VM has to wait for the host to swap memory. This could be a sign of overcommitted memory. Threshold: Higher than 5.
    • %MLMTD– Indicates the percentage of time a VM or world was not scheduled because of a limit setting. Unless a limit on a resource pool or VM was purposely configured by design, there shouldn’t be anything higher than 0 in this field. Threshold: Greater than 0.
    • %CSTP – Indicates the percentage of time a VM spends in a ready, co-deschedule state. This field really only applies to virtual machines that are using vSMP and indicates that one vCPU is being used a lot more than the other vCPU allocated to the VM. Threshold: Higher than 3.
  • Memory
    • MCTLSZ (MB)– Indicates the amount of physical memory the ESXi Host is reclaiming by balloon driver. Could possibly be a sign of overcommitted memory. Threshold: Greater than 0.
    • ZIP/s (MB/s)– Indicates the amount of memory that is compressed per second on the host. If the host is compressing memory pages it’s an indicator of memory contention issues and is usually due to overcommitted memory. Threshold: greater than 0.
    • UNZIP/s (MB/s) – Indicates the amount of memory that is decompressed per second on the host. Can be a sign of overcommitted memory. Threshold: greater than 0.
    • SWCUR (MB)– Memory that that is being swapped by the VM or resource pool. Points to overcommitted memory. Threshold: greater than 0.
    • CACHEUSD (MB)– Amount of memory being compressed by the ESXi host. Could be an indication of overcommitted memory. Threshold: greater than 0.
    • SWW/s and SWR/s– Indicates the rate at which the ESXi Host read or writes to the disk from or to swapped memory. Possible cause would be overcommitted memory. Threshold: greater than 0.
  • Network
    • %DRPTX – Dropped packages transmitted. Higher values than 0 could be a sign of high network utilization. Threshold: greater than 0.
    • %DRPRX – Dropped packages received. Higher values than 0 could be a sign of high network utilization. Threshold: greater than 0.
    • Used-by and Team-PNIC– These two fields are very useful to distinguishing which physical NIC a VM is using.
  • Disk
    • DAVG/cmd – Indicates the average device Latency per command at the device driver level. High values point to storage performance issues. Threshold: Over 25
    • ABRTS/s – Commands aborted per second. Aborts are issued from the guest OS when storage stops responding. The Windows OS has a default time out of 60 seconds. Possible cause could be an issue with the storage fabrics or array. Threshold: Anything over 0
    • KAVG/cmd– Average VMKernel latency per command. A high value indicates I/O is being throttled between guest OS and storage, best bet is to check with vendor for performance tuning options or an updated firmware release. Threshold Over 2
    • GAVG/cmd– Average guest operating system latency per command. This value is calculated by the sum of the DAVG and KAVG. Threshold: Over 25
    • Resets/s– Command reset’s per second. A reset command get issued when the operation fails to reach the target. Threshold: Anything over 0

analyzing esxtop batchfiles

visualesxtop

Graphite

  • %Core_Util_Time: The % of time either or both pCPUs have been active, not a sum of the pCPU utilization.

    • Note that, in batch mode, we show the corresponding "CORE UTIL(%)" of each PCPU. So, PCPU 0 and PCPU 1 have the same "CORE UTIL(%)" number, i.e. the "CORE UTIL(%)" of Core 0.
  • Group_: A group statistics is the sum of world statistics for all the worlds contained in that group.

ESXcli command list

  • esxcli storage core device list
  • esxcli storage core path list - List all the SCSI paths on the system.
  • esxcli storage core plugin list
  • esxcli storage core plugin registration list
  • esxcli storage filesystem list
  • esxcli storage nmp device list
  • esxcli storage nmp path list
  • esxcli storage core adapter list

CookBook

Create a usb bootable device

  • sudo demsg | tail
  • dmesg | grep sd
  • fdisk /dev/sdd
    • create a 2GB partition (otherwise you wont be able to create teh W95)
  • /sbin/mkfs.vfat -F 32 -n ESX /dev/sdd1
  • cat /usr/lib/syslinux/mbr/mbr.bin > /dev/sde
  • mount /dev/sdd1 /usbdisk/
  • mount -o loop /home/hck/Downloads/VMware-VMvisor-Installer-7.0U3n-21930508.x86_64.iso /esxicd/
  • cp -r /esxicd/* /usbdisk
  • mv /usbdisk/isolinux.cfg /usbdisk/syslinux.cfg
  • vi /usbdisk/syslinux.cfg
  • cp /usr/lib/syslinux/modules/bios/* /usbdisk
  • umount /usbdisk/
  • umount /esxicd

Various

Enable ssh between two ESXi hosts

Rename an ESXi host

See:

Networking cook book

VLAN tagging

See:

There are three methods:

  • External Switch Tagging (EST) - The external switch handles providing a single tag on the traffic.
  • Virtual Switch Tagging (VST) - The vSwitch provides a single tag for the VM traffic.
  • Virtual Guest Tagging (VGT) - The VM handles the tagging, the VM can have as many VMs as it wants.

Allow multiple VLAN id from the same VM

For the vSwitch set VLAN ID to 4095

  • See:
  1. Connect to the ESXi host, via vSphere
  2. Select the host (in the top right)
  3. Select the 'Configuration' tab, at the top
  4. select 'Networking' under 'Hardware'
  5. Find the vSwitch
  6. Click 'Properties...' for the vSwitch
  7. Click on the Virtual machine port group (line 2) usually named: 'VM Network NN'
  8. Click the 'Edit...' button at the bottom of the window
  9. Set the VLAN ID (optional): to 'All (4095)'
  10. click Ok
  11. click 'Close'

Troubleshooting

troubleshooting ovftool

troubleshooting ovftool upload problems

  1. tar -xf my.ova
  2. rm my.mf
  3. vi my.ovf
    • change: vmware.cdrom.iso to vmware.cdrom.atapi

Error: Invalid target disk adapter type: pvscsi

Invalid VM configuration. Reason: 'Incompatible device backing specified for device '7'.' for property 'virtualDevice.backing'

On the same freaking host that the OVF was pulled from...

To remove the Serial Port Section:

  • Navigate to the location of the OVF template.
  • Create a backup of the templatename.ovf and templatename.mf files.
  • Open the templatename.ovf file using a text editor.
  • Locate and remove the Serial Port section and save the templatename.ovf file. The Serial Port section looks similar to:
    <Item ovf:required="false">
            <rasd:AutomaticAllocation>true</rasd:AutomaticAllocation>
            <rasd:ElementName>Serial port 1</rasd:ElementName>
            <rasd:InstanceID>12</rasd:InstanceID>
            <rasd:ResourceSubType>vmware.serialport.device</rasd:ResourceSubType>
            <rasd:ResourceType>21</rasd:ResourceType>
            <vmw:Config ovf:required="false" vmw:key="yieldOnPoll" vmw:value="true" />
          </Item>
  • Open the templatename.mf file using a text editor.
  • Locate the row that contains the SHA1 hash of templatename.ovf and remove this line.
  • Save the templatename.mf file.
  • Redeploy the virtual machine using the modified templatename.ovf.

Troubleshooting vSphere-CLI installation

/usr/bin/perl: symbol lookup error: /usr/lib64/perl5/auto/XML/LibXML/Common/Common.so: undefined symbol: Perl_Gthr_key_ptr

It seems the following is required:

  • perl-Crypt-SSLeay

See:

Can't locate VMware/Vix/Simple.pm

Seems like it is missing:

  • VMware-VIX-1.15.0-2985596.x86_64.bundle
Can't locate VMware/Vix/Simple.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 . /opt/gls_installer) at /opt/gls_installer/GLSsetup/ZClinux.pm line 42.
BEGIN failed--compilation aborted at /opt/gls_installer/GLSsetup/ZClinux.pm line 42.
Compilation failed in require at /opt/gls_installer/vmdeploy.pl line 35.
BEGIN failed--compilation aborted at /opt/gls_installer/vmdeploy.pl line 35.

HostConnect() failed, 22003 The specified service provider was not found

Use VIX version 1.14

1.15 and 1.17 fails, both against ESXi 5.5 and ESXi 6.5

See:

  • /tmp/vmware-USER/vmware-vixWrapper-PID.log
DDD call  HostConnect(VIX_API_VERSION ...)
Failed to get property type for 3010 on handle 16799219.
HostConnect() failed, 22003 The specified service provider was not found

vmware-vixWrapper-PID.log

2019-01-29T13:45:02.600Z| vthread-1| I125: Log for VixWrapper pid=13876 version=1 build=build-6661328 option=Release
2019-01-29T13:45:02.600Z| vthread-1| I125: The process is 64-bit.
2019-01-29T13:45:02.600Z| vthread-1| I125: Host codepage=UTF-8 encoding=UTF-8
2019-01-29T13:45:02.600Z| vthread-1| I125: Host is Linux 3.10.0-862.11.6.el7.x86_64 Red Hat Enterprise Linux Server release 7.5 (Maipo)
2019-01-29T13:45:02.596Z| host-| I125: DictionaryLoad: Cannot open file "/usr/lib/vmware/settings": No such file or directory.
2019-01-29T13:45:02.596Z| host-| I125: [msg.dictionary.load.openFailed] Cannot open file "/usr/lib/vmware/settings": No such file or directory.
2019-01-29T13:45:02.596Z| host-| I125: PREF Optional preferences file not found at /usr/lib/vmware/settings. Using default values.
2019-01-29T13:45:02.596Z| host-| I125: DictionaryLoad: Cannot open file "/usr/lib/vmware/config": No such file or directory.
2019-01-29T13:45:02.596Z| host-| I125: [msg.dictionary.load.openFailed] Cannot open file "/usr/lib/vmware/config": No such file or directory.
2019-01-29T13:45:02.596Z| host-| I125: PREF Optional preferences file not found at /usr/lib/vmware/config. Using default values.
2019-01-29T13:45:02.596Z| host-| I125: DictionaryLoad: Cannot open file "/var/lib/jenkins/.vmware/config": No such file or directory.
2019-01-29T13:45:02.596Z| host-| I125: [msg.dictionary.load.openFailed] Cannot open file "/var/lib/jenkins/.vmware/config": No such file or directory.
2019-01-29T13:45:02.596Z| host-| I125: PREF Optional preferences file not found at /var/lib/jenkins/.vmware/config. Using default values.
2019-01-29T13:45:02.596Z| host-| I125: DictionaryLoad: Cannot open file "/var/lib/jenkins/.vmware/preferences": No such file or directory.
2019-01-29T13:45:02.596Z| host-| I125: [msg.dictionary.load.openFailed] Cannot open file "/var/lib/jenkins/.vmware/preferences": No such file or directory.
2019-01-29T13:45:02.596Z| host-| I125: PREF Optional preferences file not found at /var/lib/jenkins/.vmware/preferences. Using default values.
2019-01-29T13:45:02.692Z| vthread-1| I125: Error: could not open VIX wrapper config file /usr/lib/vmware/vixwrapper-product-config.txt (Could not find the file).
2019-01-29T13:45:02.692Z| vthread-1| I125: Failed to load product wrapper configuration file '/usr/lib/vmware/vixwrapper-product-config.txt'
2019-01-29T13:45:02.692Z| vthread-1| I125: No implementation found for service provider 10, apiVersion -1 installedVersion (null)
2019-01-29T13:45:02.692Z| vthread-1| I125: No Vix library found for provider 10 revision -1, err 22003

Failed to deploy OVF package: Invalid configuratoin for device '0'

Use ovftool for deployment to get a more descriptive error message. (This was an issue with video card RAM size and 3D being enabled)

Invalid VM configuration. Reason: 'Invalid configuration for device '0'.' for property 'VirtualVideoCard.videoRamSizeInKB'

Change the Video RAM size from 256Kb to 4KB and it worked.

⚠️ **GitHub.com Fallback** ⚠️