部署PXE服务器步骤
1,配置DHCP服务器
yum -y install dhcp
vim /etc/dhcp/dhcpd.conf
subnet 192.168.31.0 netmask 255.255.255.0 {
range 192.168.31.100 192.168.31.200;
# option domain-name-servers
202.106.0.20;
option routers 192.168.31.0;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.31.7;
filename "pxelinux.0";
}
/etc/init.d/dhcpd restart
2,创建kiskstart文件
kickstart文件可以手动书写,或者通过system-config-kickstart工具或者anaconda安装程序自动生成
yum install -y system-config-kickstart
启动后按照自定义生成文件。
文件详解:
# Kickstart file automatically generated by anaconda.
#version=DEVEL
text
url --url ftp://192.168.31.7/pub/centos6.6
//也可以使用nfs服务器。
key --skip
lang en_US.UTF-8
keyboard us
network --onboot no --device eth0 --bootproto dhcp
--noipv6
rootpw --iscrypted
$6$S.ZDQOD5o3sI.ksH$BjkF3GFMylCuQiGDpXmM7gEHwKa3hondsUvIIViX3AJct8t5gIBvX3DIgvJe0UO4N8BgVsHBfRffBR6w2eGS//
firewall --disabled
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="rhgb
quiet"
zerombr
# 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
part /boot --fstype=ext4 --size=200
part swap --fstype=swap --size=1024
part / --fstype=ext4 --grow --size=1
%packages
@base
@console-internet
@core
pax
oddjob
sgpio
device-mapper-persistent-data
samba-winbind
certmonger
pam_krb5
krb5-workstation
xferstats
perl-DBD-SQLite
%end
安装后执行的脚本。
cp ks.cfg /var/ftp/pub/
3,安装syslinux软件包
yum -y install syslinux
4,配置FTP服务器
4.1 安装ftp服务器
yum install -y vsftpd
4.2 准备CentOS6.6安装文件
mount /dev/cdrom /mnt
mkdir /var/ftp/pub/centos6.6
cp -R /mnt/* /var/ftp/pub/centos6/
chmod -R 755 /var/ftp/pub/*
5,TFTP服务器配置
5.1 安装TFTP服务器
yum -y install tftp
vi /etc/xinetd.d/tftp //修改为以下内容
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
//启动
per_source = 11
cps = 100 2
flags =
IPv4
}
5.2 配置pxe所需的文件
mkdir /var/lib/tftpboot/centos6.6
mkdir /var/lib/tftpboot/pxelinux.cfg
cp /mnt/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/centos6.6/
chmod -R 755 /var/lib/tftpboot/centos6.6
vim /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
menu title ########## PXE Boot Menu
##########
label ks basic
menu label ^Kickstart Inatall system
menu default
kernel centos6.6/vmlinuz
append ks=ftp://192.168.31.7/pub/ks.cfg
initrd=centos6.6/initrd.img ramdisk_size=8192
label linux
menu label ^Inatall system
kernel centos6.6/vmlinuz
append initrd=centos6.6/initrd.img ip=dhcp
inst.repo=ftp://192.168.31.7/pub/centos6.6
label vesa
menu label Install system with ^basic video
driver
kernel centos6.6/vmlinuz
append initrd=centos6.6/initrd.img ip=dhcp
inst.xdriver=vesa nomodeset
inst.repo=ftp://192.168.31.7/pub/centos6.6
label rescue
menu label ^Rescue installed system
kernel centos6.6/vmlinuz
append initrd=centos6.6/initrd.img
rescue
label local
menu label Boot from ^local drive
localboot 0xffff
5.3 创建tftp所需要的文件
6,设置相关启动项
chkconfig vsftpd on
chkconfig xinted on
chkconfig dhcpd on
service iptables stop