ESX Post Installation Script
ByThis is a script that will configure the networks, VLAN’s and ntp service on the ESX servers after you have a base installation complete. Just save this as a bash script and run it on each Service Console before adding the hosts to the cluster.
#!/bin/bash
#Add VMotion vmkernel port to vSwitch0
/usr/sbin/esxcfg-vswitch -A VMotion vSwitch0
/usr/sbin/esxcfg-vmknic -a -i 192.15.1.124 -n 255.255.255.0 VMotion
# Add VLANs to Service Console and VMotion Networks
esxcfg-vswitch -v 10 -p “Service Console” vSwitch0
esxcfg-vswitch -v 10 -p VMotion vSwitch0
# Add Production vSwitch1
/usr/sbin/esxcfg-vswitch -a vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic1 vSwitch1
# Add Port Groups and VLANS to vSwitch1
esxcfg-vswitch -A 192.29.6.0 vSwitch1
esxcfg-vswitch -v 50 -p 192.29.6.0 vSwitch1
esxcfg-vswitch -A 172.18.2.0 vSwitch1
esxcfg-vswitch -v 60 -p 172.18.2.0 vSwitch1
esxcfg-vswitch -A 172.18.3.0 vSwitch1
esxcfg-vswitch -v 70 -p 172.18.3.0 vSwitch1
esxcfg-vswitch -A 207.15.1.0 vSwitch1
esxcfg-vswitch -v 10 -p 207.15.1.0 vSwitch1
esxcfg-vswitch -A 175.25.0.0 vSwitch1
esxcfg-vswitch -v 2 -p 175.25.0.0 vSwitch1
# Enable/open the ntp client firewall ports
/usr/sbin/esxcfg-firewall -e ntpClient
# Setup ntpd parameters
cat > /etc/ntp.conf << NTP
restrict default kod nomodify notap noquery nopeer
restrict 127.0.0.1
server 0.us.pool.ntp.org
server 1.us.pool.ntp.org
server 2.us.pool.ntp.org
fudge 127.127.1.0 stratum 10
driftfile /etc/ntp/drift
broadcastdelay 0.008
authenticate yes
keys /etc/ntp/keys
NTP
cat > /etc/ntp/step-tickers << STEP
0.us.pool.ntp.org
1.us.pool.ntp.org
2.us.pool.ntp.org
us.pool.ntp.org
STEP
/sbin/service ntpd start
/sbin/chkconfig –level 3 ntpd on
# Update system clock
/sbin/hwclock –systohc –utc
# The –utc setting in the “timezone” command above eliminates the need for updating the clock file
#cat > /etc/sysconfig/clock << CLOCK
#ZONE=”UTC”
#UTC=true
#ARC=false
#CLOCK
# Allow incoming/outgoing communications on the Service Console via SSH.
esxcfg-firewall -e sshServer
esxcfg-firewall -e sshClient
# Create the hostsvc.xml file to specify which vmkernel port to use for VMotion — initially this file is null
cat > /etc/vmware/hostd/hostsvc.xml << VMOTION
<ConfigRoot>
<vmotion>
<nic>\VMotion</nic>
</vmotion>
</ConfigRoot>
VMOTION
# Enable VMotion by setting /proc/vmware/config/Migrate/Enabled to “1″
esxcfg-advcfg -s 1 /Migrate/Enabled
View Comments Comments
March 3rd, 2009 at 1:59 pm
Thx very much for the lines, I needed exactly this on my server.
March 3rd, 2009 at 2:03 pm
Glad it helped.
March 3rd, 2009 at 10:03 pm
Glad it helped.