话不多说,直接进入主题,步骤在附件里,直接复制粘贴就ok。
在此附上esxi自动化脚本
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw password
# Choose the first discovered disk to install onto
install --firstdisk --overwritevmfs
#autopart --firstdisk --overwritevmfs
# The installation media is in the CD-ROM drive
#network --bootproto=dhcp --device=vmnic0
#
reboot
$SNIPPET('network_config_esxi')
%pre --interpreter=busybox
$SNIPPET('kickstart_start')
$SNIPPET('pre_install_network_config')
%post --interpreter=busybox
%firstboot --interpreter=busybox
# Set the root password for the DCUI and Tech Support Mode
SN=`esxcli hardware platform get | grep "Serial Number" | awk -F ":" '{print $NF}' | sed 's/ //g'`
NAME=`esxcli hardware platform get | grep "Product Name" | awk -F ":" '{print $NF}'`
wget -q -P /opt http://172.21.200.200/config/esxserver
IPADDR=`cat /opt/esxserver | grep $SN | awk -F "," '{print $1}'`
GATEWAY=`cat /opt/esxserver | grep $SN | awk -F "," '{print $2}'`
###network config####
esxcli network ip set --ipv6-enabled false
esxcli network vswitch standard uplink add --uplink-name=vmnic1 --vswitch-name=vSwitch0
# Add vMotion Portgroup to vSwitch0, assign it VLAN ID 5 and create a VMkernel interface
esxcli network vswitch standard portgroup add --portgroup-name=vMotion --vswitch-name=vSwitch0
esxcli network vswitch standard portgroup set --portgroup-name=vMotion --vlan-id=2060
esxcli network vswitch standard portgroup set --portgroup-name="Management Network" --vlan-id=2060
esxcli network ip interface add --interface-name=vmk0 --portgroup-name=vMotion
#esxcfg-vswitch --vlan=2060 --pg="Management Network" vSwitch0
esxcli network ip interface ipv4 set --interface-name=vmk0 --ipv4=$IPADDR --netmask=255.255.255.0 --type=static
esxcli network ip route ipv4 add --gateway=192.168.1.254 --network=default
rm -fr /opt/esxserver
# Enable vMotion on the newly created VMkernel vmk1
vim-cmd hostsvc/vmotion/vnic_set vmk0
# Set DNS and hostname
esxcli network ip dns search add --domain=localdomain
esxcli network ip dns server add --server=202.106.196.115
esxcli network ip dns server add --server=8.8.8.8
# Set the default PSP for EMC V-MAX to Round Robin as that is our preferred load balancing mechan
esxcli storage nmp satp set --default-psp VMW_PSP_RR --satp VMW_SATP_SYMM
# Disable Netq #
esxcfg-module -s force_netq=0,0,0,0 tg3
esxcfg-advcfg -k FALSE netNetqueueEnabled
# Enable SSH and the ESXi Shell
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh
vim-cmd hostsvc/enable_esx_shell vim-cmd hostsvc/start_esx_shell
$SNIPPET('kickstart_done')