centos7 基于pxe安装系统

简介:

一、概念与原理

什么是PXE

   严格来说,PXE 并不是一种安装方式,而是一种引导的方式。进行 PXE 安装的必要条件是要安装的计算机中包含一个 PXE 支持的网卡(NIC),即网卡中必须要有 PXE Client。PXE (Pre-boot Execution Environment,直译为启动前的执行环境)协议使计算机可以通过网络启动。协议分为 client 和 server 端,PXE client 在网卡的 ROM 中,当计算机引导时,BIOS 把 PXE client 调入内存执行,由 PXE client 将放置在远端的文件通过网络下载到本地运行。运行 PXE 协议需要设置 DHCP 服务器和 TFTP 服务器。DHCP 服务器用来给 PXE client(将要安装系统的主机)分配一个 IP 地址,由于是给 PXE client 分配 IP 地址,所以在配置 DHCP 服务器时需要增加相应的 PXE 设置。此外,在 PXE client 的 ROM 中,已经存在了 TFTP Client。PXE Client 通过 TFTP 协议到 TFTP Server 上下载所需的文件。

什么是KickStart

   KickStart是一种无人职守安装方式。KickStart的工作原理是通过记录典型的安装过程中所需人工干预填写的各种参数,并生成一个名为ks.cfg的文件;在其后的安装过程中(不只局限于生成KickStart安装文件的机器)当出现要求填写参数的情况时,安装程序会首先去查找KickStart生成的文件,当找到合适的参数时,就采用找到的参数,当没有找到合适的参数时,才需要安装者手工干预。这样,如果KickStart文件涵盖了安装过程中出现的所有需要填写的参数时,安装者完全可以只告诉安装程序从何处取ks.cfg文件,然后去忙自己的事情。等安装完毕,安装程序会根据ks.cfg中设置的重启选项来重启系统,并结束安装。

二、环境说明

  执行pxe+kickstart来批量安装系统,需要的环境为

  1.DHCP服务器

  2.TFTP服务器

  3.httpd服务器或者ftp服务器或nfs服务器等能提供文件访问的服务器

  4.ks.cfg文件

  5.syslinux服务提供的pxelinux.0文件

  6.一台带有支持pxe协议的网卡的主机

  7.为确保实验可用性,请将防火墙和selinux关闭

三、安装步骤

1)、系统版本

1
2
[root@localhost ~]# uname -r
3.10.0-327.el7.x86_64

1
2
3


[root@localhost ~]# uname -a

Linux localhost.localdomain 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux


2)、配置网络环境以及yum源

本处使用的yum源为系统默认源,

本级网络为

1
2
3
4
5
6
7
8
9
10
11
12
13
[root@localhost dhcp] # ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
     link /loopback  00:00:00:00:00:00 brd 00:00:00:00:00:00
     inet 127.0.0.1 /8  scope host lo
        valid_lft forever preferred_lft forever
     inet6 ::1 /128  scope host
        valid_lft forever preferred_lft forever
2: eno16777736: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
     link /ether  00:0c:29:cc:38:86 brd ff:ff:ff:ff:ff:ff
     inet 172.16.219.136 /24  brd 172.16.219.255 scope global dynamic eno16777736
        valid_lft 1353sec preferred_lft 1353sec
     inet6 fe80::20c:29ff:fecc:3886 /64  scope link
        valid_lft forever preferred_lft forever

    3)、安装DHCP服务

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

 配置dhcp服务器,使其能够提供172.16.219.50-172.16.219.53的ip地址,子网掩码为255.255.255.0。配置如下

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
  [root@localhost ~] # vi /etc/dhcp/dhcpd.conf
  ddns-update-style interim;
  ignore client-updates;
  authoritative;
  allow booting;
  allow bootp;
  allow unknown-clients;
  # A slightly different configuration for an internal subnet.
  subnet 172.16.219.0 netmask 255.255.255.0 {
     range 172.16.219.50 172.16.219.53;
     default-lease- time  600;
     max-lease- time  7200;
 
  next-server 172.16.219.136;  #  DHCP server ip
  filename  "pxelinux.0" ;
  }

4)、安装httpd服务(本文通过http的方式提供服务)

1
[root@localhost ~] # yum install -y httpd

配置如下

1
2
3
4
5
6
7
8
[root@localhost ~] # vi /etc/httpd/conf.d/pxeboot.conf
Alias  /centos7_x64  /var/lib/tftpboot/centos7_x64/
 
<Directory  /var/lib/tftpboot/centos7_x64 >
Options Indexes FollowSymLinks
Require ip 127.0.0.1 172.16.219.0 /24
< /Directory >
~

5)、安装tftp-server服务端

1
[root@localhost ~] # yum install tftp-server xinetd -y

修改xinetd文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# default: off
# description: The tftp server serves files using the trivial file transfer \
#       protocol.  The tftp protocol is often used to boot diskless \
#       workstations, download configuration files to network-aware printers, \
#       and to start the installation process for some operating systems.
service tftp
{
         socket_type             = dgram
         protocol                = udp
         wait                    =  yes
         user                    = root
         server                  =  /usr/sbin/in .tftpd
         server_args             = -s  /var/lib/tftpboot
         disable                 = no
         per_source              = 11
         cps                     = 100 2
         flags                   = IPv4
}

把siabled的yes改为no

6)、准备所需要的rpm包

1
2
3
4
mount  -o loop  /root/CentOS-XX .iso  /mnt/
mkdir  /var/lib/tftpboot/centos7_x64
cp  -fr  /mnt/ /var/lib/tftpboot/centos7_x64/
chmod  -R 755  /var/lib/tftpboot/centos7_x64/


7)、准备tftpboot下的文件

安装syslinux,此服务为pxe提供pxelinux.0文件

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

准备文件

1
2
cd  /usr/share/syslinux/
cp  pxelinux.0 menu.c32 memdisk mboot.c32 chain.c32  /var/lib/tftpboot/

自定义pxe文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mkdir  /var/lib/tftpboot/pxelinux .cfg
default menu.c32
prompt 0
timeout 300
ONTIMEOUT  local
 
menu title  ########## PXE Boot Menu ##########
 
label 1
menu label ^1) Install CentOS 7
kernel centos7_x64 /images/pxeboot/vmlinuz
append initrd=centos7_x64 /images/pxeboot/initrd .img method=http: //172 .16.219.136 /centos7_x64  devfs=nomount
 
label 2
menu label ^2) Boot from  local  drive localboot

9)、重启各个服务

1
2
3
systemctl restart xinetd
systemctl restart httpd
systemctl restart dhcpd

将各个服务设置成开机自启动

1
2
3
systemctl  enable  xinetd
systemctl  enable  httpd
systemctl  enable  dhcpd

一切准备就绪,可以开始测试了

10)、测试安装

wKioL1jaI7Dhkp-SAAC219Njnv0009.png


本文转自wangfeng7399 51CTO博客,原文链接:http://blog.51cto.com/wangfeng7399/1911145,如需转载请自行联系原作者


相关文章
|
1月前
|
关系型数据库 MySQL Linux
卸载、下载、安装mysql(Linux系统centos7)
卸载、下载、安装mysql(Linux系统centos7)
|
3月前
|
Java Linux Shell
linux自动部署jar包,注册系统服务(基于Centos7)
linux自动部署jar包,注册系统服务(基于Centos7)
126 0
|
4月前
|
安全 Linux 网络安全
百度搜索:蓝易云【centos7系统添加用户、密码,以及修改端口教程】
请牢记,对系统进行任何更改都需要谨慎行事。在执行这些操作之前,最好备份重要的数据和配置文件,并确保您具有足够的权限和知识来进行这些更改。如果在操作过程中遇到任何问题,请务必小心并及时修复,以免影响系统的稳定性和安全性。
74 2
|
4月前
|
缓存 Linux 网络安全
系统-安装centos6
系统-安装centos6
153 0
|
4月前
|
监控 安全 Linux
CentOS7下部署ARL资产侦察灯塔系统
CentOS7下部署ARL资产侦察灯塔系统
225 3
|
2天前
|
关系型数据库 MySQL Linux
一次虚拟机centos7系统崩溃恢复记录
一次虚拟机centos7系统崩溃恢复记录
|
2天前
|
Java Linux API
minio文档系统在centos7虚拟机上的搭建
minio文档系统在centos7虚拟机上的搭建
|
3天前
|
安全 Linux Anolis
centos停止更新?这篇博客教会你CentOS 7转化系统为阿里龙蜥Anolis OS 7
centos停止更新?这篇博客教会你CentOS 7转化系统为阿里龙蜥Anolis OS 7
|
5天前
|
安全 关系型数据库 MySQL
CentOS 7系统加固详细方案SSH FTP MYSQL加固
CentOS 7系统加固详细方案SSH FTP MYSQL加固
|
6天前
|
Linux 网络安全 数据库
linux centos系统搭建samba文件服务器 NetBIOS解析 (超详细)
linux centos系统搭建samba文件服务器 NetBIOS解析 (超详细)

热门文章

最新文章