Linux:PXE高效批量网络装机

目录

1、批量部署的优点

2、服务端

3、客户端

4、基本部署过程,装机流程

5、PXE装机的需要四大文件

6、无人值守

7、实操


1、批量部署的优点

规摸化: 同时装配多台服务器

自动化:安装系统画置多种各种服务

远程实现,不需要光盘,U盘等安装介质

PXE

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

2、服务端

运行DHCP服务,用来外配地址 定位引导程序

运行TFTP服务,提供引导程序下载

tftp:类似于vsftp小文本传输协议提供镜像文件下载

3、客户端

网卡支持PXE协议

主板支持网络引导

4、基本部署过程,装机流程

①客户机的网卡查找dhcp服务 获取IP他让和时间

②dhcp服络器给客户机分配ip地址和引导程序的地址同时通过offer报文把ftp服务器的地址发给客户机

③tftp服络器把引导文件(pxelinux.0)传给客户机

④客户机把引导程序加载到内存中

⑤引导程序在ftp服务器中查找配置文件,服务器把配配置文件传给客户机(配置文件用ftp获取)

⑥服务器端通过vsftp服务和客户端互传文件,客户端获得系统的镜像文件

5、PXE装机的需要四大文件

pxelinux.0引导程序(syslinux程序)

default引导程序的配置文件(需要手写,在光盘ioslinux目录下的isolinux.cfg范本)

vmlimuz:内核文件(从光盘来的,isolinux目录下)

initrd.img:系统启动镜像文件(光盘,isolinux)

xinetd;:网络守护进程服条程序,管理转轻量级的网络服务,配合tftp使用

tftp基于udp协议,简单文件传输传一些小文件,端口69

vsftpd

Syslinux:引导加裁程序,简化首次安装linuxd的时间,建立维护或其他特殊用户的启动盘

6、无人值守

7、实操

[root@CentOS7-5 ~]# yum -y install tftp-server xinetd
已加载插件:fastestmirror, langpacks
httpd                                                               | 3.6 kB  00:00:00
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 tftp-server.x86_64.0.5.2-13.el7 将被 安装
---> 软件包 xinetd.x86_64.2.2.3.15-13.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================
 Package               架构             版本                         源               大小
===========================================================================================
正在安装:
 tftp-server           x86_64           5.2-13.el7                   httpd            44 k
 xinetd                x86_64           2:2.3.15-13.el7              httpd           128 k

事务概要
===========================================================================================
安装  2 软件包

总下载量:173 k
安装大小:325 k
Downloading packages:
(1/2): tftp-server-5.2-13.el7.x86_64.rpm                            |  44 kB  00:00:00
(2/2): xinetd-2.3.15-13.el7.x86_64.rpm                              | 128 kB  00:00:00
-------------------------------------------------------------------------------------------
总计                                                       274 kB/s | 173 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 2:xinetd-2.3.15-13.el7.x86_64                                          1/2
  正在安装    : tftp-server-5.2-13.el7.x86_64                                          2/2
  验证中      : tftp-server-5.2-13.el7.x86_64                                          1/2
  验证中      : 2:xinetd-2.3.15-13.el7.x86_64                                          2/2

已安装:
  tftp-server.x86_64 0:5.2-13.el7               xinetd.x86_64 2:2.3.15-13.el7

完毕!
[root@CentOS7-5 ~]# vim /etc/xinetd.d/tftp
[root@CentOS7-5 ~]# systemctl start tftp
[root@CentOS7-5 ~]# systemctl enable tftp
Created symlink from /etc/systemd/system/sockets.target.wants/tftp.socket to /usr/lib/syste                                          md/system/tftp.socket.
[root@CentOS7-5 ~]# systemctl start xinetd
[root@CentOS7-5 ~]# systemctl enable xinetd
[root@CentOS7-5 ~]#
[root@CentOS7-5 ~]# yum -y install dhcp
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 dhcp.x86_64.12.4.2.5-58.el7.centos 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================
 Package        架构             版本                                源               大小
===========================================================================================
正在安装:
 dhcp           x86_64           12:4.2.5-58.el7.centos              httpd           513 k

事务概要
===========================================================================================
安装  1 软件包

总下载量:513 k
安装大小:1.4 M
Downloading packages:
dhcp-4.2.5-58.el7.centos.x86_64.rpm                                 | 513 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : 12:dhcp-4.2.5-58.el7.centos.x86_64                                     1/1
  验证中      : 12:dhcp-4.2.5-58.el7.centos.x86_64                                     1/1

已安装:
  dhcp.x86_64 12:4.2.5-58.el7.centos

完毕!
[root@CentOS7-5 ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
cp:是否覆盖"/etc/dhcp/dhcpd.conf"? yes
[root@CentOS7-5 ~]# vim /etc/dhcp/dhcpd.conf
[root@CentOS7-5 ~]# systemctl start dhcpd
[root@CentOS7-5 ~]# systemctl enable dhcpd
Created symlink from /etc/systemd/system/multi-user.target.wants/dhcpd.service to /usr/lib/                                          systemd/system/dhcpd.service.
[root@CentOS7-5 ~]# mount /dev/sr0 /mnt
mount: /dev/sr0 写保护,将以只读方式挂载
[root@CentOS7-5 ~]# cd /mnt/images/pxeboot
[root@CentOS7-5 pxeboot]# cp vmlinuz /var/lib/tftpboot/
[root@CentOS7-5 pxeboot]# cp initrd.img /var/lib/tftpboot/
[root@CentOS7-5 pxeboot]# yum -y install syslinux
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 syslinux.x86_64.0.4.05-13.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================
 Package              架构               版本                      源                 大小
===========================================================================================
正在安装:
 syslinux             x86_64             4.05-13.el7               httpd             989 k

事务概要
===========================================================================================
安装  1 软件包

总下载量:989 k
安装大小:2.3 M
Downloading packages:
syslinux-4.05-13.el7.x86_64.rpm                                     | 989 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : syslinux-4.05-13.el7.x86_64                                            1/1
  验证中      : syslinux-4.05-13.el7.x86_64                                            1/1

已安装:
  syslinux.x86_64 0:4.05-13.el7

完毕!
[root@CentOS7-5 pxeboot]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
[root@CentOS7-5 pxeboot]# yum -y install vsftpd
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 vsftpd.x86_64.0.3.0.2-22.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

===========================================================================================
 Package            架构               版本                        源                 大小
===========================================================================================
正在安装:
 vsftpd             x86_64             3.0.2-22.el7                httpd             169 k

事务概要
===========================================================================================
安装  1 软件包

总下载量:169 k
安装大小:348 k
Downloading packages:
vsftpd-3.0.2-22.el7.x86_64.rpm                                      | 169 kB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : vsftpd-3.0.2-22.el7.x86_64                                             1/1
  验证中      : vsftpd-3.0.2-22.el7.x86_64                                             1/1

已安装:
  vsftpd.x86_64 0:3.0.2-22.el7

完毕!
[root@CentOS7-5 pxeboot]# mkdir /var/ftp/centos7
[root@CentOS7-5 pxeboot]# cp -rf /mnt/* /var/ftp/centos7/
[root@CentOS7-5 pxeboot]# systemctl start vsftpd
[root@CentOS7-5 pxeboot]# systemctl enable vsftpd
Created symlink from /etc/systemd/system/multi-user.target.wants/vsftpd.service to /usr/lib/                                         systemd/system/vsftpd.service.
[root@CentOS7-5 pxeboot]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@CentOS7-5 pxeboot]# vim /var/lib/tftpboot/pxelinux.cfg/default
[root@CentOS7-5 pxeboot]# systemctl stop firewalld.service
[root@CentOS7-5 pxeboot]# setenforce 0
[root@CentOS7-5 pxeboot]# yum install -y system-config-kickstart
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
正在解决依赖关系
--> 正在检查事务
---> 软件包 system-config-kickstart.noarch.0.2.9.6-1.el7 将被 安装
--> 正在处理依赖关系 system-config-keyboard >= 1.3.1,它被软件包 system-config-kickstart-2.9                                         .6-1.el7.noarch 需要
--> 正在处理依赖关系 system-config-language,它被软件包 system-config-kickstart-2.9.6-1.el7.                                         noarch 需要
--> 正在处理依赖关系 system-config-date,它被软件包 system-config-kickstart-2.9.6-1.el7.noar                                         ch 需要
--> 正在检查事务
---> 软件包 system-config-date.noarch.0.1.10.6-2.el7.centos 将被 安装
--> 正在处理依赖关系 system-config-date-docs,它被软件包 system-config-date-1.10.6-2.el7.cen                                         tos.noarch 需要
--> 正在处理依赖关系 gnome-python2-canvas,它被软件包 system-config-date-1.10.6-2.el7.centos                                         .noarch 需要
---> 软件包 system-config-keyboard.noarch.0.1.4.0-4.el7 将被 安装
--> 正在处理依赖关系 system-config-keyboard-base = 1.4.0-4.el7,它被软件包 system-config-key                                         board-1.4.0-4.el7.noarch 需要
---> 软件包 system-config-language.noarch.0.1.4.0-9.el7 将被 安装
--> 正在处理依赖关系 usermode-gtk,它被软件包 system-config-language-1.4.0-9.el7.noarch 需要
--> 正在检查事务
---> 软件包 gnome-python2-canvas.x86_64.0.2.28.1-14.el7 将被 安装
--> 正在处理依赖关系 gnome-python2(x86-64) = 2.28.1-14.el7,它被软件包 gnome-python2-canvas-                                         2.28.1-14.el7.x86_64 需要
--> 正在处理依赖关系 libgnomecanvas(x86-64) >= 2.8.0,它被软件包 gnome-python2-canvas-2.28.1                                         -14.el7.x86_64 需要
--> 正在处理依赖关系 libgnomecanvas-2.so.0()(64bit),它被软件包 gnome-python2-canvas-2.28.1-                                         14.el7.x86_64 需要
--> 正在处理依赖关系 libart_lgpl_2.so.2()(64bit),它被软件包 gnome-python2-canvas-2.28.1-14.                                         el7.x86_64 需要
---> 软件包 system-config-date-docs.noarch.0.1.0.11-4.el7 将被 安装
--> 正在处理依赖关系 rarian-compat,它被软件包 system-config-date-docs-1.0.11-4.el7.noarch                                          需要
---> 软件包 system-config-keyboard-base.noarch.0.1.4.0-4.el7 将被 安装
---> 软件包 usermode-gtk.x86_64.0.1.111-5.el7 将被 安装
--> 正在检查事务
---> 软件包 gnome-python2.x86_64.0.2.28.1-14.el7 将被 安装
---> 软件包 libart_lgpl.x86_64.0.2.3.21-10.el7 将被 安装
---> 软件包 libgnomecanvas.x86_64.0.2.30.3-8.el7 将被 安装
---> 软件包 rarian-compat.x86_64.0.0.8.1-11.el7 将被 安装
--> 正在处理依赖关系 rarian = 0.8.1-11.el7,它被软件包 rarian-compat-0.8.1-11.el7.x86_64 需                                         要
--> 正在处理依赖关系 rarian,它被软件包 rarian-compat-0.8.1-11.el7.x86_64 需要
--> 正在处理依赖关系 librarian.so.0()(64bit),它被软件包 rarian-compat-0.8.1-11.el7.x86_64                                          需要
--> 正在检查事务
---> 软件包 rarian.x86_64.0.0.8.1-11.el7 将被 安装
--> 解决依赖关系完成

依赖关系解决

============================================================================================
 Package                           架构         版本                      源           大小
============================================================================================
正在安装:
 system-config-kickstart           noarch       2.9.6-1.el7               httpd       351 k
为依赖而安装:
 gnome-python2                     x86_64       2.28.1-14.el7             httpd        47 k
 gnome-python2-canvas              x86_64       2.28.1-14.el7             httpd        34 k
 libart_lgpl                       x86_64       2.3.21-10.el7             httpd        67 k
 libgnomecanvas                    x86_64       2.30.3-8.el7              httpd       226 k
 rarian                            x86_64       0.8.1-11.el7              httpd        98 k
 rarian-compat                     x86_64       0.8.1-11.el7              httpd        66 k
 system-config-date                noarch       1.10.6-2.el7.centos       httpd       619 k
 system-config-date-docs           noarch       1.0.11-4.el7              httpd       527 k
 system-config-keyboard            noarch       1.4.0-4.el7               httpd        33 k
 system-config-keyboard-base       noarch       1.4.0-4.el7               httpd       103 k
 system-config-language            noarch       1.4.0-9.el7               httpd       133 k
 usermode-gtk                      x86_64       1.111-5.el7               httpd       109 k

事务概要
============================================================================================
安装  1 软件包 (+12 依赖软件包)

总下载量:2.4 M
安装大小:8.5 M
Downloading packages:
(1/13): gnome-python2-2.28.1-14.el7.x86_64.rpm                       |  47 kB  00:00:00
(2/13): libart_lgpl-2.3.21-10.el7.x86_64.rpm                         |  67 kB  00:00:00
(3/13): libgnomecanvas-2.30.3-8.el7.x86_64.rpm                       | 226 kB  00:00:00
(4/13): rarian-0.8.1-11.el7.x86_64.rpm                               |  98 kB  00:00:00
(5/13): gnome-python2-canvas-2.28.1-14.el7.x86_64.rpm                |  34 kB  00:00:00
(6/13): rarian-compat-0.8.1-11.el7.x86_64.rpm                        |  66 kB  00:00:00
(7/13): system-config-date-1.10.6-2.el7.centos.noarch.rpm            | 619 kB  00:00:00
(8/13): system-config-date-docs-1.0.11-4.el7.noarch.rpm              | 527 kB  00:00:00
(9/13): system-config-keyboard-base-1.4.0-4.el7.noarch.rpm           | 103 kB  00:00:00
(10/13): system-config-keyboard-1.4.0-4.el7.noarch.rpm               |  33 kB  00:00:00
(11/13): system-config-kickstart-2.9.6-1.el7.noarch.rpm              | 351 kB  00:00:00
(12/13): system-config-language-1.4.0-9.el7.noarch.rpm               | 133 kB  00:00:00
(13/13): usermode-gtk-1.111-5.el7.x86_64.rpm                         | 109 kB  00:00:00
--------------------------------------------------------------------------------------------
总计                                                        8.9 MB/s | 2.4 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  正在安装    : libart_lgpl-2.3.21-10.el7.x86_64                                       1/13
  正在安装    : libgnomecanvas-2.30.3-8.el7.x86_64                                     2/13
  正在安装    : gnome-python2-2.28.1-14.el7.x86_64                                     3/13
  正在安装    : gnome-python2-canvas-2.28.1-14.el7.x86_64                              4/13
  正在安装    : usermode-gtk-1.111-5.el7.x86_64                                        5/13
  正在安装    : system-config-language-1.4.0-9.el7.noarch                              6/13
  正在安装    : rarian-0.8.1-11.el7.x86_64                                             7/13
  正在安装    : rarian-compat-0.8.1-11.el7.x86_64                                      8/13
  正在安装    : system-config-date-docs-1.0.11-4.el7.noarch                            9/13
  正在安装    : system-config-date-1.10.6-2.el7.centos.noarch                         10/13
  正在安装    : system-config-keyboard-base-1.4.0-4.el7.noarch                        11/13
  正在安装    : system-config-keyboard-1.4.0-4.el7.noarch                             12/13
  正在安装    : system-config-kickstart-2.9.6-1.el7.noarch                            13/13
  验证中      : libgnomecanvas-2.30.3-8.el7.x86_64                                     1/13
  验证中      : system-config-keyboard-base-1.4.0-4.el7.noarch                         2/13
  验证中      : system-config-date-docs-1.0.11-4.el7.noarch                            3/13
  验证中      : system-config-language-1.4.0-9.el7.noarch                              4/13
  验证中      : rarian-compat-0.8.1-11.el7.x86_64                                      5/13
  验证中      : gnome-python2-canvas-2.28.1-14.el7.x86_64                              6/13
  验证中      : system-config-keyboard-1.4.0-4.el7.noarch                              7/13
  验证中      : rarian-0.8.1-11.el7.x86_64                                             8/13
  验证中      : usermode-gtk-1.111-5.el7.x86_64                                        9/13
  验证中      : libart_lgpl-2.3.21-10.el7.x86_64                                      10/13
  验证中      : system-config-kickstart-2.9.6-1.el7.noarch                            11/13
  验证中      : system-config-date-1.10.6-2.el7.centos.noarch                         12/13
  验证中      : gnome-python2-2.28.1-14.el7.x86_64                                    13/13

已安装:
  system-config-kickstart.noarch 0:2.9.6-1.el7

作为依赖被安装:
  gnome-python2.x86_64 0:2.28.1-14.el7
  gnome-python2-canvas.x86_64 0:2.28.1-14.el7
  libart_lgpl.x86_64 0:2.3.21-10.el7
  libgnomecanvas.x86_64 0:2.30.3-8.el7
  rarian.x86_64 0:0.8.1-11.el7
  rarian-compat.x86_64 0:0.8.1-11.el7
  system-config-date.noarch 0:1.10.6-2.el7.centos
  system-config-date-docs.noarch 0:1.0.11-4.el7
  system-config-keyboard.noarch 0:1.4.0-4.el7
  system-config-keyboard-base.noarch 0:1.4.0-4.el7
  system-config-language.noarch 0:1.4.0-9.el7
  usermode-gtk.x86_64 0:1.111-5.el7

完毕!
[root@CentOS7-5 pxeboot]# vim /var/lib/tftpboot/pxelinux.cfg/default
[root@CentOS7-5 pxeboot]# cd ~
[root@CentOS7-5 ~]# ls
anaconda-ks.cfg       ks.cfg  模板  图片  下载  桌面
initial-setup-ks.cfg  公共    视频  文档  音乐
[root@CentOS7-5 ~]# vim ks.cfg
[root@CentOS7-5 ~]# cp ks.cfg /var/ftp/
[root@CentOS7-5 ~]# cd /var/ftp/
[root@CentOS7-5 ftp]# ls
centos7  ks.cfg  pub
[root@CentOS7-5 ftp]# vim /var/lib/tftpboot/pxelinux.cfg/default
[root@CentOS7-5 ftp]# vim /var/lib/tftpboot/pxelinux.cfg/default
[root@CentOS7-5 ftp]# vim ks.cfg
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
引用内容提供了在Linux系统上安装syslinux和配置tftp服务器的步骤,引用内容提供了创建pxelinux.cfg目录的步骤,引用内容提供了保存自动应答软件和编辑引导菜单的步骤。 PXE(Preboot Execution Environment)是一种网络引导协议,可以通过网络服务器上安装和配置操作系统。使用PXE进行Linux装机可以实现批量装机和自动化装机的需求。 在进行Linux PXE装机之前,需要进行以下步骤: 1. 安装syslinux和tftp服务器使用命令`yum install -y syslinux`安装syslinux,并使用命令`yum install -y tftp-server`安装tftp服务器。 2. 复制pxelinux.0文件到tftp服务器目录:使用命令`cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/`将pxelinux.0文件复制到tftp服务器的目录下。 3. 创建pxelinux.cfg目录:使用命令`mkdir /var/lib/tftpboot/pxelinux.cfg`创建pxelinux.cfg目录,该目录用于存放引导菜单的配置文件。 4. 准备自动应答文件:将自动应答文件(比如ks.cfg)保存到服务器上,可以使用命令`cp /root/anaconda-ks.cfg /var/ftp/ks.cfg`将anaconda-ks.cfg文件复制到/var/ftp/目录下。 5. 编辑引导菜单的配置文件:使用命令`vim /var/lib/tftpboot/pxelinux.cfg/default`编辑引导菜单的配置文件,添加以下内容: ``` default auto prompt 0 label auto kernel vmlinuz append initrd=initrd.img method=ftp://192.168.100.10/centos7 ks=ftp://192.168.100.10/ks.cfg ``` 通过以上步骤,可以实现Linux PXE装机。在客户端上启动时,系统将从tftp服务器上下载引导文件pxelinux.0,然后根据引导菜单的配置文件default进行自动安装,同时使用指定的自动应答文件ks.cfg进行操作系统的配置。 请根据实际需求和网络环境进行相应的配置和调整。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [Linux——轻松学会PXE高效网络装机](https://blog.csdn.net/m0_61744194/article/details/124291052)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [如何使用PXE实现Linux网络装机](https://blog.csdn.net/YsDou/article/details/120143627)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值