相关概念

1. 什么是PXE

   严格来说,PXE 并不是一种安装方式,而是一种引导方式。进行 PXE 安装的必要条件是在要安装的计算机中必须包含一个 PXE 支持的网卡(NIC),即网卡中必须要有 PXE Client。PXE (Pre-boot Execution Environment)协议可以使计算机通过网络启动。此协议分为 Client端和 Server 端,而PXE Client则在网卡的 ROM 中。当计算机引导时,BIOS 把 PXE Client 调入内存中执行,然后由 PXE Client 将放置在远端的文件通过网络下载到本地运行。运行 PXE 协议需要设置 DHCP 服务器和 TFTP 服务器。DHCP 服务器会给 PXE Client(将要安装系统的主机)分配一个 IP 地址,由于是给 PXE Client 分配 IP 地址,所以在配置 DHCP 服务器时需要增加相应的 PXE 设置。此外,在 PXE Client 的 ROM 中,已经存在了 TFTP Client,那么它就可以通过 TFTP 协议到 TFTP Server 上下载所需的文件了。

2. 什么是Kickstart

   Kickstart是一种无人值守的安装方式。它的工作原理是在安装过程中记录典型的需要人工干预填写的各种参数,并生成一个名为 ks.cfg的文件。如果在安装过程中(不只局限于生成Kickstart安装文件的机器)出现要填写参数的情况,安装程序首先会去查找 Kickstart生成的文件,如果找到合适的参数,就采用所找到的参数;如果没有找到合适的参数,便需要安装者手工干预了。所以,如果Kickstart文件涵盖了安装过程中可能出现的所有需要填写的参数,那么安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后就去忙自己的事情。等安装完毕,安装程序会根据ks.cfg中的设置重启系统,并结束安装。

3. PXE + Kickstart的安装先决条件

DHCP 服务器。
TFTP 服务器。
Kickstart所生成的ks.cfg配置文件。
一台存放系统安装文件的服务器,如 NFS、HTTP 或 FTP 服务器。
一个带有 PXE 支持网卡的主机。

实现步骤

#############################挂载光盘################################
yum install -y httpd    安装apache
mount /dev/cdro /mnt/cdrom    挂载安装光盘
cp -rf /mnt/cdrom/* /mnt/cdrom    复制光盘内容到web目录
#############################安装tftp################################
yum install -y tftp-server    安装tftp-server
cat /etc/xinetd.d/tftp    修改配置文件内容为
service tftp
{
  socket_type    = dgram
  protocol    = udp
  wait      = yes
  user      = root
  server      = /usr/sbin/in.tftpd
  server_args    = -s /tftpboot
  disable      = no
  per_source    = 11
  cps      = 100 2
  flags      = IPv4
}
service xinetd restart    重启xinetd进程
########################配置支持PXE的启动程序#######################
mkdir -p /tftpboot
cp /usr/lib/syslinux/pxelinux.0 /tftpboot
cp /var/www/html/p_w_picpaths/pxeboot/vmlinuz /tftpboot
cp /var/www/html/p_w_picpaths/pxeboot/initrd.img /tftpboot/
cp /var/www/html/isolinux/*.msg /tftpboot/
mkdir /tftpboot/pxelinux.cfg -pv
cp /var/www/html/isolinux/isolinux.cfg  /tftpboot/pxelinux.cfg/default
########################安装配置dhcp服务#############################
yum –y install dhcp
cat /etc/dhcpd.conf    主配置文件
ddns-update-style interim;
ignore client-updates;
next-server 192.168.1.110;
filename "/pxelinux.0";
subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers                  192.168.1.10;
        option subnet-mask              255.255.255.0;
        option nis-domain               "domain.org";
        option domain-name              "domain.org";
        option domain-name-servers      192.168.1.10;
        option time-offset              -18000; # Eastern Standard Time
        range dynamic-bootp 192.168.1.100 192.168.1.200;
        default-lease-time 21600;
        max-lease-time 43200;
}
service dhcpd start
########################安装Kickstart并配置##########################
yum –y install system-config-kickstart
system-config-Kickstart    配置
最后将生成的文件ks.cfg保存到/var/www/html下
###############修改/tftpboot/pxelinux.cfg/default文件################
修改前两行内容为
default text ks=http://192.168.11.29/ks.cfg
timeout 2
#################修改/var/www/html/ks.cfg文件内容####################
#platform=x86, AMD64, or Intel EM64T
#System authorization information
auth    --useshadow    --enablemd5
# System bootloader configuration
key --skip
bootloader --location=mbr
# Partition clearing information
clearpart --none
# Use graphical install
graphical
# Firewall configuration
firewall --disabled
# Run the Setup Agent on first boot
firstboot --disable
#System keyboard
keyboard us
#System language
lang en_US
# Installation logging level
logging --level=info
# Use network installation
url --url=http://192.168.1.110/
# Network information
network --bootproto=dhcp --device=eth0 --onboot=on
reboot
#Root password
rootpw --iscrypted $1$aseasd$W0TpOJ8tqCoFgcbKk4wie0
# SELinux configuration
selinux --disabled
# System timezone
timezone --isUtc Asia/Shanghai
# Install OS instead of upgrade
install
# X Window System configuration information
xconfig    --defaultdesktop=GNOME --depth=8 --resolution=640x480
# Disk partitioning information
bootloader --location=mbr --driveorder=sda
clearpart --all --initlabel
part / --bytes-per-inode=4096 --fstype="ext3" --size=5120
part /boot --bytes-per-inode=4096 --fstype="ext3" --size=128
part swap --bytes-per-inode=4096 --fstype="swap" --size=500
part /data --bytes-per-inode=4096 --fstype="ext3" --grow --size=1
%packages
@base
@development-libs
@development-tools
#######################添加开机启动并且启动各服务####################
service httpd start
chkconfig httpd on
service dhcpd start
chkconfig dhcpd on
service xinetd restart

启动客户端测试

   至此表明各服务正常工作

PXE+DHCP+Apache+KickStart无人值守安装RHEL5.8_无人值守

   至此表明ks.cfg文件生效

PXE+DHCP+Apache+KickStart无人值守安装RHEL5.8_无人值守_02