第六章、PXE高效网络装机、Kickstart无人值守安装
阅读原文时间:2023年07月08日阅读:1

目录

一、部署PXE远程安装服务

PXE是有Intel公司开发的网络引导技术,工作在Client/Server模式(也简称CS模式),允许客户机通过网络从远程服务器下载引导镜像,并加载安装文件或整改操作系统。

  1. 规模化:同时装配多台服务器,无需每一台单独安装操作系统;
  2. 自动化:实现服务器的自动安装及自动配置各种服务;
  3. 远程实现:不需要光盘、U盘等安装介质,方便快捷的同时又可以保障服务器安全。

① 客户机

  • 客户机的网卡要支持PXE协议(集成BOOTROM芯片)
  • 主板支持网络引导。有一些需在BIOS设置中允许从 Network 或 LAN 启动即可。

② 服务端

  • [DHCP]服务器 :为客户机自动分配地址、指定引导文件位置。
  • 服务器要开启 TFTP服务(简单文件传输协议):用来提供系统内核和引导镜像文件的下载。
  • 服务器中使用FTP服务(或http/nfs)font> :提供yum安装源
  • 安装软件包syslinux :提供PXE引导程序

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

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

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

4.bios执行引导程序

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

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

二、搭建PXE远程安装服务器

批量安装系统

[root@localhost mnt]# yum install dhcp tftp-server.x86_64 vsftpd syslinux -y
[root@localhost /]# cp /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@localhost /]# vim /etc/dhcp/dhcpd.conf

# DHCP server to understand the network topology.

subnet 192.168.100.0 netmask 255.255.255.0 {
  range 192.168.100.10 192.168.100.50;
  option routers 192.168.100.100;
  next-server 192.168.100.100;
  filename "pxelinux.0";
}
[root@localhost /]# rpm -ql tftp-server
[root@localhost /]# vim /etc/xinetd.d/tftp
disable                 = no

[root@localhost tftpboot]# cd /var/ftp/
[root@localhost ftp]# mkdir centos7
[root@localhost ftp]# mount /dev/sr0 centos7/
[root@localhost ftp]# cd centos7/
[root@localhost centos7]# cd isolinux/
[root@localhost isolinux]# cp initrd.img vmlinuz /var/lib/tftpboot/
[root@localhost isolinux]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# rpm -ql syslinux |grep pxelinux.0
[root@localhost tftpboot]# cp /usr/share/syslinux/pxelinux.0 ./
[root@localhost tftpboot]# mkdir pxelinux.cfg
[root@localhost tftpboot]# cd pxelinux.cfg/
[root@localhost pxelinux.cfg]# vim default

复制
[root@localhost ~]# cd /mnt
[root@localhost mnt]# cd isolinux/
[root@localhost isolinux]# vim isolinux.cfg 

[root@localhost 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@localhost pxelinux.cfg]# cd ..
[root@localhost tftpboot]# tree
[root@localhost tftpboot]# systemctl stop firewalld
[root@localhost tftpboot]# setenforce 0
[root@localhost ~]# vim /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR=192.168.100.100
NETMASK=255.255.255.0
GATEWAY=192.168.100.100
#DNS1=8.8.8.8

设置仅主机
[root@localhost ~]# systemctl restart network
[root@localhost ~]# ip a
root@localhost ~]# systemctl start dhcpd
[root@localhost dhcp]# systemctl start tftp
[root@localhost dhcp]# systemctl start vsftpd

设置仅主机

三、Kickstart无人值守安装

[root@localhost pxelinux.cfg]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# mkdir bak
[root@localhost yum.repos.d]# mv *.repo bak/
[root@localhost yum.repos.d]# vim local.repo

[local]
name=local
baseurl=file:///var/ftp/centos7
gpgckeck=0

[root@localhost yum.repos.d]# yum clean all && yum makecache
[root@localhost yum.repos.d]# yum install system-config-kickstart -y

[root@localhost yum.repos.d]# cd /var/ftp/
[root@localhost ftp]# cd /var/lib/tftpboot/
[root@localhost tftpboot]# cd pxelinux.cfg/
[root@localhost pxelinux.cfg]# vim default

default menu.c32
prompt 1

label auto
        kernel vmlinuz
        append initrd=initrd.img method=ftp://192.168.100.100/centos7 ks=ftp://192.168.100.100/ks.cfg

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@localhost pxelinux.cfg]# cd /usr/share/syslinux/  #不加men.c32就不用打 是壁纸
[root@localhost syslinux]# cp menu.c32 /var/lib/tftpboot/

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器