PXE高效批量网络装机

PXE概述

预启动执行环境,在操作系统之前运行

优点

规模化:同时装配多台服务器
自动化:安装系统,配置各种服务
远程实现:不需要光盘,U盘等安装介质

服务端

运行DHCP服务,用来分配地址、定位引导程序
运行TFTP服务,提供引导程序下载

客户端

网卡支持PXE协议
主板支持网络引导

工作过程

1.客户机从自己的PXE网卡启动,向本网络中的DHCP服务器索取IP
2.DHCP服务器返回分给客户机IP以及bootstrap文件的放置位置(该文件一般是放在一台TFTP服务器上)
3.客户机向本网络中的TFTP服务器索取bootstrap文件
4.客户机取得bootstrap文件后之执行该文件
5.根据bootstrap的执行结果,通过TFTP服务器加载内核和文件系统
6.进入安装画面, 此时可以通过选择FTP,HTTP,NFS方式之一进行安装

实操

首先开启dhcp服务,指向tftp服务器


[root@localhost ~]# yum -y install dhcp  #安装dhcp
已安装:
  dhcp.x86_64 12:4.2.5-82.el7.centos                                                           

作为依赖被安装:
  bind-export-libs.x86_64 32:9.11.4-26.P2.el7_9.5                                              

作为依赖被升级:
  dhclient.x86_64 12:4.2.5-82.el7.centos        dhcp-common.x86_64 12:4.2.5-82.el7.centos      
  dhcp-libs.x86_64 12:4.2.5-82.el7.centos      

完毕!
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
subnet 192.168.88.0 netmask 255.255.255.0 {
  range 192.168.88.10 192.168.88.20;
  option routers 192.168.88.137;
  next-server 192.168.88.137;
  filename "pxelinux.0";
}

[root@localhost ~]# systemctl restart dhcpd

安装启用tftp服务(需要四个文件:defaule,vmlinuz,initrd.img,pxelinux.0)

[root@localhost ~]# yum -y install tftp-server.x86_64
已安装:
  tftp-server.x86_64 0:5.2-22.el7                                                              

完毕!
[root@localhost ~]# yum provides */pxelinux.0
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: mirrors.ustc.edu.cn
 * extras: mirrors.nju.edu.cn
 * updates: mirrors.ustc.edu.cn
base/7/x86_64/filelists_db                                              | 7.2 MB  00:00:00     
extras/7/x86_64/filelists_db                                            | 231 kB  00:00:00     
updates/7/x86_64/filelists_db                                           | 4.7 MB  00:00:00     
syslinux-4.05-15.el7.x86_64 : Simple kernel loader which boots from a FAT filesystem
源    :base
匹配来源:
文件名    :/usr/share/syslinux/pxelinux.0

安装ftpd在vsftpd软件包镜像中中找到vmlinuz,initrd.img两个文件

[root@localhost ~]# yum -y install vsftpd
[root@localhost ~]# mount /dev/sr0 /var/ftp/centos7
[root@localhost ~]# cd /var/ftp/centos7/images/pxeboot/
[root@localhost ~]# cp vmlinuz initrd.img /var/lib/tftpboot/
[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost ~]# cd pxelinux.cfg/
[root@localhost ~]# vim default
default auto
prompt 1
label auto
  kernel vmlinuz
  append initrd=initrd.img method=ftp://192.168.195.100/centos7

label linux text
  kernel vmlinuz
  append text initrd=initrd.img method=ftp://192.168.195.100/centos7

label linux rescue
  kernel vmlinuz
  append rescue initrd=initrd.img method=ftp://192.168.195.100/centos7
  
[root@localhost ~]# cd /var/lib/tftpboot/   ##查看tftp站点中的四个必要文件
[root@localhost tftpboot]# ls         
initrd.img  pxelinux.0  pxelinux.cfg  vmlinuz  
 ## pxelinux.0 是syslinux中的,initrd.img和vmlinuz是ftp中的, pxelinux.cfg是手动写进去的
[root@localhost ~]# iptable -F     ##关闭防火墙
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl start tftp
[root@localhost ~]# systemctl enable dtftp
[root@localhost ~]# systemctl start ftpd
[root@localhost ~]# systemctl enable ftpd

Kickstart 无人值守安装

在这里插入图片描述

去客户端配置
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值