Hi,
I am working on a kickstart script to autobuild my ESX servers. It is working great including the %post script section. However I have one problem. My post script can create virtual switches and port groups but I can't set the network load balancing to IP hash. The command I am using is:
/usr/bin/vmware-vim-cmd "hostsvc/net/portgroup_set --nicteaming-policy=loadbalance_ip vSwitch1 DMZ"
If I run this from the service console it works. However, when I place it in my post script it just doesn't work. Does anybody know why?
Cheers
Hi,
Can you post you %post section please (do not forget to mask DNS configuration, password, IP addresses, etc.)?
Regards.
ESX 3.5 Update 2
%post section is attached below:
%post
cat > /tmp/esxcfg.sh <<EOF1
#!/bin/sh
enable SSH root-access
mv /etc/ssh/sshd_config /etc/ssh/sshd_config.old
/bin/sed -e "s/PermitRootLogin no/PermitRootLogin yes/g" /etc/ssh/sshd_config.old > /etc/ssh/sshd_config
/etc/init.d/sshd restart
#Configure Firewall and startup services
echo "Â Â Â Configuring firewall"
chkconfig ntpd on
chkconfig snmpd on
/usr/sbin/esxcfg-firewall -e ntpClient
/usr/sbin/esxcfg-firewall -e snmpd
/usr/sbin/esxcfg-firewall -e sshClient
/usr/sbin/esxcfg-firewall -o 81,tcp,out,UpdateManager
Upsize console memory
mv -f /etc/vmware/esx.conf /etc/vmware/esx.conf.old
/bin/sed -e 's/boot\/memSize = \"272\"/boot\/memSize = \"800\"/g' /etc/vmware/esx.conf.old >> /etc/vmware/esx.conf
mv -f /boot/grub/grub.conf /tmp/grub.conf.bak
/bin/sed -e 's/uppermem 277504/uppermem 818176/g' -e 's/mem=272M/mem=800M/g' /tmp/grub.conf.bak >> /boot/grub/grub.conf
add nic on vSwitch0
/usr/sbin/esxcfg-vswitch -L vmnic9 vSwitch0
/usr/sbin/esxcfg-vswitch -L vmnic5 vSwitch0
/usr/sbin/esxcfg-vswitch -U vmnic0 vSwitch0
/usr/sbin/esxcfg-vswitch -v 51 -p "Service Console" vSwitch0
create vswitch1 with additonal nic and portgroup
/usr/sbin/esxcfg-vswitch -a vSwitch1
/usr/sbin/esxcfg-vswitch -A 172dmz vSwitch1
/usr/sbin/esxcfg-vswitch -A 17dmz vSwitch1
/usr/sbin/esxcfg-vswitch -A 127dmz vSwitch1
/usr/sbin/esxcfg-vswitch -v 504 -p 172dmz vSwitch1
/usr/sbin/esxcfg-vswitch -v 502 -p 17dmz vSwitch1
/usr/sbin/esxcfg-vswitch -v 501 -p 127dmz vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic3 vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic4 vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic7 vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic8 vSwitch1
Create VMkernel
/usr/sbin/esxcfg-vswitch -A VMkernel vSwitch0
/usr/sbin/esxcfg-vswitch -v 52 -p VMkernel vSwitch0
/usr/sbin/esxcfg-vmknic --add --ip 10.10.10.5 --netmask 255.255.255.0 VMkernel
sleep 3
Refresh the network settings with vimsh
/usr/bin/vimsh -n -e "hostsvc/net/refresh"
/usr/bin/vimsh -n -e "internalsvc/refresh_network"
Active and standby setup
/usr/bin/vmware-vim-cmd "hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic4,vmnic8 --nicorderpolicy-standby=vmnic3,vmnic7 vSwitch1 172dmz"
/usr/bin/vmware-vim-cmd "hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic7,vmnic3 --nicorderpolicy-standby=vmnic8,vmnic4 vSwitch1 127dmz"
/usr/bin/vmware-vim-cmd "hostsvc/net/portgroup_set --nicorderpolicy-active=vmnic4,vmnic8 --nicorderpolicy-standby=vmnic3,vmnic7 vSwitch1 17dmz"
/usr/bin/vimsh -n -e "hostsvc/net/refresh"
/usr/bin/vimsh -n -e "internalsvc/refresh_network"
Set Load Balancing
/usr/bin/vmware-vim-cmd "hostsvc/net/portgroup_set --nicteaming-policy=loadbalance_ip vSwitch1 127dmz"
/usr/bin/vmware-vim-cmd "hostsvc/net/portgroup_set --nicteaming-policy=loadbalance_ip vSwitch1 17dmz"
/usr/bin/vmware-vim-cmd "hostsvc/net/portgroup_set --nicteaming-policy=loadbalance_ip vSwitch1 172dmz"
Enable VMotion
/usr/bin/vimsh -n -e "hostsvc/vmotion/vnic_set vmk0"
Configure NTP
echo "Â Â Â Configuring NTP"
echo "restrict kod nomodify notrap noquery nopeer" > /etc/ntp.conf
echo "restrict 127.0.0.1" >> /etc/ntp.conf
echo "server 10.10.10.1" >> /etc/ntp.conf
echo "driftfile /var/lib/ntp/drift" >> /etc/ntp.conf
echo "10.10.10.1" > /etc/ntp/step-tickers
service ntpd start
/sbin/hwclock --systohc
/etc/init.d/mgmt-vmware restart
EOF1
/bin/chmod 755 /tmp/esxcfg.sh
cp /etc/rc.d/rc.local /etc/rc.d/rc.local.bak
cat >> /etc/rc.d/rc.local <<EOF
cd /tmp
/tmp/esxcfg.sh
mv -f /etc/rc.d/rc.local.bak /etc/rc.d/rc.local
EOF
Hi,
I think that it should work. However, have you tried without quotes:
/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --nicteaming-policy=loadbalance_ip vSwitch1 127dmz
/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --nicteaming-policy=loadbalance_ip vSwitch1 17dmz
/usr/bin/vmware-vim-cmd hostsvc/net/portgroup_set --nicteaming-policy=loadbalance_ip vSwitch1 172dmz
FYI, you can use this to configure SC memory size:
cp -f /etc/vmware/esx.conf /etc/vmware/esx.conf.old
cp -f /boot/grub/grub.conf /tmp/grub.conf.bak
sed -i 's/memSize = \"272\"/memSize = \"800\"/g' /etc/vmware/esx.conf
esxcfg-boot -g
esxcfg-boot -b
Regards.
Yes I have tried with and without the quotes but still no luck....
When I put a sleep command in the script I can capture the output and see:
Invalid command 'hostsvc/net/portgroup_set --nicteaming-policy=loadbalance_ip vSwitch1 127dmz'.
Yes I am using Cisco switches and EtherChannel is enabled. How is it an unsupported config?
Have you got any advice on my scripting problem?
I am also seeing "514 Error connecting to hostd-vmdb service instance" which might explain why my vmware-vim-cmd commands are not working.
well you probably have 3 channels?
when an active nic of one of these channels fail a standby nic will become part of the channel, but this nic is also part of a different channel. this can cause serieus problems on your network cause mac addresses are popping up on places they don't belong.
Duncan
VMware Communities User Moderator
-
Blogging: http://www.yellow-bricks.com
If you find this information useful, please award points for "correct" or "helpful".
I see your point but I have VSS enabled on the physical switches which will prevent that from happening. But if I didn't it would be a very different story.
Cheers
Are you sure? I'm no networking expert but this would mean you would have two channels with the same members? I thought VSS was for creating cross stack ether channels?
Duncan
VMware Communities User Moderator
-
If you find this information useful, please award points for "correct" or "helpful".
Hey Mike concerning the "514 Error connecting to hostd-vmdb service instance"........ I have "intermittantly" got that error when loading my hosts with a Kick Start script. I have gotten around the problem by restarting hostd in my Kick Start script and then sleeping 60 seconds to ensure hostd was fully up before continuing. These are the commands I put in my kick Start script.
service mgmt-vmware restart
sleep 60
Note sure why I had to do this....but it fixed my problem.