Tuesday, September 18, 2007

vimsh : handy Vmware ESX Command line tool

Hi,

Recently learned/discovered a handy command line tool on ESX :

vimsh

If you just run vimsh and press enter, you enter a sort of separate command line interface

You can do various things with this CLI here some examples :

vmsvc/getallvms :
gives you a list of all registered virtual machines

vmsvc/poweron, vmsvc/poweroff, vmsvc/powerstate :
change/query powerstate of virtual machines

vmsvc/removedisk
remove a virtual disk while your virtual machine is online
for example vmsvc/removedisk 64 0 4 N removes SCSI device 0:4 from virtual machine with vmID 64, the N leaves the virtual disk file intact.

/hostsvc/vmotion/vnic_set portgroup3
enables vmotion on portgroup3, handy to integrate in post-setup configuration scripts

and much much more ...
You can find a detailed white paper about vimsh at the great site http://www.xtravirt.com/index.php?option=com_remository&Itemid=75&func=fileinfo&id=4

 

For scripting purposes you can use this command in non-interactive mode, for example :

vimsh -ne vmsvc/getallvms > /root/registeredvms.txt

Wednesday, June 20, 2007

Clustering your Vmware License server

Clustering your Vmware License server is quite easy but there are a few things to know.  In our setup we used a Majority Node set cluster with file share withness.  We installed the license servers on each node and uploaded the license files locally in the licensing directory.

Then we created a resource group with "IP", "Network name", and "Generic service" pointing to the Vmware License service, and if you like you can add your Virtual Center Service as well. (mind KB doc. http://kb.vmware.com/selfservice/microsites/search.do?cmd=displayKC&externalId=2195771 and be sure you use VC 2.0.1 patch2)

After starting the license server we noticed that the license server takes over the node name and not the clustered resource network name. Seems no big deal at first but apparently the ESX-servers dynamically change the license server name in their config to the node name.  If that node fails and the other node takes over the licensing service, all your ESX-servers will point to the wrong locations.

But there is a solution :

  • Stop the Vmware license server
  • Go to the license files and open them
  • Search for "SERVER this_host ANY 27000" be sure to take to one without the # in front of the line
  • Edit this line and add @<your hostname>, so for example if you clustered resource network name is "VCSERVER01" the line should be : "SERVER this_host ANY 27000@VCSERVER01"
    Clustered networknames are allways uppercase.
  • Search for "VENDOR VMWARELM port=27010" be sure to take to one without the # in front of the line
  • Edit this line and add @<your hostname>, so for example if you clustered resource network name is "VCSERVER01" the line should be : "VENDOR VMWARELM port=27010@VCSERVER01"
    Clustered networknames are allways uppercase.
  • Save the file
  • Do this for each license file
  • Copy the license files to the other node
  • Start the Vmware License service

Monday, April 2, 2007

Problems are hard, solutions are easy ...

I had a few clusters-across-boxes on my ESX-servers, and as Vmware described in its guides, I used RDM's. 

The result of that was that I wasn't able to add nor create vmfs's anymore.   Vmkwarning logs showed SCSI-reservation errors, what didn't suprise me as the MS-cluster-service does this, but I couldn't understand that the VI-client timed out on this.

After long search and consulting some college's we came to the idea to increase VI-client timeout settings.  (You can find it in the Edit menu of the VI-client, called client settings, remote command timeout)  And ofcourse that did the trick, so conclusion : problems are hard, solutions easy !

Tuesday, March 20, 2007

Lost ESX-server's root password ?!?!! :-(

After a little google-ing I found a Red Hat Enterprise password reset procedure, that also works on ESX 3, actually it's quite easy.

  1. Reboot your ESX-server.
  2. In the Linux GRUB menu select "Service Console" and press "e" to edit.
  3. Go to the line that starts with "kernel" and press "e" again
  4. Append the word "single" at the end of the line and press enter
  5. Press "b" to boot with these options
  6. Once the system is booted you get a Linux command prompt, where you can enter "passwd" to change the password
  7. Reboot and login using your new password

Friday, March 16, 2007

Virtual Center High Availability ...

How to ... for now I'm not sure ...

I have a 2 site config with 2 ESX-clusters one in each site.
I thought to install a MNS-cluster with a file share witness, and use the new cluster-aware features of VC with patch 2.

I would like to virtualize the 2 cluster nodes and put 1 node in each site, and maybe put the witness file share in a 3th site.

It's certainly something to consider but not sure if it will work ... waiting for input from Vmware support ...

to be continued ...

Saturday, March 10, 2007

Unattended install of ESX with Microsoft's RIS-server

I needed to install a lot of ESX servers and thought of a little automation.So I looked around the web and found this link : http://www.vmware.com/community/message.jspa?messageID=466174

In short it comes to this :

Setup the RIS Server :

  1. Install DHCP and RIS
  2. On your RIS server create the following folder structure: Setup\English\Images\PXELinux\i386\templates\pxelinux.cfg\ (pxelinux.cfg is a folder)
  3. Download the latest version of syslinux from: http://www.kernel.org/pub/linux/utils/boot/syslinux/
  4. From the ESX 3 (this works with 2.5.x as well) CD (images\pxeboot) copy the following files to Setup\English\Images\PXELinux\i386\templates vmlinuz initrd.img

    NOTE: you MAY want to rename these files IF you plan on have multiple versions of ESX builds available.
  5. From the file you downloaded in step 2, copy the pxelinux.0 to the templates folder.
  6. Create a file called pxelinux.sif file in the template folder with the following contents: [OSChooser]
    Description = "Linux"
    Help = "This option runs a Linux installer."
    LaunchFile = "Setup\English\Images\PXELinux\i386\templates\pxelinux.0"
    ImageType = Flat Version="1.01"
  7. In the Setup\English\Images\PXELinux\i386\templates\pxelinux.cfg folder create a file called 'default' (no extension) with the following info.
    DEFAULT esx
    prompt 1
    display boot.msg
    timeout 1000
    label esx
    kernel vmlinuz append initrd=initrd.img
  8. Install NFS on your RIS server, Windows 2003 R2 provides it as a standard component
  9. Create an NFS share with a copy of the Vmware ESX 3.0.1 CD.
  10. Enable scripted installation feature on an already installed ESX to create the answer files.
    You can use this link page 94 : http://www.vmware.com/pdf/vi3_installation_guide.pdf
  11. Log in to the ESX Server 3.0.1 service console as root.
  12. Open the file/usr/lib/vmware/webAccess/tomcat/apache-tomcat-5.5.17/webapps/ui/WEB-INF/struts-config.xml in a text editor such as vi.
  13. Locate the scripted section.
  14. Comment out the line reading:
  15. Uncomment the following lines:
  16. Save and close the file.
  17. Type service vmware-webAccess restart.
  18. Launch a supported Web browser and enter the URL of your ESX Server installation to open VI Web Access.The Welcome page appears.
  19. Click Log in to the Scripted Installer.
  20. Follow the onscreen instructions to create and download the answer file
  21. Save the answer file in the root of your NFS share.
  22. Boot your new physical server, let it boot from PXE
  23. At the boot: type esx and the link to the answer file you want to use during install, for example : esx ks=nfs:192.168.29.45:/PXEInstallESX/KS.cfg

TIP : If you have the MAC-addresses of your servers up-front (some hardware vendors can provide this info together with the serial number of the server), you can create additionale files in the Setup\English\Images\PXELinux\i386\templates\pxelinux.cfg directory. Name them after MAC-addresses of your servers.
DEFAULT esx
prompt 1
display boot.msg
timeout 1000
label esx
kernel vmlinuz
append initrd=initrd.img ks=nfs:192.168.29.45:/PXEInstallESX/KS.cfg

This way everything would be fully automated.

Have fun with it ...

Thursday, January 18, 2007

Problems upgrading ESX 3.0 to 3.0.1

Hi,

Upgrading ESX 3.0 to ESX 3.0.1 with a remote repository is not really working for me.
Found a very helpfull post on http://www.vmug.nl/

Seems that it's better to upgrade yum-2.0.7-3vmw.noarch.rpm and VMware-esx-scripts-3.0.1-32039.i386.rpm manually first and then do the esxupdate. Vmware-Esx-Scripts contains the esxupdate script itself, and that script seems to use yum.

The way to do it : Go into the 32039 directory, as root and type :
1) rpm -Uvh yum-2.0.7-3vmw.noarch.rpm
2) rpm -Uvh VMware-esx-scripts-3.0.1-32039.i386.rpm
3) esxupdate -f update

Tuesday, January 16, 2007

Vmware ESX 3 patch updates through FTP ...

Hi,

Allthough we only have four ESX-servers for the moment I tried to make a ftp-repository for all ESX-patches. I put the FTP-server on my virtual center server. But it didn't work proporly, I allways got this error :

# esxupdate -r ftp://172.28.247.223/dslib/ESX-1006511 update
INFO: Configuring...
INFO: Preparing to install VMware ESX Server ESX-1006511...
ERROR: Error (1) executing [yum info] retrygrab() failed for: ftp://172.28.247.223/dslib/ESX-1006511/headers/header.info
Executing failover method failover: out of servers to try Error getting file ftp://172.28.247.223/dslib/ESX-1006511/headers/header.info[Errno 6]
ERROR: Url Return no Content-Length - something is wrong
Gathering header information file(s) from server(s) Server:
Esxupdate-compatible repository for VMware ESX Server ESX-1006511

After some google-ing I found this procedure:

  • Login to the service console as root
  • Change directory to /usr/share/yum
  • Make a backup copy of urlgrabber.py (IMPORTANT) cp urlgrabber.py urlgrabber.py.BAK
  • Edit urlgrabber.py and find the following lines:

    if have_urllib2 or scheme != 'file':
    # urllib does not provide content-length for local files
    if not hdr is None and not hdr.has_key('Content-Length'):
    raise URLGrabError(6, _('ERROR: Url Return no Content-Length - something is wrong'))
  • Comment them out (Add a '#' at the beginning of the line):

    # if have_urllib2 or scheme != 'file': #
    # urllib does not provide content-length for local files
    # if not hdr is None and not hdr.has_key('Content-Length'):
    # raise URLGrabError(6, _('ERROR: Url Return no Content-Length - something is wrong')) Try the esxupdate command again..

  • Then try the esxupdate again

Friday, January 12, 2007

ESX 3.0 can use datastores on NFS and Windows R2 is NFS-capable out of the box ...

Hi,

Yesterday I had the idea to make an NFS-share on my Virtual Center server. I would like to use it as a repository for ISOs and VM-Templates to make it easier for Windows Admins to upload ISOs to a Virtual Infrastructure. If this works they only need to copy their ISOs to the right location on the Virtual Center server and all ESX's have automatically access to the ISOs, floppies, ... No hassle with sftp, accounts on the ESX, ...

As my VC is a Windows 2003 R2 I could just install NFS by using "Add/Remove Windows Components". It's a build-in feature now.

First try :
I installed the NFS components, shared a folder, with NFS's standard settings, and made the NFS-links in Virtual Center on every ESX-box.
Everything looks good but the connection wasn't really stable. Copying large files always failed.

Second try :
I found some info on the web to adjust a few settings on the windows side :
  • Anonymous UID: 2 (instead of the std -2)
  • Anonymous GID: 0 (instead of the std -2)

Next step for me will be to secure this, although everything is in a private VLAN, I would like to have some access control ...

Sunday, January 7, 2007

Change TSprofile for a lot of users ...

Recently I had to change a lot of user's TS-profile settings, I wasn't able to do it with GPO's because I had to deal with W2k Citrix Servers so I tried to use the TSprof.exe-tool but that didn't work also because I had a %-sign in the TS-profile. The %value% was directly translated and only the result was saved in the user property, so I made a little VB-program using Visual Basic Express Ed. to do the job, ... (code and .exe included)

You can use it this way :

Changes tsprofilepaths of users listed in file.
Usage : UpdateTSprofile -s:[servername] -f:[path/file] -p:[tsroamingprofilepath]

-h help, shows this info
-s:[servername] domaincontroller to connect to
-f:[path/file]
file path with users to update format should be one domain\user a line

-p:[tsroamingprofilepath]
path to tsroamingprofilepath if this contains % replace % with ?

Caution : Existing TS-profile Value's will be replaced

Saturday, January 6, 2007

My first article ...

My first article ... Not sure where this will go but we will see what the future brings. I will try to put some professional experiences here ...
For example last week I was confronted with a few ESX-servers installed with tiny partitions, and no separate partition for /var/log ...
A best practice should be to provide a separate partition for /var or /var/log.But of course if it's installed this way you have to live with it ...
I used a standard feature of most Linux/Unix machines that is also included in ESX 2.5/3.0 : "logrotate" ...
Here the procedure :


On ESX servers there should be separate partitions for /var and/or /var/log, if those partitions are to small or integrated in to the "/"-partition it can destabilize the ESX-server.

To adjust the automatic logrotate/Cleanup please use this procedure :

  1. SSH-logon to the ESX-server
  2. su to get root permissions
  3. vi /etc/logrotate.conf --> changes are in red

    # see "man logrotate" for details
    # rotate log files weekly
    weekly
    # keep 4 weeks worth of backlogs
    rotate 2
    # create new (empty) log files after rotating old onescreate
    # uncomment this if you want your log files compressed
    compress
    # RPM packages drop log rotation information into this directoryinclude /etc/logrotate.d
    # no packages own lastlog or wtmp -- we'll rotate them here
    /var/log/wtmp {
    monthly
    create 0664 root utmp
    rotate 1
    }
    # system-specific logs may be also be configured here.

  4. vi /etc/logrotate.d/vmkernel --> changes are in red

    /var/log/vmkernel {
    missingok
    compress
    # keep a history over 3 years.
    weekly
    rotate 2

    # max log size of 200k (thus limiting total disk usage to under 8megs)
    size 100k
    sharedscripts
    postrotate
    /bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null true
    endscript
    }

  5. run this command : "/usr/sbin/logrotate -f /etc/logrotate.conf"
  6. go to the /var/log dir and cleanup, a last time manually, all log-files with an extension greater or equal then .2
  7. exit