准备三台电脑
192.168.200.119 http服务器 存放系统安装包和ks.cfg
192.168.200.220 dhcp服务器和tftp服务器
pxe客户端 准备安装操作系统,网卡支持pxe
步骤一: 部署HTTP服务器 (192.168.200.119)
yum install httpd -y //安装httpd软件包
systemctl start httpd.service //启动httpd服务
systemctl enable httpd.service //设置httpd服务自启动
cp /mnt/mypackage /var/www/html/mypackage //mypackage文件夹存放的是系统安装包软件,拷贝到httpd服务下
测试:
http://192.169.200.119/mypackage
systemctl stop firewalld //关闭防火墙
systemctl disable firewalld //防火墙设置不启动
setenforce 0 //临时关掉安全策略
vim /etc/sysconfig/selinux
selinux=disabled //永久关掉安全策略
步骤二:安装dhcp服务器(192.168.200.220)
yum install -y dhcp //安装dhcp软件包
rpm -qd dhcp //查看dhcp软件包安装后配置文件坐在位置
cp /usr/share/doc/dhcp-4.2.5/dhcp.conf.example /etc/dhcp/dhcpd.conf //拷贝到etc/dhcp/目录下,并命名为dhcpd.conf
vim /etc/dhcp/dhcpd.conf //编辑 /etc/dhcp/dhcpd.conf
subnet 192.168.200.0 netmask 255.255.255.0 {
range 192.168.200.100 192.168.200.200;
option routers 192.168.200.1;
default-lease-time 600;
max-lease-time 7200;
filename "pxelinux.0"
next-server 192.168.200.220
}
systemctl restart dhcpd //重启dhcpd服务
systemctl enable dhcpd //设置dhcpd服务自启动
systemctl stop firewalld //关闭防火墙
systemctl disable firewalld //防火墙自启动关闭
setenforce 0 // 临时关闭安全策略
vim /etc/sysconfig/selinux
selinux=disabled
ss -antulp | grep 67 //查看dhcp是否处于监听状态
步骤三:安装tftp服务器(192.168.200.220)
yum -y install tftp-server //安装tftp软件包
vim /etc/xinetd.d/tftp //安装完后编辑tftp配置文件
disable no //启用tftp服务,默认是yes,修改为no
systemctl restart xinetd //tftp守护进程重启
systemctl enable xinetd //tftp守护进程设置自启动
systemctl status xinetd //查看tftp守护进程状态是否是active
systemctl start tftp.socket //tftp进程启动
systemctl enable tftp.socket //tftp进程设置自启动
systemctl status tftp.socket //查看tftp进程状态是否是active
ss -antulp | grep 69 查看tftp监听状态
cp /mnt/mypackages/isolinux/initrd.img /var/lib/tftpboot/ //boot启动文件
cp /mnt/mypackages/isolinux/vmlinuz.img /var/lib/tftpboot/ //内核文件
cp /mnt/mypackages/isolinux/boot.msg /var/lib/tftpboot/ //boot菜单文件
cp /mnt/mypackages/isolinux/vesamenu.c32 /var/lib/tftpboot/ 可选
步骤四:安装syslinux文件拷贝到TFTP目录下(192.168.200.220)
yum -y install syslinux //安装syslinux
rpm -ql syslinux | grep pxelinux.0 //查看 pxelinux.0文件位置
cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ //拷贝到tftpboot目录下
mkdir /var/lib/tftpboot/pxelinux.cfg //创建文件夹pxelinux.cfg
cp /mnt/mypackages/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default //isolinux.cfg拷贝到/pxelinux.cfg目录下,并命名为default
vim /var/lib/tftpboot/pxelinux.cfg/default //编辑default文件
label linux
menu label ^Install Oracle Linux 7.0
menu default
kernel vmlinuz
append initrd=initrd.img inst.stage2=http://192.168.200.119/mypackage/ //安装系统一些菜单项到系统安装目录里去找
ks=http://192.168.200.119/pub/ //指明下载ks.cfg所在的位置
步骤五:拷贝ks.cfg(192.168.200.220)
cp /root/anaconda-ks.cfg /var/www/html/pub/ks.cfg //ks.cfg可以通过两种方法得到,一种是通过安装system-config-kickstart软件包,system-config-kickstart命令进去一步一步操作,会生成ks.cfg,拷贝到 /var/www/html/pub/下
另一种是在root目录下有anaconda-ks.cfg,拷贝到 /var/www/html/pub/ks.cfg,并重命名为ks.cfg,并修改如下:
vim 644 /var/www/html/pub/ks.cfg
vim /var/www/html/pub/ks.cfg
# Use CDROM installation media
cdrom
修改为
# Use CDROM installation media
#network install
url --url="http://192.168.200.119/mypackage" //系统安装所在的位置