测试环境:win10/vmware workstation 12 pro

操作系统:RHEL 6.5(PXE服务器)

【2016.11.30】

【遗留问题】

1、ks.cfg通过本地文件方式加载不成功,只能通过http://方式成功 ,以下几种尝试都是不成功的。

ks=file:esxi5.1/ks.cfg
   ks=ks.cfg
   ks=tftp://192.168.148.1/esxi5.1/ks.cfg

安装与配置:


。安装DHCP

。安装XINETD, 并启用TFTP服务

。安装syslinux(yum安装):会自动在tftpboot目录下放置pxelinux.0及seamenu.c32文件,还有一些其它文件

配置DHCP: 在地址分配子项中增加filename "pxelinux.0"

配置tftp: enable一下即可,无其它特殊配置,无需-c,整个过程不会向tftp写文件

配置菜单:在tftpboot目录下,创建一个文件夹:pxelinux.cfg。然后再建立default文件,即菜单文件

配置好之后,就可以启动一台PXE客户端进行测试了,正常情况下,就可以显示菜单了。说明PXE配置成功了,接下来就可以根据实际安装需求,定制default文件、制定ks.cfg文件及布署安装包了。

利用PXE方式安装ESXi 5.1


参考文档:主要是vmware的官方文档

准备:

  • 下载ESXi 5.1的ISO安装包,并在tftpboot下建立目录esxi5.1
  • 将iso文件解开后,将文件copy至esxi5.1下(不能只接将ISO mount到esxi5.1目录,因为要修改文件)

配置:

pxelinux.cfg/default文件: (可以将esxi5.1中的isolinux.cfg文件COPY过来进行修改,主要修改为正确的目录路径)

default menu.c32
menu title PXE BOOT VMWARE ESXI
timeout 100label ESXi
menu label Boot VMware ESXikernel esxi5.1/mboot.c32append -c esxi5.1/boot.cfg     //注意此处boot.cfg要修改menu label esxi5.1-xxxxxx

//整个文件相对简单,只是增加了相对目录esxi5.1

  esxi5.1/boot.cfg文件:由于原ISO是光盘模式的,故每个文件都给出了绝对路径/(根)

[root@localhost esxi5.1]# cat boot.cfg
bootstate=0
title=Loading ESXi installer
kernel=/tboot.b00
kernelopt=runweasel
modules=/b.b00 --- /useropts.gz --- /k.b00 --- /chardevs.b00 --- /a.b00 --- /user.b00 --- /s.v00 --- /ata_pata.v00 --- /ata_pata.v01 --- /ata_pata.v02 --- /ata_pata.v03 --- /ata_pata.v04 --- /ata_pata.v05 --- /ata_pata.v06 --- /ata_pata.v07 --- /block_cc.v00 --- /ehci_ehc.v00 --- /weaselin.t00 --- /esx_dvfi.v00 --- /xlibs.v00 --- /ima_qla4.v00 --- /ipmi_ipm.v00 --- /ipmi_ipm.v01 --- /ipmi_ipm.v02 --- /misc_cni.v00 --- /misc_dri.v00 --- /net_be2n.v00 --- /net_bnx2.v00 --- /net_bnx2.v01 --- /net_cnic.v00 --- /net_e100.v00 --- /net_e100.v01 --- /net_enic.v00 --- /net_forc.v00 --- /net_igb.v00 --- /net_ixgb.v00 --- /net_nx_n.v00 --- /net_r816.v00 --- /net_r816.v01 --- /net_s2io.v00 --- /net_sky2.v00 --- /net_tg3.v00 --- /net_vmxn.v00 --- /ohci_usb.v00 --- /sata_ahc.v00 --- /sata_ata.v00 --- /sata_sat.v00 --- /sata_sat.v01 --- /sata_sat.v02 --- /sata_sat.v03 --- /sata_sat.v04 --- /scsi_aac.v00 --- /scsi_adp.v00 --- /scsi_aic.v00 --- /scsi_bnx.v00 --- /scsi_fni.v00 --- /scsi_hps.v00 --- /scsi_ips.v00 --- /scsi_lpf.v00 --- /scsi_meg.v00 --- /scsi_meg.v01 --- /scsi_meg.v02 --- /scsi_mpt.v00 --- /scsi_mpt.v01 --- /scsi_mpt.v02 --- /scsi_qla.v00 --- /scsi_qla.v01 --- /scsi_rst.v00 --- /uhci_usb.v00 --- /tools.t00 --- /xorg.v00 --- /imgdb.tgz --- /imgpayld.tgz
build=
updated=0

  

但由于我们采用PXE方式,文件不再位于根,而是位于tftp服务器的esxi5.1目录下,因此,需要将所有/替换成esxi5.1/xxx。操作如下:

首先,将所有/都替换掉,VI命令:%s#/##g

然后在modules这行前面加入一行:prefix=esxi5.1/ (这条命令全局有效,不在乎所在位置)

“kernel=......”一行为 kernel=tboot.b00,此处不加esxi5.1/

启动pxe client测试:

通过上面设置后,启动PXE CLIENT,基本就能出现安装界面了,只需要选择键盘、安装位置,基本没什么选项(问题:在何处加载第三方驱动)。

这种方法只是实现了PXE安装,但没有实现无人值守的自动安装。

ESXi 5实现全自动安装(无需人工连接键盘、显示器):这里要用到ks.cfg文件(kickstart)


就增加两个步骤:1)生成ks.cfg    2)在default文件中传递该ks.cfg文件给核心

任何一台esxi安装完成后,会自动生成一个etc/vmware/weasel/ks.cfg,可通过修改这个文件定制必要的参数,实验中采用了如下ks.cfg

#
# Sample scripted installation file
#
# Accept the VMware End User License Agreement
vmaccepteula
# Set the root password for the DCUI and Tech Support Mode
rootpw iampeter319
# The install media is in the CD-ROM drive
install --firstdisk --overwritevmfs
# Set the network to DHCP on the first network adapater
#network --bootproto=dhcp --device=vmnic0
network --bootproto=static --device=vmnic0 --ip=192.168.148.100 --netmask=255.255.252.0 --gateway=192.168.148.1
reboot
# A sample post-install script
%post --interpreter=python --ignorefailure=true
import time
stampFile = open('/finished.stamp', mode='w')
stampFile.write( time.asctime() )

具体参数及语法,可参考vmware官方文档。这里只改了network项及安装完成后自动reboot。

准备好ks.cfg文件后,需要将其位置传递给核心,可以通过protocol:// , cdrom://, file://, usb://等方式。在实验中,采用file方式没有成功,原因不详。最后采用http://<PXESERVER_IP>/ks.cfg的方式(即将ks.cfg拷贝至apache的/var/www/html目录下)

按照官方文档的说明,应该是修改boot.cfg文件,通过kernelopt=ks=http://xxxx/ks.cfg进行传递。但感觉这样不方便,未采用,而采用了修改default文件的方法,效果一样。

修改原boot.cfg文件中的倒数第二行,更改为如下:

 append -c esxi5.1/boot.cfg ks=http://192.168.148.128/ks.cfg

还有一种特殊的做法:ESXi在启动成功后,会在其虚拟文件系统中产生一个/etc/vmware/weasel/ks.cfg文件。如果我们传递如下格式:

ks=file://etc/vmware/weasel/ks.cfg

则ESXi也会自动安装,但是参数是不受控制的,因为是自动生成的。这种方式安装完成后,密码空,IP地址为自动获取。

【说明】在生成ks.cfg文件后,可以不修改default文件进行传递,而是在ESXi开始安装时,通过按Shift-O键,手工进行传递,之后就会自动进行了。

由于ks的内容较多,以下是两个例子,比较全面,全自动安装并且自动设置包括:网络、SSH、vSwitch等等

# Sample kickstart for ESXi 5.1
# William Lam
# www.virtuallyghetto.com
#########################################accepteula
install --firstdisk --overwritevmfs
rootpw vmware123
reboot#下面这句应该往前提,放在reboot之前,估计是作者手误%include /tmp/networkconfig
%pre --interpreter=busybox# extract network info from bootup
VMK_INT="vmk0"
VMK_LINE=$(localcli network ip interface ipv4 get | grep "${VMK_INT}")
IPADDR=$(echo "${VMK_LINE}" | awk '{print $2}')
NETMASK=$(echo "${VMK_LINE}" | awk '{print $3}')
GATEWAY=$(localcli network ip route ipv4 list | grep default | awk '{print $3}')
DNS="172.30.0.100,172.30.0.200"
HOSTNAME=$(nslookup "${IPADDR}" "${DNS}" | grep Address | grep "${IPADDR}" | awk '{print $4}')echo "network --bootproto=static --addvmportgroup=false --device=vmnic0 --ip=${IPADDR} --netmask=${NETMASK} --gateway=${GATEWAY} --nameserver=${DNS} --hostname=${HOSTNAME}" > /tmp/networkconfig%firstboot --interpreter=busybox# enable VHV (Virtual Hardware Virtualization to run nested 64bit Guests + Hyper-V VM)
grep -i "vhv.enable" /etc/vmware/config || echo "vhv.enable = \"TRUE\"" >> /etc/vmware/config# enable & start remote ESXi Shell  (SSH)
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh# enable & start ESXi Shell (TSM)
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell# supress ESXi Shell shell warning - Thanks to Duncan (http://www.yellow-bricks.com/2011/07/21/esxi-5-suppressing-the-localremote-shell-warning/)
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1# ESXi Shell interactive idle time logout
esxcli system settings advanced set -o /UserVars/ESXiShellInteractiveTimeOut -i 3600# Change the default ESXi Admins group "ESX Admins" to a custom one "Ghetto ESXI Admins" for AD
vim-cmd hostsvc/advopt/update Config.HostAgent.plugins.hostsvc.esxAdminsGroup string "Ghetto ESXi Admins"# Users that will have full access to DCUI even if they don't have admin permssions on ESXi host
vim-cmd hostsvc/advopt/update DCUI.Access string root,william,tuan# Block VM guest BPDU packets, global configuration
esxcli system settings advanced set -o /Net/BlockGuestBPDU -i 1# copy SSH authorized keys & overwrite existing
wget http://air.primp-industries.com/esxi5/id_dsa.pub -O /etc/ssh/keys-root/authorized_keys# disable SSH keys - uncomment the next section
# sed -i 's/AuthorizedKeysFile*/#AuthorizedKeysFile/g' /etc/ssh/sshd_config# rename local datastore to something more meaningful
vim-cmd hostsvc/datastore/rename datastore1 "$(hostname -s)-local-storage-1"# assign license
vim-cmd vimsvc/license --set AAAAA-BBBBB-CCCCC-DDDDD-EEEEE## SATP CONFIGURATIONS ##
esxcli storage nmp satp set --satp VMW_SATP_SYMM --default-psp VMW_PSP_RR
esxcli storage nmp satp set --satp VMW_SATP_DEFAULT_AA --default-psp VMW_PSP_RR###########################
## vSwitch configuration ##
################################################################################
# vSwitch0 : Active->vmnic0,vmnic1 Standby->vmnic2
#       failback: yes
#       faildectection: beacon
#       load balancing: portid
#       notify switches: yes
#       avg bw: 1000000 Kbps
#       peak bw: 1000000 Kbps
#       burst size: 819200 KBps
#       allow forged transmits: yes
#       allow mac change: no
#       allow promiscuous no
#       cdp status: both# attach vmnic1,vmnic2 to vSwitch0
esxcli network vswitch standard uplink add --uplink-name vmnic1 --vswitch-name vSwitch0
esxcli network vswitch standard uplink add --uplink-name vmnic2 --vswitch-name vSwitch0# configure portgroup
esxcli network vswitch standard portgroup add --portgroup-name VMNetwork1 --vswitch-name vSwitch0
esxcli network vswitch standard portgroup set --portgroup-name VMNetwork1 --vlan-id 100
esxcli network vswitch standard portgroup add --portgroup-name VMNetwork2 --vswitch-name vSwitch0
esxcli network vswitch standard portgroup set --portgroup-name VMNetwork2 --vlan-id 200
esxcli network vswitch standard portgroup add --portgroup-name VMNetwork3 --vswitch-name vSwitch0
esxcli network vswitch standard portgroup set --portgroup-name VMNetwork3 --vlan-id 333# configure cdp
esxcli network vswitch standard set --cdp-status both --vswitch-name vSwitch1### FAILOVER CONFIGURATIONS #### configure active and standby uplinks for vSwitch0
esxcli network vswitch standard policy failover set --active-uplinks vmnic0,vmnic1 --standby-uplinks vmnic2 --vswitch-name vSwitch0# configure failure detection + load balancing (could have appended to previous line)
esxcli network vswitch standard policy failover set --failback yes --failure-detection beacon --load-balancing portid --notify-switches yes --vswitch-name vSwitch0### SECURITY CONFIGURATION ###
esxcli network vswitch standard policy security set --allow-forged-transmits yes --allow-mac-change no --allow-promiscuous no --vswitch-name vSwitch0### SHAPING CONFIGURATION ###
esxcli network vswitch standard policy shaping set --enabled yes --avg-bandwidth 100000 --peak-bandwidth 100000 --burst-size 819200 --vswitch-name vSwitch0#####################################################
# vSwitch1 : Active->vmnic3,vmnic4 Standby->vmnic5
#       failback: no
#       faildectection: link
#       load balancing: mac
#       notify switches: no
#       allow forged transmits: no
#       allow mac change: no
#       allow promiscuous no
#       cdp status: listen
#       mtu: 9000# add vSwitch1
esxcli network vswitch standard add --ports 256 --vswitch-name vSwitch1# attach vmnic3,4,5 to vSwitch0
esxcli network vswitch standard uplink add --uplink-name vmnic3 --vswitch-name vSwitch1
esxcli network vswitch standard uplink add --uplink-name vmnic4 --vswitch-name vSwitch1
esxcli network vswitch standard uplink add --uplink-name vmnic5 --vswitch-name vSwitch1# configure mtu + cdp
esxcli network vswitch standard set --mtu 9000 --cdp-status listen --vswitch-name vSwitch1# configure portgroup
esxcli network vswitch standard portgroup add --portgroup-name NFS --vswitch-name vSwitch1
esxcli network vswitch standard portgroup add --portgroup-name FT_VMOTION --vswitch-name vSwitch1
esxcli network vswitch standard portgroup add --portgroup-name VSPHERE_REPLICATION --vswitch-name vSwitch1### FAILOVER CONFIGURATIONS #### configure active and standby uplinks for vSwitch1
esxcli network vswitch standard policy failover set --active-uplinks vmnic3,vmnic4 --standby-uplinks vmnic5 --vswitch-name vSwitch1# configure failure detection + load balancing (could have appended to previous line)
esxcli network vswitch standard policy failover set --failback no --failure-detection link --load-balancing mac --notify-switches no --vswitch-name vSwitch1### SECURITY CONFIGURATION ###
esxcli network vswitch standard policy security set --allow-forged-transmits no --allow-mac-change no --allow-promiscuous no --vswitch-name vSwitch1# configure vmkernel interface for NFS traffic, FT_VMOTION and VSPHERE_REPLICATION traffic
VMK0_IPADDR=$(esxcli network ip interface ipv4 get | grep vmk0 | awk '{print $2}')
VMK1_IPADDR=$(echo ${VMK0_IPADDR} | awk '{print $1".51."$3"."$4}' FS=.)
VMK2_IPADDR=10.10.0.2
VMK3_IPADDR=10.20.0.2
esxcli network ip interface add --interface-name vmk1 --mtu 9000 --portgroup-name NFS
esxcli network ip interface ipv4 set --interface-name vmk1 --ipv4 ${VMK1_IPADDR} --netmask 255.255.255.0 --type static
esxcli network ip interface add --interface-name vmk2 --mtu 9000 --portgroup-name FT_VMOTION
esxcli network ip interface ipv4 set --interface-name vmk2 --ipv4 ${VMK2_IPADDR} --netmask 255.255.255.0 --type static
esxcli network ip interface add --interface-name vmk3 --mtu 9000 --portgroup-name VSPHERE_REPLICATION
esxcli network ip interface ipv4 set --interface-name vmk3 --ipv4 ${VMK3_IPADDR} --netmask 255.255.255.0 --type static# Configure VMkernel traffic type (Management, VMotion, faultToleranceLogging, vSphereReplication)
esxcli network ip interface tag add -i vmk2 -t Management
esxcli network ip interface tag add -i vmk2 -t VMotion
esxcli network ip interface tag add -i vmk2 -t faultToleranceLogging
esxcli network ip interface tag add -i vmk3 -t vSphereReplication# Configure VMkernel routes
esxcli network ip route ipv4 add -n 10.20.183/24 -g 172.30.0.1
esxcli network ip route ipv4 add -n 10.20.182/24 -g 172.30.0.1# Disable IPv6 for VMkernel interfaces
esxcli system module parameters set -m tcpip3 -p ipv6=0### MOUNT NFS DATASTORE ###
esxcli storage nfs add --host 172.51.0.200 --share /volumes/Primp/primp-6 --volume-name himalaya-NFS-primp-6### ADV CONFIGURATIONS ###
esxcli system settings advanced set --option /Net/TcpipHeapSize --int-value 30
esxcli system settings advanced set --option /Net/TcpipHeapMax --int-value 120
esxcli system settings advanced set --option /NFS/HeartbeatMaxFailures --int-value 10
esxcli system settings advanced set --option /NFS/HeartbeatFrequency --int-value 20
esxcli system settings advanced set --option /NFS/HeartbeatTimeout --int-value 10
esxcli system settings advanced set --option /NFS/MaxVolumes --int-value 128### SYSLOG CONFIGURATION ###
esxcli system syslog config set --default-rotate 20 --loghost vcenter50-3.primp-industries.com:514,udp://vcenter50-3.primp-industries.com:514,ssl://vcenter50-3.primp-industries.com:1514,udp://vcenter50-3.primp-industries.com:514,udp://vcenter50-3.primp-industries.com:514,ssl://vcenter50-3.primp-industries.com:1514,ssl://vcenter50-3.primp-industries.com:1514# change the individual syslog rotation count
esxcli system syslog config logger set --id=hostd --rotate=20 --size=2048
esxcli system syslog config logger set --id=vmkernel --rotate=20 --size=2048
esxcli system syslog config logger set --id=fdm --rotate=20
esxcli system syslog config logger set --id=vpxa --rotate=20### NTP CONFIGURATIONS ###
cat > /etc/ntp.conf << __NTP_CONFIG__
restrict default kod nomodify notrap noquery nopeer
restrict 127.0.0.1
server 0.vmware.pool.ntp.org
server 1.vmware.pool.ntp.org
__NTP_CONFIG__
/sbin/chkconfig ntpd on### FIREWALL CONFIGURATION #### enable firewall
esxcli network firewall set --default-action false --enabled yes# services to enable by default
FIREWALL_SERVICES="syslog sshClient ntpClient updateManager httpClient netdump"
for SERVICE in ${FIREWALL_SERVICES}
doesxcli network firewall ruleset set --ruleset-id ${SERVICE} --enabled yes
done# backup ESXi configuration to persist changes
/sbin/auto-backup.sh# enter maintenance mode
esxcli system maintenanceMode set -e true# copy %first boot script logs to persisted datastore
cp /var/log/hostd.log "/vmfs/volumes/$(hostname -s)-local-storage-1/firstboot-hostd.log"
cp /var/log/esxi_install.log "/vmfs/volumes/$(hostname -s)-local-storage-1/firstboot-esxi_install.log"# Needed for configuration changes that could not be performed in esxcli
esxcli system shutdown reboot -d 60 -r "rebooting after host configurations"

  另外一个ks.cfg例子,包含如何放弃ipv6, 如何配置ntp

# Accept the VMware End User License Agreementvmaccepteula# Set the root password for the DCUI and ESXi Shell rootpw --iscrypted yHYo5Lev6wbMg # Set the keyboardkeyboard German# Install on the first local disk available on machineinstall --firstdisk --overwritevmfs# Set the network network --bootproto=static  --device=vmnic0 --addvmportgroup=0 --hostname=ewie1vmesx01.aareal.org --ip=xxx.xxx.xxx.xxx--netmask=255.255.255.0 --gateway=xxx.xxx.xxx.xxx--nameserver="xxx.xxx.xxx.xxx"# reboots the host after the scripted installation is completedreboot%firstboot --interpreter=busybox#####SWITCH0 - VMANAGE ######### Add an extra nic to vSwitch0 and add Name esxcli network vswitch standard uplink add --uplink-name=vmnic1 --vswitch-name=vSwitch0# configure active and standby uplinks for vSwitch0esxcli network vswitch standard policy failover set --active-uplinks=vmnic0,vmnic1 --vswitch-name=vSwitch0####SWITCH1 - VMOTION ######### Add new vSwitch for VMotion, assign uplinks, create a portgroup for Switch1                  esxcli network vswitch standard add --vswitch-name=vSwitch1 --ports=256esxcli network vswitch standard uplink add --uplink-name=vmnic2 --vswitch-name=vSwitch1esxcli network vswitch standard uplink add --uplink-name=vmnic3 --vswitch-name=vSwitch1#Add vMotion Portgroup to vSwitch1esxcli network vswitch standard portgroup add --portgroup-name=vMotion --vswitch-name=vSwitch1# Enable vMotion on the newly created VMkernel vmk1esxcli network ip interface add --interface-name=vmk1 --portgroup-name=vMotionesxcli network ip interface ipv4 set --interface-name=vmk1 --ipv4=172.27.196.10 --netmask=255.255.255.0 --type=static# Enable vMotion on the newly created VMkernel vmk1vim-cmd hostsvc/vmotion/vnic_set vmk1# configure active and standby uplinks for vSwitch1esxcli network vswitch standard policy failover set --active-uplinks=vmnic2,vmnic3 --vswitch-name=vSwitch1####SWITCH2 - Virtual Machines ######## # Add new vSwitch for VirtualMachines , assign uplinks, create a portgroup                     esxcli network vswitch standard add --vswitch-name=vSwitch2 --ports=504esxcli network vswitch standard uplink add --uplink-name=vmnic4 --vswitch-name=vSwitch2esxcli network vswitch standard uplink add --uplink-name=vmnic5 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup add --portgroup-name=PUB_172_27_193_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PUB_172_27_193_0 --vlan-id=99esxcli network vswitch standard portgroup add --portgroup-name=PUB_172_27_194_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PUB_172_27_194_0 --vlan-id=101esxcli network vswitch standard portgroup add --portgroup-name=PUB_172_27_195_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PUB_172_27_195_0 --vlan-id=195esxcli network vswitch standard portgroup add --portgroup-name=PUB_172_27_197_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PUB_172_27_197_0 --vlan-id=197esxcli network vswitch standard portgroup add --portgroup-name=PUB_172_27_198_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PUB_172_27_198_0 --vlan-id=198esxcli network vswitch standard portgroup add --portgroup-name=PRIV_172_27_231_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PRIV_172_27_231_0 --vlan-id=231esxcli network vswitch standard portgroup add --portgroup-name=PRIV_172_27_232_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PRIV_172_27_232_0 --vlan-id=232esxcli network vswitch standard portgroup add --portgroup-name=PRIV_172_27_233_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PRIV_172_27_233_0 --vlan-id=233esxcli network vswitch standard portgroup add --portgroup-name=PRIV_172_27_234_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PRIV_172_27_234_0 --vlan-id=234esxcli network vswitch standard portgroup add --portgroup-name=PRIV_172_27_235_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PRIV_172_27_235_0 --vlan-id=235esxcli network vswitch standard portgroup add --portgroup-name=PRIV_172_27_236_0 --vswitch-name=vSwitch2esxcli network vswitch standard portgroup set --portgroup-name=PRIV_172_27_236_0 --vlan-id=236# configure active and standby uplinks for vSwitch2esxcli network vswitch standard policy failover set --active-uplinks=vmnic4,vmnic5 --vswitch-name=vSwitch2# Enable SSH and the ESXi Shellvim-cmd hostsvc/enable_sshvim-cmd hostsvc/start_sshvim-cmd hostsvc/enable_esx_shellvim-cmd hostsvc/start_esx_shell# Set the default PSP for Netapp to Round Robin as that is our preferred load balancing mechanismesxcli storage nmp satp set --default-psp VMW_PSP_RR --satp VMW_SATP_ALUA# Rename local datastore to something more meaningful vim-cmd hostsvc/datastore/rename datastore1 "$(hostname -s)_datastore1"#Disable IPv6 and Reboot#esxcli system module parameters set -m=tcpip3 -p ipv6=0esxcli network ip set --ipv6-enabled=falseesxcli system shutdown reboot -d 60 -r "making IPv6 config changes"### NTP CONFIGURATIONS ###cat >/etc/ntp.conf<<__NTP_CONFIG__restrict default kod nomodify notrap noquerynopeerrestrict 127.0.0.1server 0.192.168.1.72server 1.192.168.1.73__NTP_CONFIG__
/sbin/chkconfig ntpd on

【关于ipv6】上面有两种方法可以disable掉IPV6。但是esxcli的重启语句需要先进入维护模式才能执行。也可以简单的在%firstboot的最后加一行reboot,直接重启。

以下这个ks.cfg文件是我在实验中用到的,已经通过试验,基本功能都有了。(自己增加了DNS项)

#
# Sample scripted installation file
#
# Accept the VMware End User License Agreement
vmaccepteula
rootpw iampeter
install --firstdisk --overwritevmfs
%include /tmp/networkconfigreboot%pre --interpreter=busybox# extract network info from bootup
VMK_INT="vmk0"
VMK_LINE=$(localcli network ip interface ipv4 get | grep "${VMK_INT}")
IPADDR=$(echo "${VMK_LINE}" | awk '{print $2}')
NETMASK=$(echo "${VMK_LINE}" | awk '{print $3}')
GATEWAY=$(localcli network ip route ipv4 list | grep default | awk '{print $3}')

DNS=$(localcli network ip dns server list | grep DNS | awk -F ':' '{ print $2 }')
#DNS="172.30.0.100,172.30.0.200"
#HOSTNAME=$(nslookup "${IPADDR}" "${DNS}" | grep Address | grep "${IPADDR}" | awk '{print $4}')echo "network --bootproto=static --addvmportgroup=false --device=vmnic0 --ip=${IPADDR} --netmask=${NETMASK} --gateway=${GATEWAY} --nameserver=${DNS} --hostname=esxi55" > /tmp/networkconfig%firstboot --interpreter=busybox# enable VHV (Virtual Hardware Virtualization to run nested 64bit Guests + Hyper-V VM)
grep -i "vhv.enable" /etc/vmware/config || echo "vhv.enable = \"TRUE\"" >> /etc/vmware/config# enable & start remote ESXi Shell  (SSH)
vim-cmd hostsvc/enable_ssh
vim-cmd hostsvc/start_ssh# enable & start ESXi Shell (TSM)
vim-cmd hostsvc/enable_esx_shell
vim-cmd hostsvc/start_esx_shell#disable ipv6
#esxcli network ip set --ipv6-enabled=false
#esxcli system module parameters set -m tcpip3 -p ipv6=0esxcli network ip set --ipv6-enabled=false
esxcli system shutdown reboot -d 60 -r "making IPv6 config changes"### NTP CONFIGURATIONS ###
cat >/etc/ntp.conf<<__NTP_CONFIG__
restrict default kod nomodify notrap noquerynopeer
restrict 127.0.0.1
server 192.168.200.128
__NTP_CONFIG__
/sbin/chkconfig ntpd on# supress ESXi Shell shell warning - Thanks to Duncan (http://www.yellow-bricks.com/2011/07/21/esxi-5-suppressing-the-localremote-shell-warning/)
esxcli system settings advanced set -o /UserVars/SuppressShellWarning -i 1reboot
# A sample post-install script
%post --interpreter=python --ignorefailure=true
import time
stampFile = open('/finished.stamp', mode='w')
stampFile.write( time.asctime() )

  

采用http方式:


前面介绍的方法,文件的抓取都是通过tftp方式。在网络环境不佳的情况下,tftp 采用的udp方式没有http的tcp方式稳定。根据vmware官方文档,可采用http方式代替tftp方式

1、pxelinux.0是tftp方式;gpxelinux.0是http方式,因此,更改dhcp.conf的filename "gpxelinux.0"

2、修改boot.cfg,将prefix=esxi5.1/;改为: http://x.x.x.x/esxi5.1/

3、相应的文件夹做好链接,并用浏览器做好测试,就可以执行http的安装了。

Windows平台PXE的实现


windows平台下要实现pxe,也需要dhcp,tftp,(option)http。tiny pxe server 1.0版可以实现该功能。它不仅内置了tftp,dhcp,http,而且内置了pxelinux.0及gpxelinux,软件仅有不到5M。

需要注意:所有服务器的根是files目录,其它的和linux下是一样的。在进行esxi安装时,配置文件需要linux格式,特别是ks文件。如果格式不是linux格式(unix,ansi)而是windows文本格式,就会出现许多莫名其妙的问题。

工作流程分析(根据抓包结果得出):


1.DHCP: 分配IP地址,并分配pxelinux.0文件名告之PXE client
2. Client通过tftp拿到pxelinux.0,大约19个blocks
3. Client运行pxelinux.0, 准备拿配置文件
4. 连续tftp几个文件(由于只配置了default,肯定找不到),pxelinux.cfg目录下

564d330d-5a45-e2de-eb15-88e321e7dfd2 【未知】
01-00-0c-29-e7-df-d2 【此文件名是01,加上PXE CLIENT主机的MAC地址,可采用这种方式进行个性化定制】
C0A89464 【此为该主机的IP地址(192 168 148 100)的十六进制表示,下面类同,这样可以实现针对不同主机或一类主机的定制化配置】
C0A8946
C0A894
C0A89
C0A8
C0A
C0
C

以上文件没有配置,最后取得default文件。Default文件如下:

default vesamenu.c32
timeout 100menu background splash.jpg
menu title Welcome to Install System --BY Lvyunlabel Auto_CentOS
menu label Auto Install CentOS6.2
menu default
kernel CentOS/vmlinuz
append initrd=CentOS/initrd.img ks=nfs:192.168.2.58:/mnt/ks/ks.cfglabel Custom_CentOS
menu label Custom Install CentOS6.2
kernel CentOS/vmlinuz

  

5. 成功后,client再读取default文件,得知要用vesamenu.c32, 则继续tftp,取vesamenu.c32,大约117blocks
6. Client取到相应的menu.c32,就在client上运行,client根据之前拿到的default显示菜单

Troubleshooting:


1. pxe client DHCP成功,但是tftp.....报错

pxe服务器的iptables没有关掉(与宿主windows的防火墙无关)

2. DHCP成功,tftp也能拿到pxelinux.0,但就是拿不到default,提示权限问题。在tftp服务器上手工tftp get default文件,也说是权限问题不能拿到。

原因:selinux关闭就好了。

etc/vmware/weasel/ks.cfg

转载于:https://www.cnblogs.com/peterhu318/p/6116954.html

RHEL 6.5 PXE 安装调试 VMWARE ESXi 5.1 安装相关推荐

  1. 试图运行项目时出错,无法启动调试。没有正确安装调试器,请运行安装程序安装或恢复调试器。...

            用Visual Studio.net 2003调试项目时,出现错误对话框,显示如下:         试图运行项目时出错,无法启动调试.没有正确安装调试器,请运行安装程序安装或恢复调试 ...

  2. 群晖pxe安装windows_通过PXE快速部署VMware ESXi 6.5

    说明 我们一般默认安装ESXi 都是通过cd或者u盘之类的介质进行安装ESXi系统,不过如果我们的环境新到一大批服务器并且需要在规定的时间内完成系统的部署,那么一台台部署显然是不可能的,所以我们就使用 ...

  3. Pxe + Kickstart脚本 +VMWare NAT模式 自动安装 ESXi 6.5

    目标: 在虚拟机上测试通过PXE自动安装ESXi,为硬件安装ESXi做准备. 实验环境: Windows 10 (主机) VMWare workstation 15  (运行于主机上) Tiny PX ...

  4. VMware ESXi 6.7安装配置

    VMware ESXi 6.7 已与2016年11月15日发布,如下介绍其安装过程.同以往ESXi产品安装区别不大. 本次安装过程演示,采用VMware Workstation 15 平台进行安装.如 ...

  5. 虚拟机安装VMware ESXi 6.7安装过程介绍

    环境 : vmware 14 1.从VMware官网或其他渠道获取到ESXi 6.7安装文件,本示例采用如下版本: 2.打开workstation 14,依次选择"文件"-&quo ...

  6. VMWARE ESXi 7.0安装吃120G空间解决办法

    安装VMWARE ESXi 7.0的过程中被多占用了一个VMFSL的空间.本来就不富裕的磁盘被占用很是悲伤,需要解决. 直接说结论,很难删除VMFSL.So,直接再安装一次吧!!! 最佳方式是在安装E ...

  7. 服务器虚拟机6的安装教程,VMware vCenter 6.7 安装过程(图文教程)

    本文关键详细介绍了VMware vCenter 6.7 安装全过程,原文中根据实例编码详细介绍的十分详尽,对大伙儿的学习培训或是工作中具备一定的参照学习培训使用价值,必须的小伙伴们下边伴随着我来一起学 ...

  8. VMware ESXi 6.5 安装NVIDIA K2 GPU 显卡硬件驱动和配置图文

    安装请参考 ​​https://blogs.vmware.com/apps/2018/09/using-gpus-with-virtual-machines-on-vsphere-part-3-ins ...

  9. VMware ESXi 5.0安装图文教程

    在虚拟化领域VMware.Citrix.Microsoft都有不错的解决方案而在服务器虚拟化领域VMware又占据着领导者地位游侠www.2cto.com今天也装了个平台与大家一起分享. VMware ...

最新文章

  1. 如何优化Spring Cloud微服务注册中心架构?
  2. 搭建多语言外文网站需要注意三个细节问题
  3. 深度学习之卷积神经网络(12)深度残差网络
  4. html代码编辑器sp,在线HTML编译,文本关键字高亮显示,富文本编辑实现大概思路...
  5. 宽容与忍耐 忍乃济——这是《尚书》这部中国令世人刮目的奇书告诉我们的真理 保身第一法:谦逊;处事第一法:安详;待人第一法:涵容(宽容);养心第一法:洒脱...
  6. 如何把Linux工具里的“军刀”BusyBox移植到RT-Thread Smart?
  7. python爬取百度百科搜索结果_用Python抓取百度搜索结果,python,爬取,的
  8. 【Python】Python实战从入门到精通之七 -- 教你深入理解异常处理
  9. PhoneGap出现错误,找不到www/index.html页面
  10. 设计模式再学习之简单工厂模式
  11. 在MFC中调用DLL .
  12. 【iOS】Ambiguous reference to member 'tableView(_:numberOfRowsInSection:)'
  13. R语言信用评分卡:探索性数据分析
  14. 推荐一个用Flutter写的仿网易云音乐项目(已开源)
  15. Mysql重新安装(ubuntu)
  16. 强大的CHM电子书或CHM帮助文件的快速制作工具Easy CHM
  17. php优缺点ppt,ppt和pdf有什么区别
  18. android app与gprs通信,gprs连接管理app
  19. python 转换数字为中文的大写
  20. 山中无甲子,寒尽不知年

热门文章

  1. MiniImageNet数据集重新划分训练集、测试集、验证集
  2. /proc/self/environ等敏感文件
  3. 安徽省六安市2021高考成绩查询系统,2021六安市地区高考成绩排名查询,六安市高考各高中成绩喜报榜单...
  4. 物联网无线串口WiFi模块,智能生活无线应用,无线WiFi模组技术
  5. 一篇文章教会你利用Python网络爬虫获取穷游攻略
  6. python基于PHP+MySQL的健身房管理系统
  7. 2022-2027年中国地质工程行业市场全景评估及发展战略规划报告
  8. cornerstone 无限期使用配置
  9. Matlab中利用findpeaks找波峰和波谷
  10. 制作U盘/MP3的个性图标。