VMware

Jonathan Marrott's VM Scripting Blog

January 18, 2008


0

Additional Blog, etc.

Posted by froboy Jan 18, 2008

Since this particular blog is dedicated to VMWare and scripting, I have created a more general tech blog. This blog will also contain some VMWare info that is not scripting related. Initially it contains notes from the recent ESX training I went through. If you have been through the Install and Configure training and are preparing for your VCP exam, these notes will prove very helpful. I just passed my VCP exam today with a 91%. That was lower than I wanted, but I did hurry through it in about 30 min. I am sure that I glazed over some questions.

You can find it at:
My Tech Blog

0 Comments Permalink
0

Firewall - XML Changes (Updated)

Posted by froboy Jan 18, 2008

I decided that I didn't like changing the firewall by executing esxcfg-firewall all the time. So I edited the appropriate XML file to include the nececssary ports for TSM and VMM (HP) agent. This is different for ESX 3.0.x and 3.5. One word of caution: In ESX 3.5 if you add a service to services.xml and it exists in another XML file. You can render your system inaccessible.

ESX 3.5
Service - TSM
Location - ibmTSM.xml

<!-- Firewall configuration information for IBM TSM -->
<ConfigRoot>
<service>
<id>TSM</id>
<rule id='0000'>
<direction>inbound</direction>
<protocol>tcp</protocol>
<port type='dst'>1500</port>
<flags>-m state --state NEW</flags>
</rule>
<rule id='0001'>
<direction>outbound</direction>
<protocol>tcp</protocol>
<port type='dst'>1500</port>
<flags>-m state --state NEW</flags>
</rule>
<rule id='0002'>
<direction>inbound</direction>
<protocol>tcp</protocol>
<port type='dst'>
<begin>1581</begin>
<end>1583</end>
</port>
<flags>-m state --state NEW</flags>
</rule>
<rule id='0003'>
<direction>outbound</direction>
<protocol>tcp</protocol>
<port type='dst'>
<begin>1581</begin>
<end>1583</end>
</port>
<flags>-m state --state NEW</flags>
</rule>
</service>
</ConfigRoot>

ESX 3.0.x
Service - TSM
Location - services.xml
<service id='0023'>
<id>TSM</id>
<rule id='0000'>
<direction>inbound</direction>
<protocol>tcp</protocol>
<port type='dst'>1500</port>
<flags>-m state --state NEW</flags>
</rule>
<rule id='0001'>
<direction>outbound</direction>
<protocol>tcp</protocol>
<port type='dst'>1500</port>
<flags>-m state --state NEW</flags>
</rule>
<rule id='0002'>
<direction>inbound</direction>
<protocol>tcp</protocol>
<port type='dst'>
<begin>1581</begin>
<end>1583</end>
</port>
<flags>-m state --state NEW</flags>
</rule>
<rule id='0003'>
<direction>outbound</direction>
<protocol>tcp</protocol>
<port type='dst'>
<begin>1581</begin>
<end>1583</end>
</port>
<flags>-m state --state NEW</flags>
</rule>
</service>

Service - VMM
Location - services.xml
Note: We discontinued use of VMM do to VM reboots.

<service id='0028'>
<id>VmmService</id>
<rule id='0000'>
<direction>inbound</direction>
<protocol>tcp</protocol>
<port type='dst'>
<begin>1124</begin>
<end>1126</end>
</port>
<flags>-m state --state NEW</flags>
</rule>
<rule id='0001'>
<direction>outbound</direction>
<protocol>tcp</protocol>
<port type='dst'>
<begin>1124</begin>
<end>1126</end>
</port>
<flags>-m state --state NEW</flags>
</rule>
</service>

0 Comments Permalink
5

Enable VMotion on VMKernel port

Posted by froboy Jan 18, 2008

This will enable VMotion on a VMKernel port. I am writing this one because it changed between verisons of ESX. This command uses the very useful vimsh.

ESX 3.0.x:
vimsh -n -e "/hostsvc/vmotion/vnic_set portgroup2"
portgroup# - Determined by the order of portgroup creation. The system automatically makes one to begin with.

ESX 3.5:
vimsh -n -e "/hostsvc/vmotion/vnic_set vmk0"
vmk# - Determined by the order of the VMKernel port creation. The first one created is '0'.

5 Comments Permalink
3

Create NFS Mount on ESX (Updated)

Posted by froboy Jan 18, 2008

I like to have a mount on each of my ESX servers to allow for quick installations and centralized scripting for cron jobs.

NFS Mount visible from host and service console:
<Required to have a Service Console and VMKernel port>
This can be accessed from /vmfs/volumes/<datastore>
esxcfg-firewall -e nfsClient
esxcfg-nas -a -o nfsserver.yourdomain.com -s /vol/vm nfs01

Manual mount visible from the service console only:
1. Edit /etc/rc.d/rc.local
2. Add: mount nfsserver.yourdomain.com:/vol/vm /mnt/vm
This will allow it to mount on boot.
3. Execute: mkdir /mnt/vm
4. Execute: chkconfig portmap on
5. Execute: service portmap start
6. Execute: esxcfg-firewall -e nfsClient
7. Execute: mount nfsserver.yourdomain.com:/vol/vm /mnt/vm
This will immediately mount.

3 Comments Permalink
0

DNS - Set Servers (Updated)

Posted by froboy Jan 18, 2008

Simple script to set DNS servers. This sets muplitle DNS servers while kickstart by default only sets one.

Set DNS servers using vimsh:
vimsh -n -e "/hostsvc/net/dns_set --dns-addresses=192.168.0.1,192.168.0.2 --dns-searchdomain=yourdomain.com"

Set DNS servers by manually creating resolv.conf:
cat > /etc/resolv.conf << EOF1

search yourdomain.com
nameserver 192.168.0.4
nameserver 192.168.0.6

EOF1

0 Comments Permalink
0

ESX Friendly Method:
Install IO:Tty -
1. Download Perl-IO-TTY from here
2. Copy to your host or execute from a shared location
3. Execute 'rpm -ivh perl-IO-Tty-1.07-1.el3.rf.i386.rpm'

Install Expect.pm -
1. Download Perl-Expect from here
2. Copy to your host or execute from a shared location
3. Execute 'rpm -ivh perl-Expect-1.21-1.el3.rf.noarch.rpm'

Pain-in-the-butt Method:
You can download these from http://sourceforge.net/projects/expectperl/

The installation itself is pretty simple. IO::Tty needs to be installed first. This installation does not add additional items to run in RAM.

Install IO:Tty -
1. Decompress file.
2. Browse to location of files.
3. Execute perl Makefile.PL
4. Execute make
5. Execute make install

Install Expect.pm -
1. Decompress file.
2. Browse to location of files.
3. Execute perl Makefile.PL
4. Execute make
5. Execute make install

0 Comments Permalink
4

The service console memory should be increased if you are running apps other than the default install. This includes management agents, backups, etc. Here is a simple command that I ran across to accomplish this. It requires a reboot to take effect. I incorporate this in my kickstart script. Don't forget to set your swap partition to be 2x the Service Console memory.

See Current Setting:
The setting shown is in bytes (MB * 1024 * 1024)
vimsh -n -e "/hostsvc/memoryinfo"
serviceConsoleReserved - Current setting
serviceConsoleReservedCfg - Setting after next reboot

Set to 800MB with vimsh:
vimsh -n -e "/hostsvc/memoryinfo 838860800"

Set by manual edit of files:
mv -f /etc/vmware/esx.conf /tmp/esx.conf.bak
sed -e 's/boot\/memSize = \"272\"/boot\/memSize = \"512\"/g' /tmp/esx.conf.bak >> /etc/vmware/esx.conf

mv -f /boot/grub/grub.conf /tmp/grub.conf.bak
sed -e 's/uppermem 277504/uppermem 523264/g' -e 's/mem=272M/mem=512M/g' /tmp/grub.conf.bak >> /boot/grub/grub.conf

If you feel like setting it to the maximum of 800 MB.

mv -f /etc/vmware/esx.conf /tmp/esx.conf.bak
sed -e 's/boot\/memSize = \"272\"/boot\/memSize = \"800\"/g' /tmp/esx.conf.bak >> /etc/vmware/esx.conf

mv -f /boot/grub/grub.conf /tmp/grub.conf.bak
sed -e 's/uppermem 277504/uppermem 818176/g' -e 's/mem=272M/mem=800M/g' /tmp/grub.conf.bak >> /boot/grub/grub.conf

4 Comments Permalink
Click to view froboy's profile Member since: Jun 26, 2006

A swell blog containing some of the scripts I have written for VM management.

View froboy's profile

Communities