PXE批量部署的优点
规模化:同时装配多台服务器 自动化:安装系统、配置各种服务 远程实现:不需要光盘、U盘等安装介质
PXE(Preboot eXcution Environment)
服务端
运行DHCP服务,用来分配地址、定位引导程序 运行TFTP服务,提供引导程序下载
客户端
基本部署过程
准备CentOS 7 安装源(YUM仓库) 安装并启用TFTP服务 提供Linux内核、PXE引导程序等 安装并启用DHCP服务 配置启动菜单
准备CentOS 7 安装源
CentOS 7 安装源支持HTTP、FTP、NFS等协议发布
[ root@localhost ~ ] # yum - y install vsftpd
[ root@localhost ~ ] # mkdir / var / ftp/ centos7
[ root@localhost ~ ] # cp - rf / media/ cdrom
安装并启用TFTP服务
安装tftp-server软件包,启用tftp服务 配置文件位于/etc/xinetd.d/tftp
[ root@localhost ~ ] # yum - y install tftp- server
[ root@localhost ~ ] # vi / etc/ xinetd. d/ tftp
server_args = - s / var / lib/ tftpboot
disable = no
[ root@localhost ~ ] # systemctl start tftp
[ root@localhost ~ ] # systemctl enable tftp
准备Linux内核、PXE引导程序
Linux内核、初始化镜像文件分别为vmlinuz和initrd.img 引导程序为pxelinux.0,由软件包syslinux提供
[ root@localhost ~ ] # cd / media/ cdrom/ images/ pxeboot
[ root@localhost pxeboot] # cp vmlinuz initrd. img / var / lib/ tftpboot
[ root@localhost ~ ] # yum - y install syslinux
[ root@localhost ~ ] # cp / usr/ share/ syslinux/ pxelinux. 0 / var / lib/ tftpboot
DHCP服务的PXE设置
[ root@localhost ~ ] # yum - y install dhcp
[ root@localhost ~ ] # vi / etc/ dhcp/ dhcp. conf
subnet 192.168 .4 .0 netmask 255.255 .255 .0 {
... ...
option routers 192.168 .4 .254 ;
option domain- name- server 192.168 .4 .254 , 202.106 .0 .20 ;
range 192.168 .4 .254 ;
filename “pxelinux. 0 ”
}
[ root@localhost ~ ] # systemctl start dhcpd
[ root@localhost ~ ] # systemctl enable dhcpd
配置启动菜单文件
[ root@localhost ~ ] # vi / var / lib/ tftpboot/ pxelinux. cfg/ default
default auto
prompt 1
label auto
kernel vmlinuz
append initrd= initrd. img method= ftp: / / 192.168 .4 .254 / centos7
label linux text
kernel vmlinuz
append text initrd= initrd. img method= ftp: / / 192.168 .4 .254 / centos7
label linux rescue
kernel vmlinuz
append rescue initrd= initrd. img method= ftp: / / 192.168 .4 .254 / centos7
验证PXE网络安装
调整BIOS设置,以便从网络引导 自动获取IP地址,并指定CentOS 7 安装源 其余过程与本地安装相同
kickstart无人值守技术
创建应答文件,预先定义好各种安装设置 免去交互设置过程,从而实现全自动化安装
应答文件的来源
编辑CentOS 7 系统中现有的应答文件 - /root/anaconda-ks.cfg 使用system-config-kickstart工具创建新的应答文件 -需要安装system-config-kickstart软件包
应答文件的内容
... ...
url-- url= “ftp: / / 192.168 .4 .254 / centos7"
... ...
% post-- interpreter= / bin/ bash
rm - f / etc/ yum. repos. d
PXE与kickstart结合使用
[ root@localhost ~ ] # cp / root/ ks. cfg / var / ftp/ ks. cfg
[ root@localhost ~ ] # vi / var / lib/ tftpboot/ pxelinux. cfg/ default
default auto
prompt 0
label auto
kernel vmlinuz
append initrd= initrd. img method= ftp: / / 192.168 .4 .254 / centos7
ks= ftp: / / 192.168 / 4 / 254 / ks/ cfg
验证自动安装
将客户机以PXE方式引导 系统会自动完成安装,并配置好软件仓库 整个安装过程无需手动干预