1、PXE:允许客户机通过网络从远程服务器下载引导镜像,并加载安装文件或者整个操作系统
PXE的有点:规模化,自动化,远程实现
2、PXE的安装和实现:
1)、安装并启用TFTP服务:
TFTP是一个基于UDP协议实现的,用于在客户机和服务器之间进行简单文件传输的协议,适合于小文件传输应用。 TFTP服务默认由xinetd服务进行管理,使用UDP端口:69
[root@localhost ~]# yum -y install xinetd.x86_64
[root@localhost ~]# yum install -y tftp-server.x86_64
安装完成后查看文件是否生成:
[root@localhost ~]# cd /etc/
[root@localhost etc]# cd xinetd.d/
[root@localhost xinetd.d]# ls
chargen-dgram daytime-dgram discard-dgram echo-dgram tcpmux-server time-dgram
chargen-stream daytime-stream discard-stream echo-stream tftp time-stream
[root@localhost xinetd.d]# vim tftp
service tftp
{
socket_type = dgram
protocol = udp
wait = yes #同时安装多,改成no
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/lib/tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
启用服务:
[root@localhost xinetd.d]# systemctl start tftp
[root@localhost xinetd.d]# systemctl start xinetd.service
开机自启动:
[root@localhost xinetd.d]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/systemd/system/tftp.socket.
[root@localhost xinetd.d]# systemctl enable xinetd.service
2)、安装DHCP
[root@localhost yum.repos.d]# yum -y install dhcp.x86_64
3)、修改DHCP服务的配置文件:
[root@localhost dhcp-4.2.5]# cp -p dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp: overwrite ‘/etc/dhcp/dhcpd.conf’? yes
[root@localhost dhcp]# vim dhcpd.conf
default-lease-time 600;
max-lease-time 7200;
ddns-update-style none;
next-server 192.168.233.129;
filename “pxelinux.0”
subnet 192.168.233.0 netmask 255.255.255.0 {
range dynamic-bootp 192.168.233.100 192.168.233.200;
option broadcast-address 192.168.233.129;
}
设置开机自启动:
[root@localhost dhcp]# systemctl start dhcpd
Job for dhcpd.service failed because the control process exited with error code. See “systemctl status dhcpd.service” and “journalctl -xe” for details.
[root@localhost dhcp]# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/systemd/system/dhcpd.service.
4)、准备linux文件内核、初始化镜像文件:
root@localhost dhcp]# cd /mnt/
[root@localhost mnt]# cd images/
[root@localhost images]# cd pxeboot/
[root@localhost pxeboot]# ls
initrd.img TRANS.TBL vmlinuz
[root@localhost pxeboot]# cp -p vmlinuz /var/lib/tftpboot/ #复制linux内核文件到TFTP的目录下
[root@localhost pxeboot]# cp initrd.img /var/lib/tftpboot/ #复制初始化镜像文件到TFTP根目录下
5)、准备PXE引导程序:
[root@localhost /]# yum install -y syslinux #PXE的引导程序包由syslinux提供
[root@localhost syslinux]# cp pxelinux.0 /var/lib/tftpboot/ # 复制PXE引导程序到TFTP的根目录下
6)、安装FTP服务,准备centos 7的安装源:
[root@localhost yum.repos.d]# yum install -y vsftpd
[root@localhost yum.repos.d]# cp -rf /mnt/* /var/ftp/centos7/
启动FTP服务:
[root@localhost yum.repos.d]# systemctl start vsftpd
[root@localhost yum.repos.d]# systemctl enable vsftpd
7)、配置启动菜单文件:
[root@localhost pxelinux.cfg]# vim default
default auto #指定默认入口名称
prompt 1 #设置是否等待用户选择,1表示等待用户控制
label auto #图像安装引导入口
kernel vmlinuz #定义引导参数
append initrd=initrd.img method=ftp://192.168.233.129/centos7
label linux text #文本安装的引导入口
kernel vmlinuz
append text initrd=initrd.img method=ftp://192.168.233.129/centos7
label linux rescue #救援模式的引导入口
kernel vmlinuz
append rescue initrd=initrd.img method=ftp://192.168.233.129/centos7
关闭防火墙,验证PXE网络安装