本章结构:
部署PXE远程安装服务:
搭建PXE远程安装服务器
验证PXE网络安装
实现Kickstart无人值守安装:
准备安装应答文件
实现批量自动装机
一、PXE(Preboot excution environment):
预启动执行环境,在操作系统之前执行
服务端:
运行DHCP服务,用来分配地址
运行TFTP服务,提供引导程序下载
客户端:
网卡支持PXE协议
主板支持网络引导
实验代码:
一、配置DHCP服务:
1、[root@localhost ~]# yum -y install dhcp
[root@localhost ~]# cat /etc/dhcp/dhcpd.conf #########see /usr/share/doc/dhcp*/dhcpd.conf.example
[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf ####yes
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.100.0 netmask 255.255.255.0 {
range 192.168.100.128 192.168.100.200;
option routers 192.168.100.100;
option domain-name-servers 8.8.8.8;
next-server 192.168.100.100;
filename "pxelinux.0";
}
二、配置tftp服务:
2、[root@localhost ~]# yum -y install tftp-server
[root@localhost ~]# yum -y install syslinux
[root@localhost ~]# vim /etc/xinetd.d/tftp #######修改“disable =no”开启tftp服务
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ #######cd /var/lib/tftpboot/ ls 有个pxelinux.0文件
[root@localhost ~]# yum -y install vsftpd #######安装ftp服务
[root@localhost ~]#cd /var/ftp ls >pub
[root@localhost ftp]#mkdir centos7
[root@localhost ftp]# mount /dev/cdrom /var/ftp/centos7 ls centos7/ 有文件了
[root@localhost ftp]# cd centos7/images/pxeboot/ ls initrd.img vmlinuz
[root@localhost pxeboot]# cp vmlinuz initrd.img /var/lib/tftpboot/ ######此时里面有3个文件:initrd.img pxelinux.0 vmlinuz
[root@localhost tftpboot]#mkdir pxelinux.cfg
[root@localhost tftpboot]#cd pxelinux.cfg/
vim default
default auto
prompt 1
label auto
kernel vmlinuz
append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg
label linux text
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.100.100/centos7
label linux rescue
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7
[root@localhost pxelinux.cfg]#iptables -F
[root@localhost pxelinux.cfg]#setenforce 0
[root@localhost pxelinux.cfg]#systemctl start dhcpd
[root@localhost pxelinux.cfg]#systemctl start tftp
[root@localhost pxelinux.cfg]#systemctl start vsftpd
[root@localhost pxelinux.cfg]#netstat -nuap
kickstart无人值守:
[root@localhost pxelinux.cfg]#yum install system-config-kickstart
在图形化界面设置,系统相关配置:#############
[root@localhost ~]#ls ######会有一个ks.cfg文件
[root@localhost ~]#cd ks.cfg/
[root@localhost ~]#vim anaconda-ks.cfg ######里面的%package-%end复制到ks.cfg
[root@localhost ~]#vim /var/lib/tftpboot/pxelinux.cfg/default #####在第一个label加上 ks=ftp://192.168.100.100/ks.cfg
[root@localhost ~]#mv ks.cfg /var/ftp
[root@localhost ~]#cd /var/ftp ls>centos7 ks.cfg pub