A. Mikkelsen

VMware ESX scripts, commands, tools and other nice to know things that will make your virtualization days easier!!!!

Browsing Posts in vSphere (ESX)

Yesterday we upgraded one of our vSphere Clusters to 4.1 – it went smoothly 🙂

But today the users reported that they weren’t able to use cut % paste between the guest and their computer using the vSphere Client (Console).

After a quick google we found that VMware has tightened the vSphere security by disabling this feature. See VMware KB 1026437.

If you need the cut & paste functionality you can enable it again on the guest or host level.

For a single VM:

  • Using the vSpher Client logon to your vCenter server.
  • Poweroff the VM.
  • Edit the VM’s settings
  • Navigate to Options > Advanced > General
  • Click Configuration Parameters
  • Add the following rows, by using Add Row
    isolation.tools.copy.disable –  false
    isolation.tools.paste.disable  – false
    
  • Click OK twice to close the dialogs and save the changes.
  • PowerOn the VM

For all VM’s on a host ESX/ESXi

Must be done on all hosts, so you don’t loose the functionality when the VM is migrated to another host.

  • Open a SSH to the host ex. using Putty
  • Open /etc/vmware/config in your favorit editor .
  • Add these lines to the file

    isolation.tools.copy.disable="FALSE"
    isolation.tools.paste.disable="FALSE"
    
  • Save and close the config file. Cut & Paste will work after a VM powerson, reboots or resume.

Friday I was at a customer to upgrade their ESXi 4.0 (free) to version 4.1.
This should have been an easy task, download CD, burn it and install.

This wasn’t the case, the new ESXi 4.1 wouldn’t install, it kept freezing during the extract of the cim.vgz file.
The problem occurred on both the Dell custom of ESXi 4.0 U1 and the standard ESXi 4.1.
We googled and googled but didn’t find a solution – in the end we blamed the error on the old bios version 1.1.4.

To my luck the customer still had the CD we installed the server with 9 months ago – ESXi 4.0.

We installed ESXi using the old CD and then everything was working – but we still needed to upgrade to ESXi 4.1.

So now what to do …….

Normally you use the hostupdate utility or the Remote CLI but the hostupdate utility is not included in the free version of ESXi and the we didn’t want to install the Remote CLI on the computer.
To my luck I had the hostupdate utility installed but i kept getting this error when trying to upgrade the ESXi host.

“Failed to read the upgrade package metadata.xml”

The solution to our problem was:

  1. Since it was a ESXi free with out support, we decided to use the “ESXi command line interface”, witch is unsupported.
    Follow this guide to enable it (http://www.bauer-power.net/2010/04/vmware-esxi-hack-to-allow-ssh.html).
  2. Download and extract the upgrade ZIP file from VMware.
  3. From the VIclient, upload the extracted files to the host datastore, using the “datastore browser”
    – I uploaded the files to a folder named “upgrade”
  4. Put the ESXi host in “Maintance Mode”
    – Since it is a ESXi, this can only be done when all VM’s are powered off.
  5. Connect the the ESXi console using ex. Putty.exe.
  6. Navigate to the upgrade directory.
    cd /vmfs/volumes/local-datastore/upgrade
  7. Begin the upgrade process
    esxupdate update -m metadata.zip
    
  8. When the upgrade is finished, reboot the host.
    reboot
  9. To verify the new build number:
    – Connect to the host using the VIclient
    – Select the host
    – Choose the “Summery” tab
    – Verify that the ESXi version number and build has been updated

VMware has released their hardening guide for vSphere 4.0.

There is more than 100 guidelines to choose from, divided between

  • Introduction
  • Virtual Machines
  • Host (both ESXi and ESX)
  • vNetwork
  • vCenter
  • Console OS (for ESX only)

http://blogs.vmware.com/security/2010/04/vsphere-40-hardening-guide-released.html

Time keeping in a virtual environment can be a challenge to setup.

To help you, VMware has maintained a KB on the subject.
http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1318

The KB presents best practices for achieving accurate timekeeping in Windows Guest operating systems. These recommendations include a suggested configuration for timesynchronization in the guest and on the host.

A more specific guide also exists for Windows and Linux servers:
For Windows read:
http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&docType=kc&externalId=1318&sliceId=1&docTypeID=DT_KB_1_1&dialogID=73678717&stateId=0%200%2078515868
For Linux read:
http://kb.vmware.com/selfservice/microsites/microsite.do?cmd=displayKCPopup&docType=kc&externalId=1006427&sliceId=1&docTypeID=DT_KB_1_1

It’s great reading, but very nerdy 🙂

Today I needed to create a list of all users connected to a vCenter sever through the Client.
And during so I created a few variants 🙂

This creates a list of all usernames connected to the vCenter server through a vCenter Client.

$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
foreach ($sess in $sessMgr.SessionList){
   write "$($sess.UserName)"
}

If you want to see a witch clients have been idle for 60 minutes try this.

$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
foreach ($sess in $sessMgr.SessionList){
    if (($sess.LastActiveTime).addminutes(60) -lt (Get-Date)){
        write "$($sess.UserName)"
      }
}

If you the want to terminate the sessions that have been inactive  for more than 60 minute

$svcRef = new-object VMware.Vim.ManagedObjectReference
$svcRef.Type = "ServiceInstance"
$svcRef.Value = "ServiceInstance"
$serviceInstance = get-view $svcRef
$sessMgr = get-view $serviceInstance.Content.sessionManager
$oldSessions = @()
foreach ($sess in $sessMgr.SessionList){
    if (($sess.LastActiveTime).addminutes(60) -lt (Get-Date)){
        $oldSessions += $sess.Key
      }
}
$sessMgr.TerminateSession($oldSessions)

You can modify the hell out of this script to suit your needs and be my guest….

You can download the full script here.

The scripts are based on code found  at the PowerCLI community by LucD.
http://communities.vmware.com/message/914858#914858

vLogView by Xtravirt

No comments

vLogView, helps you view and search all LOG files from each of your ESX hosts from a single application.

For more info and the latest download, visit http://xtravirt.com/xd10132

vlogview

If you need a good guide to Interpreting the statistic from ESXTOP then take a look at this guide from VMware.

http://communities.vmware.com/docs/DOC-9279

I’m using it to troubleshoot performance issues (poor response times) from clients in different locations, when using the remote console.

Restarting the Management agents on ESX Server 3.x

  1. Login to the ESX host using SSH (or from COS)
  2. Type service mgmt-vmware restart.
    CAUTION
    Before restarting the Management Agent make sure that Automatic Startup/Shutdown is Disabled
    For more info see
    Restarting hostd (mgmt-vmware) on ESX Server Hosts Restarts Hosted Virtual Machines Where Virtual Machine Startup/Shutdown is Enabled (1003312)
  3. Type service vmware-vpxa restart.
  4. Exit the SSH session or logout of COS

Just found this very interesting article http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1013109 describing a problem with Windows 2008 and ESX 4 virtual hardware version 7.

In short the article states that you might have the disks go offline in a Windows 2008 VM if you

  • Upgrade virtual hardware from version 4 to 7
  • Installing a new VM with virtual hardware 7

There is two ways to get around this (taken from the VMware KB 103109)

————————

This can be resolved by changing the SAN Automount Policy on the system. See the Microsoft article http://support.microsoft.com/kb/973834 to change the SAN Policy to online.
The SAN policy is defined within the VDS environment of the system and is represented by the following values:
  • VDS_SP_UNKNOWN = 0x0
  • VDS_SP_ONLINE = 0x1
  • VDS_SP_OFFLINE_SHARED = 0x2
  • VDS_SP_OFFLINE = 0x3
On Windows Server 2008 Enterprise and Windows Server 2008 Datacenter, the default SAN policy is VDS_SP_OFFLINE_SHARED. On all other Windows Server 2008 editions, the default SAN policy is VDS_SP_ONLINE.
To query current SAN policy from the command line, start DISKPART and issue a SAN command:
C:\>DISKPART.EXE
DISKPART> san
SAN Policy : Offline Shared

DISKPART> exit

Alternatively, you can set the disk to Online after the hardware version upgrade.
To set the disk to Online:
  1. Log in to your system as an Administrator.
  2. Click Computer Management > Storage > Disk Management.
  3. Right-click the disk and choose Online.

If you are looking for a easy and simple guide for setting up iSCSI on vSphere (ESX 4.x) you might want to take a look at this guide from www.techhead.co.uk
http://www.techhead.co.uk/vmware-esxi-4-0-vsphere-connecting-to-an-iscsi-storage-target

Powered by WordPress Web Design by SRS Solutions © 2019 A. Mikkelsen Design by SRS Solutions