PXE

PXE网络装机

PXE介绍

PXE(preboot execute environment,预启动执行环境)

是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持通过网络启动操作系统,在启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transfer protocol)或MTFTP(multicast trivial file transfer protocol)协议下载一个启动软件包到本机内存中执行,由这个启动软件包完成终端(客户端)基本软件设置,从而引导预先安装在服务器中的终端操作系统。
PXE可以引导多种操作系统,如:windows2008/win7/win8/linux系列系统等。PXE网络安装的引导程序为pxelinux.0,由软件包syslinux提供。

kickstart(ks)-无人值守安装的一种方式

定义了Linux安装过程的配置文件,比如要在系统中使用的时区,如何对驱动器进行分区,或者应该安装那些软件包。有了这个文件可以解放双手,让Linux安装过程按照我们预先定义的要求进行自动安装,同时部署大量主机。一般centos系统安装后,会在root目录下生成一个名为anaconda-ks.cfg的kickstart配置文件。

工作原理

在这里插入图片描述


PXE工作原理说明:

  1. Client向PXE Server上的DHCP发送IP地址请求消息,DHCP检测Client是否
    合法(主要是检测Client的网卡MAC地址),如果合法则返回Client的IP地
    址,同时将启动文件pxelinux.0的位置信息一并传送给Client

  2. Client向PXE Server上的TFTP发送获取pxelinux.0请求消息,TFTP接收到
    消息之后再向Client发送pxelinux.0大小信息,试探Client是否满意,当
    TFTP收到Client发回的同意大小信息之后,正式向Client发送pxelinux.0。

  3. Client执行接收到的pxelinux.0文件。

  4. Client向TFTP发送针对本机的配置信息(记录在TFTP的pxelinux.cfg目录
    下),TFTP将配置文件发回Client,继而Client根据配置文件执行后续操
    作。

  5. Client向TFTP发送Linux内核请求信息,TFTP接收到消息之后将内核文件发
    送给Client。

  6. Client向TFTP发送根文件请求信息,TFTP接收到消息之后返回Linux根文件
    系统。

  7. Client启动Linux内核(启动参数已经在4中的配置文件中设置好了)。

  8. Client通过NFS下载镜像文件,读取autoyast自动化安装脚本。
    至此,Client正式进入自动化安装模式开始安装系统直到完成。

PXE client是需要安装Linux的计算机,TFTP Server和DHCP Server运行在另外一台Linux Server上。Bootstrap文件、配置文件、Linux内核以及Linux根文件系统都放置在Linux Server上TFTP服务器的根目录下。
PXE client在工作过程中,需要三个二进制文件:bootstrap、Linux 内核和Linux根文件系统。Bootstrap文件是可执行程序,它向用户提供简单的控制界面,并根据用户的选择,下载合适的Linux内核以及Linux根文件系统。

配置

这里将这几种服务装到同一台PC中
安装并配置DHCP服务

[root@localhost ~]# yum -y install dhcp

在主配置文件中修改

[root@localhost ~]# vim /etc/dhcp/dhcpd.conf 
#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page
#
subnet 192.168.1.0 netmask 255.255.255.0 {      #声明一个网段
        range 192.168.1.50 192.168.1.70;        #地址池     分配ip从1.50-1.70
        next-server 192.168.1.1;                #tftp服务器的ip   这里填写本机ip   因为服务都在同一台上
        filename "pxelinux.0";                   #第一个引导文件的名称
}
~       
# 保存退出后重启服务
[root@localhost ~]# systemctl restart dhcpd

安装tftp服务

[root@localhost ~]# yum -y install tftp-server xinetd
[root@localhost ~]# vim /etc/xinetd.d/tftp
# 将该项修改为no
        disable                 = no

安装含有引导文件程序

[root@localhost ~]# yum -y install syslinux

复制所需要的引导文件

[root@localhost ~]#  cd /var/lib/tftpboot/
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 ./
[root@localhost tftpboot]# cp  /media/dvd/images/pxeboot/vmlinuz  ./
[root@localhost tftpboot]# cp /media/dvd/images/pxeboot/initrd.img ./
[root@localhost tftpboot]# cp /media/dvd/isolinux/vesamenu.c32 ./  
[root@localhost tftpboot]# cp /media/dvd/isolinux/splash.png ./
[root@localhost tftpboot]# cp /media/dvd/isolinux/boot* ./
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# cp /media/dvd/isolinux/isolinux.cfg pxelinux.cfg/default

修改配置文件,找到并修改以下内容

[root@localhost tftpboot]# vim pxelinux.cfg/default   # 为了让安装系统选择默认配置,自己起的目录文件名
# 第一行
default linux
timeout 600
......
# 60行左右
menu separator # insert an empty line

label linux
  menu label ^Install CentOS Linux 7
  kernel vmlinuz
  append initrd=initrd.img inst.stage2=ftp://192.168.1.1/centos ks= ftp://192.168.1.1/centos/ks.cfg quiet

label check

重启服务

[root@localhost tftpboot]# systemctl restart xinetd
[root@localhost tftpboot]# systemctl restart tftp

安装ftp服务

[root@localhost ~]# yum -y install vsftpd
[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# mkdir centos
[root@localhost ftp]# cd centos/
[root@localhost centos]# cp -r /media/dvd/* ./
[root@localhost centos]# cp /root/anaconda-ks.cfg ./ks.cfg
[root@localhost centos]#  chmod +r ks.cfg
[root@localhost ftp]# vim ks.cfg
# 在配置文件最后添加
reboot
eula --agreed
~                   

找到并加入下面内容(url)
在这里插入图片描述

[root@localhost ftp]# systemctl restart vsftpd
[root@localhost ftp]# systemctl stop firewalld
[root@localhost ftp]# setenforce 0

重启服务后,开一台没有镜像的PC(与服务器在同一网段),便可以执行无人安装操作了

出现该内容说明成功了

在这里插入图片描述

以上是使用命令行配置配置信息
下面使用图形化界面来配置,ks.cfg是通过图形化界面生成的
使用system-config-kickstart来配置ks.cfg文件

[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost ~]# ls 
yum.repo
[root@localhost ~]# vim development.repo
[development] 
name=base
baseurl=file:///mnt/
enabled=1
gpgcheck=0
[root@localhost centos]# yum -y install system-config-kickstart
[root@localhost centos]# system-config-kickstart

基础配置:
在这里插入图片描述
安装方法:
在这里插入图片描述
引导程序需要pxe的引导文件:
在这里插入图片描述
重新制定分区
也可以保留现在的分区
在这里插入图片描述
添加分区在这里插入图片描述
添加/boot
在这里插入图片描述
添加/
在这里插入图片描述
防火墙
在这里插入图片描述
安装的图形界面
在这里插入图片描述
保存
在这里插入图片描述
可以出现路径 选择文件系统 —找到 var --找到ftp—找到centos–保存的名字 ks.cfg
在这里插入图片描述

[root@localhost centos]# cd /var/ftp/centos/
[root@localhost centos]# ls
CentOS_BuildTag     EULA     images    ks.cfg     lost+found    repodata              RPM-GPG-KEY-CentOS-Testing-7   EFI     GPL        isolinux  LiveOS  Packages    RPM-GPG-KEY-CentOS-7        TRANS.TBL
[root@localhost centos]# vim ks.cfg 
%packages
@gnome-desktop
@x11     图形化界面的模块
initial-setup   添加的内容
initial-setup-gui    这两行是初始化操作系统

%end
user --name=test --password=123.com    #创建普通用户
eula --agreed   #同意协议
重启服务   
之后的操作就一致了

详解
详解

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值