RHEL6.6 PXE安裝-基於VMWare WorkStation

///////////第一部分:安裝安裝服務器html

1.先安裝一臺RHEL6.6的服務器A(地址爲192.168.139.132),做爲安裝服務器。這樣後面的機器就能夠指向這臺服務器進行自動安裝python

2.在A上安裝http服務器linux

3.將OS的文件拷貝到/var/www/html/rhel6.6express

4.在A上安裝createrepo工具/rhel6.6bash

5.在A上創建repo。指向http://192.168.139.132服務器

6.準備kickstart文件app

修改配置:因爲安裝服務器是用的cdrom安裝,但後面的服務器須要從http服務上安裝,因此須要修改less

#cdrom
url --url http://192.168.139.132/rhel6.6/
將cdrom註釋掉,增長一條url指令ide

固然也能夠把fireware和selinux關掉工具

[root@localhost ~]# cp anaconda-ks.cfg /var/www/html/
[root@localhost ~]# chmod 777 /var/www/html/anaconda-ks.cfg

# Kickstart file automatically generated by anaconda.

#version=DEVEL
install
#cdrom
url --url http://192.168.139.132/rhel6.6-install
lang en_US.UTF-8
keyboard us
network --onboot yes --device eth0 --bootproto dhcp
rootpw  --iscrypted $1$3MFQKYIJ$ifM2hjwz62pookT7VokgJ.
# Reboot after installation
reboot
firewall --disabled
authconfig --useshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# here so unless you clear all partitions first, this is
# not guaranteed to work
clearpart --all --initlabel
zerombr
part /boot --fstype=ext4 --size=300
part / --fstype=ext4 --grow --size=3000
part swap --grow --maxsize=2048 --size=2048




%packages
@Base
@Core
@Desktop
@Fonts
@General Purpose Desktop
@Internet Browser
@Printing client
@X Window System
binutils
gcc
kernel-devel
make
patch
python

%end

%post
if [ -f /boot/grub/menu.lst -a ! -h /boot/grub/menu.lst ]; then cp /boot/grub/menu.lst /boot/grub/menu.lst.bak && sed -i 's/ rhgb//' /boot/grub/menu.lst; fi
if [ -f /boot/grub/grub.conf -a ! -h /boot/grub/grub.conf ]; then cp /boot/grub/grub.conf /boot/grub/grub.conf.bak && sed -i 's/ rhgb//' /boot/grub/grub.conf; fi
if [ -f /boot/grub2/grub.conf -a ! -h /boot/grub2/grub.conf ]; then cp /boot/grub2/grub.conf /boot/grub2/grub.conf.bak && sed -i 's/ rhgb//' /boot/grub2/grub.conf; fi
if [ -f /etc/rc.d/rc.local ]; then cp /etc/rc.d/rc.local /etc/rc.d/rc.local.backup; fi
cat >>/etc/rc.d/rc.local <<EOF
#!/bin/bash
echo
echo "Installing VMware Tools, please wait..."
if [ -x /usr/sbin/getenforce ]; then oldenforce=\$(/usr/sbin/getenforce); /usr/sbin/setenforce permissive || true; fi
mkdir -p /tmp/vmware-toolsmnt0
for i in hda sr0 scd0; do mount -t iso9660 /dev/\$i /tmp/vmware-toolsmnt0 && break; done
cp -a /tmp/vmware-toolsmnt0 /opt/vmware-tools-installer
chmod 755 /opt/vmware-tools-installer
cd /opt/vmware-tools-installer
mv upgra32 vmware-tools-upgrader-32
mv upgra64 vmware-tools-upgrader-64
mv upgrade.sh run_upgrader.sh
chmod +x /opt/vmware-tools-installer/*upgr*
umount /tmp/vmware-toolsmnt0
rmdir /tmp/vmware-toolsmnt0
if [ -x /usr/bin/rhgb-client ]; then /usr/bin/rhgb-client --quit; fi
cd /opt/vmware-tools-installer
for s in sr0 sr1; do eject -s /dev/\$s; done
./run_upgrader.sh
if [ -f /etc/rc.d/rc.local.backup ]; then mv /etc/rc.d/rc.local.backup /etc/rc.d/rc.local; else rm -f /etc/rc.d/rc.local; fi
rm -rf /opt/vmware-tools-installer
sed -i 's/3:initdefault/5:initdefault/' /etc/inittab
if [ -f /boot/grub/menu.lst.bak ]; then mv /boot/grub/menu.lst.bak /boot/grub/menu.lst; fi
if [ -f /boot/grub/grub.conf.bak ]; then mv /boot/grub/grub.conf.bak /boot/grub/grub.conf; fi
if [ -f /boot/grub2/grub.conf.bak ]; then mv /boot/grub2/grub.conf.bak /boot/grub2/grub.conf; fi
if [ -x /usr/sbin/getenforce ]; then /usr/sbin/setenforce \$oldenforce || true; fi
if [ -x /bin/systemd ]; then systemctl restart prefdm.service; else telinit 5; fi
EOF
chmod 755 /etc/rc.d/rc.local
if [ -x /bin/systemd ]; then systemctl enable rc-local.service; fi
/usr/sbin/adduser littlesuccess
/usr/sbin/usermod -p '$1$3MFQKYIJ$ifM2hjwz62pookT7VokgJ.' littlesuccess
/usr/bin/chfn -f "RHEL6.6" littlesuccess
/bin/echo done
%end

 

///////////////第二部分:安裝必要工具/////////////

1.安裝syslinux

yum install syslinux

2.安裝dhcp

yum install dhcp

須要進行配置

vi /etc/dhcp/dhcpd.conf

內容以下:

ddns-update-style interim;
ignore client-updates;

allow booting;
allow bootp;

class "pxeclients"{
match if substring(option vendor-class-identifier,0,9) = "PXEClient";
filename "pxelinux.0";
next-server 192.168.139.132;
}

subnet 192.168.139.0 netmask 255.255.255.0 {
option routers 192.168.139.1;
option subnet-mask 255.255.255.0;
option time-offset -18000; # Eastern Standard Time
range dynamic-bootp 192.168.139.2 192.168.139.254;
default-lease-time 216000;
max-lease-time 432000;
}

 

service dhcpd start

chkconfig dhcpd on

3.安裝tftp-server

yum install tftp-server

修改配置文件vi /etc/xinetd.d/tftp將disable由yes改成no

disable = no

拷貝啓動引導文件

cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot

cp /usr/share/syslinux/vesamenu.c32 /var/lib/tftpboot/

cp /var/www/html/rhel6.6/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/

mkdir /var/lib/tftpboot/pxelinux.cfg

cp /var/www/html/rhel6.6/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

修改/var/lib/tftpboot/pxelinux.cfg/default的配置:

default linux-ks
#prompt 1 timeout 10

display boot.msg

menu background splash.jpg
menu title Welcome to Red Hat Enterprise Linux 6.6!
menu color border 0 #ffffffff #00000000
menu color sel 7 #ffffffff #ff000000
menu color title 0 #ffffffff #00000000
menu color tabmsg 0 #ffffffff #00000000
menu color unsel 0 #ffffffff #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color scrollbar 0 #ffffffff #00000000 label linux-ks
menu label ^Install or upgrade an existing system with kickstart
menu default
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.139.132/anaconda-ks.cfg

 

 

啓動服務

service xinetd start

chkconfig xinetd on

///////////////第三部分:批量安裝其餘服務器

1.在VMWare中創建一個空白服務器。

2.啓動空白服務器,此時空白服務器會自動找到安裝服務器。整個過程無需人工干預

 

問題解決:

1.出現The storage may contain data的警告,這時須要人工干預。想去這個警告,進行全自動安裝。

在ks.cfg中加入

# Clear the Master Boot Record
zerombr

2.出現ks.cfg沒法訪問的問題

確保ks.cfg的訪問權限沒問題

相關文章
相關標籤/搜索