首先需要安装软件:

Yum install –y dhcp tftp-server  nfs-utils

Yum install –y syslinux

1、配置dhcp服务器

Dhcp服务器的配置文件在/etc/dhcp/dhcpd.conf,把他的配置文件改为:

ddns-update-style interim;
ignore client-updates;
next-server 192.168.10.142;
filename "pxelinux.0";
allow booting;
allow bootp;
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.1;
option subnet-mask 255.255.0.0;
range dynamic-bootp 192.168.10.50 192.168.10.100;
host ns {
hardware ethernet 00:1a:a0:2b:38:81;
fixed-address 192.168.10.88;}
}


配置说明:

subnet 为网络地址,netmask为掩码,表示在哪一段网络中分配IP地址,必须跟主机在同一个网络内。

Option routers为分配IP后,客户端的网关地址,option subnet-mask 为客户端的掩码。

Rangedynamic-bootp 为分配的IP地址范围。

Next-server tftp服务器的地址,filename PXE安装时需要的文件

 Host ns 为某一个MAC地址,配置固定的IP地址,绑定

配置好了之后,重启 /etc/init.d/dhcpd restart

2、配置tftp服务器:

Vi /etc/xinetd.d/tftp disable = yes 改为no 就可以了

3TFTP+PXE配置

要实现远程安装系统,需要在tftpboot目录指定相关PXE内核模块及相关参数。配置步骤如下:

Mount /dev/cdrom  /mnt     #挂载光盘

ln –s  /var/lib/tftpboot/  /     #做个软连接

cd /tftpboot                 #进入/tftpboot目录

cp  /usr/share/syslinux/pxelinux.0  .    #pxelinux.0拷贝到/tftpboot目录

cp /mnt/p_w_picpaths/pxeboot/{vmlinux,initrd.img}  .  #把内核拷贝到tftpboot目录

mkdir  -p pxelinux.cfg   #/tftpboot目录下创建pxelinux.cfg目录

vi   pxelinux.cfg/default 把内容改成如下:

default  centos6.5
timeout 600
display boot.msg
menu background splash.jpg
menu title Welcome to CentOS 6.5!
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 centos6.5
kernel vmlinuz
append ks=nfs:192.168.10.142:/data/centos/ks.cfg ksdevice=eth0  initrd=initrd.img
label  local


给default  777 权限  chmod  777 default

配置说明:192.168.10.142是kickstart服务器,/data/centos是nfs共享linux镜像的目录,也是linux安装文件的路径,ks.cfg是kickstart主配置文件,应答文件,ksdevice=eth0表示有多块网卡时,客户端从eth0安装

4、NFS+KICKSTART配置

Mkdir   -p /data/centos

Cp  -a /mnt/*  /data/centos  #把光盘里的所有文件拷贝到/data/centos目录下

Vi  /etc/exports  加入一行 /data/centos  *(rw,sync)   表示把/data/centos共享出来给所有人访问,可读写

配置kickstart文件,vi  /data/centos/ks.cfg  改成以下内容:

install
text
nfs --server=192.168.10.142 --dir=/data/centos
lang en_US.UTF-8
keyboard us
network --onboot no --device eth0 --bootproto dhcp --noipv6
rootpw  123456
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --disabled
timezone Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgbquiet"
clearpart --all --initlabel
zerombr yes 
part /boot--fstype=ext4 --size=200
part /--fstype=ext4 --size=8000
part /data--fstype=ext4  --grow --size=1000
part swap--size=1024
%packages  --nobase
%end
reboot
给ks.cfg 777权限 chmod  777  ks.cfg
5、重启所有服务
/etc/init.d/dhcpd  restart
/etc/init.d/xinetd  restart
/etc/init.d/rpcbind  restart
/etc/init.d/nfs  restart


 

客户端测试