关闭系统防火墙:
# service iptables stop
# vi /etc/selinux/config 修改
SELINUX=disabled
# yum -y install dhcp
修改vi /etc/dhcp/dhcpd.conf 配置文件,内容如下:
ddns-update-style interim;
ignore client-updates;
allow booting;
allow bootp;
filename "pxelinux.0";#pxe boot需要的启动文件名, 相当于bootloader
next-server 192.168.100.149; #tftp server的ip
subnet 192.168.100.0 netmask 255.255.255.0{
default-lease-time 216000;
max-lease-time 432000;
option time-offset -18000;
range 192.168.100.150 192.168.100.160;#地址池范围
option subnet-mask 255.255.255.0;
option routers 192.168.100.149;
}
启动DHCP服务
# /etc/init.d/dhcpd start
2.1 安装tftp-server
# yum install tftp-server xinetd –y
2.2 启用tftp 服务
# vi /etc/xinetd.d/tftp
将disable 设置为no
# /etc/init.d/xinetd restart
# /etc/init.d/tftpd restart
3.1 安装并配置HTTP
# yum install httpd –y
开启服务
# /etc/init.d/httpd start
将iso文件挂载至/var/www/html/centos
# mount /dev/cdrom/ /var/www/html/centos
4. 配置支持PXE的启动程序
安装syslinux
yum install –y syslinux
4.1 复制pxelinux.0 文件至/var/lib/tftpboot/ 文件夹中
# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
4.2 复制iso 镜像中的/image/pxeboot/initrd.img 和vmlinux 至/var/lib/tftpboot/ 文件夹中
# cp /var/www/html/centos/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/
4.3复制iso 镜像中的/isolinux/boot.msg,vesamenu.c32 splash.png 至/var/lib/tftpboot/ 文件夹中
cp /var/www/html/centos/isolinux/{boot.msg,vesamenu.c32,splash.jpg} /var/lib/tftpboot/
4.4 在/var/lib/tftpboot/ 中新建一个pxelinux.cfg目录
# mkdir /var/lib/tftpboot/pxelinux.cfg
4.5 将iso 镜像中的/isolinux 目录中的isolinux.cfg复制到pxelinux.cfg目录中,同时更改文件名称为default
# cp /var/www/html/centos/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
4.6 修改default文件
# vi /var/lib/tftpboot/pxelinux.cfg/default
label linux
menu label ^Install by pxe
menu default
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.100.149/ks.cfg
5.1 生成并修改ks.cfg 文件
#vi /var/www/html/ks.cfg
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.100.149/centos"
# Root password huawei123
rootpw --iscrypted $6$.2zqp7Meu4kPupW2$xsC6bRSp6AIeIjbem5MXaI4pN4Z27AgAVPrWxTaL
drEJ8n.lXVsSRlMsmeqyiKXgrm.whw28gFwDMkMpU4q1W.
# System authorization information
auth --useshadow --passalgo=sha512
# Use text mode install
text
firstboot --disable
# System keyboard
keyboard us
# System language
lang zh_CN.UTF-8
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# System timezone
timezone --utc Asia/Shanghai
# Network information
network --bootproto=dhcp --device=eth0 --onboot=yes
# Clear the Master Boot Record
zerombr
# System bootloader configuration
bootloader --append=" crashkernel=auto"--location=mbr --driveorder=sda
# Disk partitioning information
autopart
# Partition clearing information
clearpart --all --initlabel
# Reboot after installation
reboot
repo --name="CentOS" --baseurl=http://192.168.100.149/centos --cost=100
%packages --nobase
@core
%end
6. 确认三个服务是否正常运行:
service httpd status
service dhcpd status
service xinetd statu