Virtualization Adapted Adapting Business Processes for Virtual Infrastrcuture (and vice-versa)

2009/04/16

VMware ESX host command line configuration script

Filed under: Uncategorized — Tags: , , , , — iben @ 14:46

#customize esxXX by IR Date YYYYMMDD
# ESX host configuration script for company.com
# configure as needed for esxXX by changing IP addresses below…
# configure 4 nics for nfs storage
# nic 1 and 3 – cos1, vms, vmotion
# nic 2 and 4 – vmkernel for nfs storage
#

#configure SYSLOG
echo “*.* @syslog.site.company.com” >> /etc/syslog.conf
service syslog restart

# List current config
/usr/sbin/esxcfg-nics -l
/usr/sbin/esxcfg-vswitch -l

#creating virtual switches
/usr/sbin/esxcfg-vswitch -a vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic1 vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic3 vSwitch1
/usr/sbin/esxcfg-vswitch -L vmnic2 vSwitch0
#enable CDP advertise and listen mode
/usr/sbin/esxcfg-vswitch -b vSwitch0
/usr/sbin/esxcfg-vswitch -b vSwitch1
/usr/sbin/esxcfg-vswitch -B both vSwitch0
/usr/sbin/esxcfg-vswitch -B both vSwitch1
/usr/sbin/esxcfg-vswitch -b vSwitch0
/usr/sbin/esxcfg-vswitch -b vSwitch1

#creating portgroups
/usr/sbin/esxcfg-vswitch -A “ITG-VLAN2” vSwitch0
/usr/sbin/esxcfg-vswitch -A “PUBLIC-VLAN4” vSwitch0
/usr/sbin/esxcfg-vswitch -A “VMkVMotion-VLAN209” vSwitch0
/usr/sbin/esxcfg-vswitch -A “VMkStorage-VLAN207” vSwitch1
#/usr/sbin/esxcfg-vswitch -A “Service Console” vSwitch0
/usr/sbin/esxcfg-vswitch -A “Service Console 2” vSwitch0
/usr/sbin/esxcfg-vswif -a -i 10.102.8.111 -n 255.255.255.0 -p “Service Console 2” vswif1
/usr/sbin/esxcfg-vswitch -A “ESX-VLAN208” vSwitch0
/usr/sbin/esxcfg-vmknic -a -i 10.102.7.211 -n 255.255.255.0 VMkStorage-VLAN207
/usr/sbin/esxcfg-vmknic -a -i 10.102.9.211 -n 255.255.255.0 VMkVMotion-VLAN209
/usr/sbin/esxcfg-route -a 0.0.0.0/0 10.102.7.1
/usr/sbin/esxcfg-vswif -l
/usr/sbin/esxcfg-vmknic -l

vmware-vim-cmd hostsvc/net/vswitch_setpolicy –nicteaming-policy=loadbalance_ip vSwitch0
vmware-vim-cmd hostsvc/net/vswitch_setpolicy –nicteaming-policy=loadbalance_ip vSwitch1
vmware-vim-cmd /hostsvc/net/vswitch_setpolicy –failurecriteria-check-beacon 0 vSwitch0
vmware-vim-cmd /hostsvc/net/vswitch_setpolicy –failurecriteria-check-beacon 0 vSwitch1
vmware-vim-cmd hostsvc/net/vswitch_setpolicy –securepolicy-promisc=false vSwitch0
vmware-vim-cmd hostsvc/net/vswitch_setpolicy –securepolicy-macchange=false vSwitch0
vmware-vim-cmd hostsvc/net/vswitch_setpolicy –securepolicy-forgedxmit=false vSwitch0
vmware-vim-cmd hostsvc/net/vswitch_setpolicy –securepolicy-promisc=false vSwitch1
vmware-vim-cmd hostsvc/net/vswitch_setpolicy –securepolicy-macchange=false vSwitch1
vmware-vim-cmd hostsvc/net/vswitch_setpolicy –securepolicy-forgedxmit=false vSwitch1

#configuring vlans
/usr/sbin/esxcfg-vswitch -l
/usr/sbin/esxcfg-vswitch -v 2 -p “ITG-VLAN2” vSwitch0
/usr/sbin/esxcfg-vswitch -v 4 -p “PUBLIC-VLAN4” vSwitch0
/usr/sbin/esxcfg-vswitch -v 207 -p “VMkStorage-VLAN207” vSwitch1
/usr/sbin/esxcfg-vswitch -v 209 -p “VMkVMotion-VLAN209” vSwitch0
/usr/sbin/esxcfg-vswitch -v 208 -p “Service Console” vSwitch0
/usr/sbin/esxcfg-vswitch -v 208 -p “Service Console 2” vSwitch0
/usr/sbin/esxcfg-vswitch -v 208 -p “ESX-VLAN208” vSwitch0
/usr/sbin/esxcfg-vswitch -l

#delete vmnic1 from vSwitch0 (run these if necessary)
#/usr/sbin/esxcfg-vswitch -N vmnic1 -p “ITG-VLAN2” vSwitch0
#/usr/sbin/esxcfg-vswitch -N vmnic1 -p “PUBLIC-VLAN4” vSwitch0
#/usr/sbin/esxcfg-vswitch -N vmnic1 -p “VMkStorage-VLAN207” vSwitch0
#/usr/sbin/esxcfg-vswitch -N vmnic1 -p “VMkVMotion-VLAN209” vSwitch0
#/usr/sbin/esxcfg-vswitch -N vmnic1 -p “Service Console” vSwitch0
#/usr/sbin/esxcfg-vswitch -N vmnic1 -p “Service Console 2” vSwitch0
#/usr/sbin/esxcfg-vswitch -N vmnic1 -p “ESX-VLAN208” vSwitch0

#add vmnics to each port group
/usr/sbin/esxcfg-vswitch -M vmnic2 -p “ITG-VLAN2” vSwitch0
/usr/sbin/esxcfg-vswitch -M vmnic2 -p “PUBLIC-VLAN4” vSwitch0
/usr/sbin/esxcfg-vswitch -M vmnic1 -p “VMkStorage-VLAN207” vSwitch1
/usr/sbin/esxcfg-vswitch -M vmnic3 -p “VMkStorage-VLAN207” vSwitch1
/usr/sbin/esxcfg-vswitch -M vmnic2 -p “VMkVMotion-VLAN209” vSwitch0
/usr/sbin/esxcfg-vswitch -M vmnic2 -p “Service Console” vSwitch0
/usr/sbin/esxcfg-vswitch -M vmnic2 -p “Service Console 2” vSwitch0
/usr/sbin/esxcfg-vswitch -M vmnic2 -p “ESX-VLAN208” vSwitch0
/usr/sbin/esxcfg-vswitch -l

sleep 10

#setup vmotion on the first vmk network
#vmware-vim-cmd “hostsvc/vmotion/netconfig_get” (check config)
vmware-vim-cmd hostsvc/vmotion/vnic_set vmk1

#/usr/sbin/esxcfg-vswitch -l

vmware-vim-cmd /hostsvc/net/portgroup_set –nicorderpolicy-active=vmnic0 vSwitch0 “Service Console”
vmware-vim-cmd /hostsvc/net/portgroup_set –nicorderpolicy-standby=vmnic2 vSwitch0 “Service Console”
vmware-vim-cmd /hostsvc/net/portgroup_set –nicorderpolicy-active=vmnic0 vSwitch0 “Service Console 2”
vmware-vim-cmd /hostsvc/net/portgroup_set –nicorderpolicy-standby=vmnic2 vSwitch0 “Service Console 2”
vmware-vim-cmd /hostsvc/net/portgroup_set –nicorderpolicy-active=vmnic0 vSwitch0 “VMkVMotion-VLAN209”
vmware-vim-cmd /hostsvc/net/portgroup_set –nicorderpolicy-standby=vmnic2 vSwitch0 “VMkVMotion-VLAN209”

#adding Network Attached data store
/usr/sbin/esxcfg-nas -l
/usr/sbin/esxcfg-nas -a -o NAS1-ip -s /vol/vmw_datastore1 vmw_datastore1
/usr/sbin/esxcfg-nas -a -o NAS2-ip -s /vol/vmw_datastore2 vmw_datastore2
#/usr/sbin/esxcfg-nas -a -o NAS3-ip -s /vol/vol3_vmware_test nfs_vol_netapp
/usr/sbin/esxcfg-nas -l

#configure resolv.conf
/bin/cat /dev/null > /etc/resolv.conf
echo “nameserver ns1-ip” >> /etc/resolv.conf
echo “nameserver ns2.ip” >> /etc/resolv.conf
echo “search site.company.com” >> /etc/resolv.conf
cat /etc/resolv.conf

#configure hostname
vmware-vim-cmd hostsvc/net/dns_set –dns-hostname=esxXX
vmware-vim-cmd hostsvc/net/dns_set –dns-domainname=site.company.com

#configure NTP
/usr/sbin/esxcfg-firewall -e ntpClient
/usr/sbin/ntpdate -u ntp1.site.company.com
chkconfig –list ntpd
chkconfig –level 35 ntpd on
chkconfig –list ntpd
echo “restrict ntp1-ip mask 255.255.255.255 nomodify notrap noquery” >> /etc/ntp.conf
echo “server ntp1.site.company.com” >> /etc/ntp.conf
echo “restrict ntp2-ip mask 255.255.255.255 nomodify notrap noquery” >> /etc/ntp.conf
echo “server ntp2.site.company.com” >> /etc/ntp.conf
echo “restrict ntp3-ip mask 255.255.255.255 nomodify notrap noquery” >> /etc/ntp.conf
echo “server ntp3.site.company.com” >> /etc/ntp.conf
echo “driftfile /var/lib/ntp/drift” >> /etc/ntp.conf
echo “ntp1-ip” > /etc/ntp/step-tickers
echo “ntp2-ip” >> /etc/ntp/step-tickers
echo “ntp3-ip” >> /etc/ntp/step-tickers
service ntpd restart
hwclock –systohc

#configure SUDO

esxcfg-boot -g
esxcfg-boot -b

esxcfg-advcfg -s 32 /NFS/MaxVolumes

# make sure that NFS locks are not disabled
esxcfg-advcfg -s 0 /NFS/LockDisable

# this should already be set correctly, but just to make sure
esxcfg-advcfg -s 12 /NFS/HeartbeatFrequency

# this should also be set correctly already
esxcfg-advcfg -s 10 /NFS/HeartbeatMaxFailures

# increase the heap size. Default is 9.
esxcfg-advcfg -s 30 /Net/TcpIpHeapSize

# increase heap max. Default is 30.
esxcfg-advcfg -s 120 /Net/TcpIpHeapMax

#configure AD
/usr/sbin/esxcfg-auth –enablead –addomain=site.company.com –addc=DC-NAME.site.company.com
useradd IT1
useradd IT2
#useradd Administrator

#configure SNMP
/bin/cat /dev/null > /etc/snmp/snmpd.conf
echo “syscontact IT-TEAM-DL@company.com” >> /etc/snmp/snmpd.conf
echo “syslocation Company-Location” >> /etc/snmp/snmpd.conf
echo “rocommunity RO-String” >> /etc/snmp/snmpd.conf
echo “trapcommunity RO-String” >> /etc/snmp/snmpd.conf
echo “trapsink DELL-IT-Assistant-Server.site.company.com RO-String” >> /etc/snmp/snmpd.conf
echo “dlmod SNMPESX /usr/lib/vmware/snmp/libSNMPESX.so” >> /etc/snmp/snmpd.conf
echo “smuxpeer .1.3.6.1.4.1.674.10892.1” >> /etc/snmp/snmpd.conf

#install Dell OpenManage Agent
esxcfg-firewall -o 80,tcp,out,http
/usr/bin/lwp-download http://DELL-IT-Assistant-Server.site.company.com/OM_5.5.0_ManNode_A00.targz
tar -xvf OM_5.5.0_ManNode_A00.tar.gz
cd linux/supportscripts/
./srvadmin-install.sh -b -w -r -s
srvadmin-services.sh start
esxcfg-firewall -o 1311,tcp,in,OpenManageRequest

#test by going to https://esxXX.site.company.com:1311

# service mgmt-vmware restart # if needed

#end of script

Powered by WordPress