第五章PXE高效批量网络装机

第一章PXE的概念

1.1实现的硬件条件

1.2实现过程

1.3优点

1.4操作过程

  1. 安装

  1. 将配置文件模板复制到dhcp目录下

3.修改配置文件

4拷配文件

5.安装配置文件


第一章PXE的概念

PXE 的全称是 preboot execute environment它其实是Intel在很久以前提出来的一项用于通过网络来引导系统的标准。允许客户机通过网络从远程服务器上下载引导镜像,并加载安装文件或者整个操作系统。

pxe是通过网卡引导启动

1.1实现的硬件条件

1.BIOS支持

2.网卡支持(现在基本都已支持)

3.需要在bios中开启开关,服务器一般没打开(bmc界面里打开)

4.网络中有一台 DHCP 服务器以便为客户机自动分配地址、指定引导文件位置 网卡自带DHCP功能 dhcp 指明分配的ip地址

5.服务器通过 tftp服务(简单文件传输协议)来提供系统内核和引导镜像的下载 udp()协议 网卡自带这个功能(不支持其他的远程共享服务)

1.2实现过程

1.网卡需要查找相关的dhcp服务器(获取地址时间)

2.找到后dhcp服务器提供ip地址,和引导程序(boot loader)的地址 还提供给客户机TFTPserver地址(dhcp本身不提供tftp服务)

3.网卡使用tftp客户端吧引导程序加载到内存中来

4.bios执行引导程序

5.引导程序会去TFTP去查找配置文件

6.根据配置文件去引导安装系统

7.系统安装过程

1.3优点

1.规模化:同时装配多台服务器

2.自动化:安装系统、配置各种服务

3.远程实现:不需要光盘、U盘等安装介质

1.4操作过程

1.安装

2将配置文件模板复制到dhcp目录下

[root@localhost ~]# cat /etc/dhcp/dhcpd.conf

#

# DHCP Server Configuration file.

# see /usr/share/doc/dhcp*/dhcpd.conf.example //配置文件模板在此目录下

# see dhcpd.conf(5) man page

[root@localhost ~]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf //将模板文件覆盖掉配置文件

cp:是否覆盖"/etc/dhcp/dhcpd.conf"? y

[root@test2 ~]# vim /etc/dhcp/dhcpd.conf

subnet 192.168.100.0 netmask 255.255.255.0 {

range 192.168.100.200 192.168.100.230;

option routers 192.168.100.100;

# next-server 192.168.100.100; #指定tftp的服务器地址

# filename "pxelinux.0"; #指定grub 文件名

}

[root@localhost isolinux]# yum install tftp-server -y

[root@localhost isolinux]# rpm -ql tftp-server

/etc/xinetd.d/tftp

/usr/lib/systemd/system/tftp.service

/usr/lib/systemd/system/tftp.socket

/usr/sbin/in.tftpd

/usr/share/doc/tftp-server-5.2

/usr/share/doc/tftp-server-5.2/CHANGES

/usr/share/doc/tftp-server-5.2/README

/usr/share/doc/tftp-server-5.2/README.security

/usr/share/man/man8/in.tftpd.8.gz

/usr/share/man/man8/tftpd.8.gz

/var/lib/tftpboot

主要文件:

#/etc/xinetd.d/tftp //配置文件

#/var/lib/tftpboot //站点

3修改配置文件

[root@localhost isolinux]# vim /etc/xinetd.d/tftp

#14行改成no,启动服务

1 # default: off

2 # description: The tftp server serves files using the trivial file transfer \

3 # protocol. The tftp protocol is often used to boot diskless \

4 # workstations, download configuration files to network-aware printers, \

5 # and to start the installation process for some operating systems.

6 service tftp

7 {

8 socket_type = dgram

9 protocol = udp

10 wait = yes

11 user = root

12 server = /usr/sbin/in.tftpd

13 server_args = -s /var/lib/tftpboot

# 14 disable = no #14行改成no,启动服务

15 per_source = 11

16 cps = 100 2

17 flags = IPv4

18 }

#每项详解

service tftp

{

socket_type = dgram

protocol = udp

wait = no //wait no表示客户机可以多台一起连接,yes表示客户机只能一台一台连接,表示是否开启多线程一起工作,否则需要等待

user = root

server = /usr/sbin/in.tftpd

server_args = -s /var/lib/tftpboot //指定TFTP根目录(引导文件的存储路径) -c允许上传

disable = no //disable no表示开启TFTP服务

per_source = 11 //通过限制一个主机的最大连接数,从而防止某个主机独占某个服务,这里每个IP地址的连接数是11个

cps = 100 2 //表示服务器最多启动100个连接,如果达到这个数目将停止启动新服务2秒。在此期间不接受任何请求

flags = IPv4

}

4拷配文件

[root@test2 ~]# yum install syslinux -y //引导程序文件需要先安装此服务

[root@localhost isolinux]# rpm -ql syslinux |grep pxelinux.0 //安装完成后找到该文件的地址

/usr/share/syslinux/gpxelinux.0

/usr/share/syslinux/pxelinux.0 //地址

[root@localhost isolinux]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/ //拷贝到站点文件里

5.安装配置文件

[root@localhost centos7]# yum install vsftpd -y

[root@localhost centos7]#rpm -ql vsftpd

/var/ftp

[root@localhost centos7]# mkdir centos7

[root@localhost centos7]# mount /dev/sr0 /var/ftp/centos7/

mount: /dev/sr0 写保护,将以只读方式挂载

[root@localhost centos7]# cd /var/ftp/centos7/

[root@localhost centos7]# ls

CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7

EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL

[root@localhost centos7]# cd images/

[root@localhost images]# ls

efiboot.img pxeboot TRANS.TBL

[root@localhost images]# cd pxeboot/

[root@localhost pxeboot]# ls

initrd.img TRANS.TBL vmlinuz

[root@localhost pxeboot]# cp initrd.img vmlinuz /var/lib/tftpboot/

[root@localhost pxeboot]# cd /var/lib/tftpboot/

[root@test2 tftpboot]# mkdir pxelinux.cfg

[root@test2 tftpboot]# cd pxelinux.cfg/

5编写配置文件

[root@test2 pxelinux.cfg]# vim default

default auto

prompt 1

label auto

kernel vmlinuz

append initrd=initrd.img method=ftp://192.168.100.100/centos7

label linux text

kernel vmlinuz

append text initrd =initrd.img method=ftp://192.168.100.100/centos7

label linux rescue

kernel vmlinuz

append rescue initrd=initrd.img method=ftp://192.168.100.100/centos7

[root@test2 tftpboot]# ls

#四大文件

initrd.img pxelinux.0 pxelinux.cfg/default vmlinuz

[root@localhost pxeboot]# systemctl stop firewalld.service

[root@localhost pxeboot]# systemctl start dhcpd

[root@localhost pxeboot]# systemctl start tftp

[root@localhost pxeboot]# systemctl start vsftpd

[root@localhost pxeboot]# setenforce 0

注:这里的dhcpd没有安装

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值