在 SUSE Linux Enterprise Server for SAP Applications 16.0 上设置 PXE 引导服务器
- 内容
设置支持 UEFI 安全引导和 Agama 安装程序的 PXE 引导服务器。
- 原因
通过网络自动完成多个 SUSE Linux Enterprise Server for SAP Applications 16.0 系统的安装,简化安装流程。
- 工作量
系统或网络管理员阅读并理解本文通常需要 30 至 45 分钟。
- 目标
打造一台可运行的 PXE 服务器,能将多种体系结构的设备引导至 Agama 安装程序。
- 要求
具备管理员权限的 SUSE Linux Enterprise Server for SAP Applications 16.0 系统
用于获取 ISO 映像的互联网连接
PXE 服务器的静态 IP 配置
1 SUSE Linux Enterprise Server for SAP Applications 16.0 的 PXE 引导概述 #
PXE 引导可使计算机通过网络引导至安装或运行时环境,而无需本地存储设备。本章将介绍 PXE 在 SUSE Linux Enterprise Server for SAP Applications 16.0 Agama 及实时安装程序映像中的工作原理,重点说明 GRUB 2 的相关配置。
1.1 PXE 引导是什么? #
PXE(预引导执行环境)是一种让系统通过 DHCP 和 TFTP/HTTP 从网络服务器检索引导加载程序和操作系统安装程序的方法。它广泛用于无需物理媒体或预安装操作系统的计算机配置场景。
1.2 PXE 引导的优势 #
PXE 引导无需本地安装媒体或手动设置,简化了计算机配置流程,具体优势包括:
通过网络以无人值守的方式安装许多系统
集中管理安装程序版本和引导配置
支持多种体系结构和固件类型,包括 UEFI 安全引导
通过 GRUB 2 菜单动态选择安装程序或安装参数
1.3 SUSE Linux Enterprise Server for SAP Applications 16.0 中 PXE 引导的工作原理 #
SUSE Linux Enterprise Server for SAP Applications 16.0 中的 PXE 引导使用 GRUB 2 作为引导加载程序,使用 Agama 安装程序作为安装界面。导加载程序和安装程序文件通过 HTTP 或 TFTP 协议从网络提供,其中 GRUB 2 负责获取内核、initrd 和实时映像。PXE 客户端可根据其体系结构(如 AMD64/Intel 64、AArch64、ppc64le、s390x)的需求,使用多种固件(包括常用的 BIOS 或 UEFI)、引导加载程序可执行文件或映像格式。此外,此类客户端必须支持在 IPv4 和 IPv6 两种网络环境中运行。
引导加载程序会传递内核参数(如 root=live:),用于从实时 ISO 映像加载基于 squashfs 的根文件系统,进而启动 Agama 界面 - 该界面既可以在本地运行,也可以作为 Web 服务运行,以支持远程 Web UI 操作。
1.3.1 与 SLES for SAP 15.x 的向后兼容性 #
本文信息主要适用于 SUSE Linux Enterprise Server for SAP Applications 16.0 及更高版本,重点介绍与 Agama 安装程序集成、依赖实时安装映像的 PXE 引导流程。在本文的背景与讨论范围内,SLES for SAP 16.0 及更高版本与 SLES for SAP 15.x 存在以下差异:
- 安装程序
使用
dracut和 Agama,而非linuxrc和 YaST。- DHCP 服务器
不再支持 ISC DHCP(2022 年已终止服务),需改用 Kea 或 dnsmasq 作为 DHCP 服务器。
- 引导参数
使用
root=live:参数加载 Agama 安装程序映像,使用可选参数inst.install_url=而非install=参数指定非默认安装储存库。
引导加载程序的选择(如 GRUB 2、pxelinux 等)保持灵活性,不依赖版本。
1.3.2 多种可行的设置方案和步骤 #
本文包含必选设置步骤以及可选或替代配置。请仅参考与您的部署相关的章节,跳过所有不适用于您部署场景的替代方案。
- 必选步骤
所有设置场景下,均须完成以下任务:安装组件、准备安装程序映像、配置 GRUB 2 以及验证服务器。
- 文件分发方式
使用 HTTP 服务器(推荐与 Agama 搭配使用,如
nginx)和/或 TFTP 服务器(如tftp或dnsmasq)。- DHCP 服务器
选择 Kea 或 dnsmasq。
注意:所选方案的局限性和特性Kea 是 ISC 推出的新一代 DHCP 服务器,可作为 ISC DHCP 的现代化替代方案。有关 Kea 的详细信息,请访问 https://www.isc.org/kea/。有关 ISC DHCP 终止服务的通知,请访问 https://www.isc.org/dhcp/。Kea 只是 DHCP 服务器,需搭配单独的 TFTP 服务器软件使用。Kea DHCP 服务器支持通过 IPv4 和 IPv6 实现 TFTP/PXE 引导的相关选项,也支持通过 IPv4 实现 HTTP 引导的选项。通过 IPv6 实现 HTTP 引导时,要求 DHCPv6 服务器能够向客户端返回
Vendor Class Option(请参见RFC3315, Section 22.16,该信息用于供“客户端标识供应商”),目前暂不支持此功能。dnsmasq 集 DNS 服务器、DHCP 服务器和 TFTP 服务器于一体。您可以使用它通过 TFTP 提供引导加载程序、内核、initrd 及其他文件。有关 dnsmasq 的详细信息,请访问 https://thekelleys.org.uk/dnsmasq/doc.html。dnsmasq DHCP 服务器支持通过 IPv4 和 IPv6 实现 TFTP/PXE 引导的相关选项,也支持通过 IPv4 实现 HTTP 引导的选项。通过 IPv6 实现 HTTP 引导时,要求 DHCPv6 服务器能够向客户端返回
Vendor Class Option(请参见RFC3315, Section 22.16,该信息用于“供客户端标识供应商”),目前暂不支持此功能。
2 为 PXE 引导服务准备网络 #
本章介绍在 SUSE Linux Enterprise Server for SAP Applications 16.0 上部署 PXE 引导服务需要满足的网络基础架构要求。
2.1 简介 #
PXE 服务器包含三类服务器:提供地址和引导文件(引导加载程序)位置的 DHCP 服务器,以及用于检索文件的 TFTP 和/或 HTTP 服务器。此外,可能还需要 DNS 服务器、NTP 服务器和支持 IPv6 的路由器 — 在生产环境网络中,这些服务器通常与 PXE 服务器分开部署。对于运行 SUSE Linux Enterprise Server for SAP Applications 16.0 的 PXE 服务器,可能还需进行特定的网络接口设置、在防火墙中添加特定的持久化规则,以及配置 SELinux 的相关权限。本章将以示例形式展示一个包含合适 IP 范围的网络环境,并说明防火墙和 SELinux 所需的必要规则。
2.2 假设和网络配置示例 #
本文假设:
PXE 服务器在
eno1网络接口上运行,网络配置如下:表 1︰ PXE 网络配置示例 #IPv4 IPv6 DNS 名称 PXE 网络 192.168.1.0/24 2001:db8:0:1::/64 example.net PXE 服务器 192.168.1.200 2001:db8:0:1::200 pxe.example.net PXE 网关 192.168.1.1 2001:db8:0:1::1 DNS 服务器 192.168.1.200 2001:db8:0:1::200 NTP 服务器 192.168.1.1 2001:db8:0:1::1 默认情况下,路由器、NTP 服务器和 DNS 服务器为外部服务器,运行在其他计算机上。本文会提供一些提示,但不包含其完整配置。
2.3 为 PXE 服务配置网络接口、防火墙和 SELinux #
配置网络接口和防火墙,以允许 PXE 服务器所需的网络服务。调整 SELinux 设置,以支持安装测试并定义持久的本地策略。
验证 PXE 网络接口并将其分配到适当的 firewalld 区域。
查看当前活跃的区域及其分配到的接口:
>sudofirewall-cmd --get-active-zones如果
eno1未分配到public区域,请将其分配到该区域:>sudofirewall-cmd --zone=public --change-interface=eno1使接口分配在系统重引导后仍生效:
>sudofirewall-cmd --permanent --zone=public --add-interface=eno1
配置防火墙以允许访问 DNS 服务。
向当前会话开放 DNS 服务访问权限:
>sudofirewall-cmd --zone=public --add-service=dns使该更改持久生效:
>sudofirewall-cmd --permanent --zone=public --add-service=dns
配置防火墙以允许访问 NTP 服务。
向当前会话开放 NTP 服务访问权限:
>sudofirewall-cmd --zone=public --add-service=ntp使该更改持久生效:
>sudofirewall-cmd --permanent --zone=public --add-service=ntp
配置防火墙以允许访问 DHCP (IPv4) 服务。
向当前会话开放 DHCP 服务访问权限:
>sudofirewall-cmd --zone=public --add-service=dhcp使该更改持久生效:
>sudofirewall-cmd --permanent --zone=public --add-service=dhcp
配置防火墙以允许访问 DHCPv6 服务。
向当前会话开放 DHCPv6 服务访问权限:
>sudofirewall-cmd --zone=public --add-service=dhcpv6使该更改持久生效:
>sudofirewall-cmd --permanent --zone=public --add-service=dhcpv6
配置防火墙以允许访问 TFTP 服务。
向当前会话开放 TFTP 服务访问权限:
>sudofirewall-cmd --zone=public --add-service=tftp使该更改持久生效:
>sudofirewall-cmd --permanent --zone=public --add-service=tftp
配置防火墙以允许访问 HTTP 服务。
向当前会话开放 HTTP 服务访问权限:
>sudofirewall-cmd --zone=public --add-service=http使该更改持久生效:
>sudofirewall-cmd --permanent --zone=public --add-service=http
配置防火墙以允许访问 HTTPS 服务。
向当前会话开放 HTTPS 服务访问权限:
>sudofirewall-cmd --zone=public --add-service=https使该更改持久生效:
>sudofirewall-cmd --permanent --zone=public --add-service=https
临时禁用
SELinux以进行设置测试。将
SELinux设置为宽松模式:>sudosetenforce 0检查
SELinux状态:>sudosestatus
生成并安装与 PXE 相关的服务的本地
SELinux策略模块。为
nginx创建并安装模块:>sudoif test `ausearch -c 'nginx' --raw | wc -l` -gt 0 ; then>sudoausearch -c 'nginx' --raw | audit2allow -a -M local-nginx>sudosemodule -i local-nginx.pp>sudofi为
dnsmasq创建并安装模块:>sudoif test `ausearch -c 'dnsmasq' --raw | wc -l` -gt 0 ; then>sudoausearch -c 'dnsmasq' --raw | audit2allow -a -M local-dnsmasq>sudosemodule -i local-dnsmasq.pp>sudofi为
in.tftpd创建并安装模块:>sudoif test `ausearch -c 'in.tftpd' --raw | wc -l` -gt 0 ; then>sudoausearch -c 'in.tftpd' --raw | audit2allow -a -M local-tftpd>sudosemodule -i local-tftpd.pp>sudofi
重新启用
SELinux强制模式。将
SELinux设置为强制模式:>sudosetenforce 1验证
SELinux状态:>sudosestatus
2.4 总结 #
通过上述过程,您已正确配置 PXE 服务器的网络接口、防火墙和 SELinux 策略,确保服务器能安全且正常运行,具体包括:
验证 PXE 服务接口(本示例中为
eno1)并将其分配到 firewalld 的public区域。开放 PXE 运行所需的防火墙服务,包括
dns、ntp、dhcp、dhcpv6、tftp、http和https。临时将
SELinux设置为permissive模式,以便进行服务测试并记录 AVC 拒绝信息。使用
ausearch和audit2allow生成并安装针对nginx、dnsmasq、in.tftpd等服务的自定义 SELinux 策略模块。将
SELinux恢复为enforcing模式,确保系统适合生产环境使用。
完成以上步骤后,PXE 服务器已完成安全配置,可通过 IPv4 或 IPv6 网络为客户端计算机提供服务。
3 安装所需的 PXE 服务器组件 #
本章介绍如何在 SUSE Linux Enterprise Server for SAP Applications 16.0 中安装支持 PXE 引导所需的软件包,包括 GRUB 2、DHCP、TFTP 和/或 HTTP 组件。
3.1 简介 #
要在 SUSE Linux Enterprise Server for SAP Applications 16.0 上配置 PXE 引导服务器,需要安装多个服务和工具。根据具体设置情况,可能需要以下组件:
dnsmasq 软件包:集成了 DNS 服务器、TFTP 服务器和 DHCP 服务器(支持 DHCPv4 和 DHCPv6),同时对 IPv6 路由器通告 (RA) 提供有限支持。具体功能包括:
dnsmasq DHCP 服务器:支持根据请求和客户端体系结构有条件地传递 DHCP 选项,适用于:
使用 DHCPv4 和 DHCPv6 的 PXE 引导请求
使用 DHCPv4 的 HTTP 引导请求
注意:dnsmasq 通过 DHCPv6 实现 HTTP 引导的局限性目前,dnsmasq 不支持发送 HTTP 引导所需的
vendor-classDHCPv6 选项。
dnsmasq TFTP 服务器:在 PXE 引导过程中,通过 TFTP 提供引导加载程序文件、内核和 initrd。
dnsmasq DNS 服务器:为客户端固件和安装程序/操作系统中的
/etc/resolv.conf提供域名及 IP 地址的递归解析服务。dnsmasq IPv6 RA:当 PXE 服务器同时作为路由器时,支持发送 IPv6 RA(配置能力仅限于“通用 RA 模式”)。
kea 软件包:一款 DHCP 服务器,是 ISC DHCP 服务器的继任者,支持根据请求和客户端体系结构有条件传递 DHCP 选项,适用于:
使用 DHCPv4 和 DHCPv6 的 PXE 引导请求
使用 DHCPv4 的 HTTP 引导请求
注意:Kea 通过 DHCPv6 实现 HTTP 引导的局限性目前,Kea 不支持发送 HTTP 引导所需的
vendor-classDHCPv6 选项。有关详细信息,请访问 https://kea.readthedocs.io/en/latest/arm/dhcp6-srv.html#id4。
TFTP 服务器:通过 TFTP 提供引导加载程序文件、内核和 initrd;搭配 kea 实现 PXE 引导时,需通过 tftp 软件包提供 TFTP 功能,而 HTTP 引导无需此组件。如果使用 dnsmasq,则无需安装 tftp 软件包。
Web 服务器:如 nginx 软件包,通过 HTTP 提供安装程序映像。
注意:HTTP 服务器的必要性几乎所有安装场景都需要 nginx 这类 HTTP/HTTPS 服务器。其用途不仅限于 HTTP 引导,尤其在以下场景中必不可少:
是 HTTP 引导的基本要求。
建议使用它来提供
squashfs.img。可在引导命令行中使用root=live:tftp://.../squashfs.img。对于
SLES-16.0-Full-*.inline.iso,如果需通过inst.install_url=http://.../install/引导命令行参数向 Agama 提供 RPM 软件包,同时提供安装配置文件及其他用于无人值守安装的文件,也建议使用 HTTP 服务器。
GRUB 2 引导加载程序软件包:为支持的体系结构和引导方式提供网络引导功能。例如,AMD64/Intel 64 体系结构支持 BIOS 和 UEFI 两种网络引导方式。此外,UEFI 通常支持 PXE (TFTP) 和 HTTP 引导。pxelinux 等其他引导加载程序不支持 UEFI 和 HTTP 引导。
可选组件:IPv6 路由器通告守护程序(如 radvd 软件包)。如果 SLES for SAP 同时作为安装程序网络的路由器,则需安装此组件,以实现以下功能:
为 PXE 或 HTTP 引导客户端配置网络路由。
允许 PXE 或 HTTP 引导客户端在网络上使用 DHCPv6。
3.2 要求 #
运行 SUSE Linux Enterprise Server for SAP Applications 16.0 且具备管理员权限的系统,已在 SUSE Customer Center 中注册,并通过 SUSEConnect 配置了对相应在线储存库的访问权限。
已启用以下 SLE 模块:Server Applications Module、Legacy Module 和 Base System Module。
可访问用于获取网络服务和引导加载程序的 SLE 模块储存库。
可正常连接互联网以获取软件包。
3.3 安装软件包 #
按以下步骤安装 PXE 引导服务器所需的核心软件包。
安装 GRUB 2 引导加载程序和 nginx HTTP 服务器(通用要求)。
>sudozypper install grub2 nginx根据您的方案,运行以下任一命令安装必要软件包:
如果使用 kea 作为 DHCP 服务器、tftp 作为 TFTP 服务器,请运行:
>sudozypper install kea tftp如果使用 dnsmasq 同时提供 DHCP、DNS 和 TFTP 服务,请运行:
>sudozypper install dnsmasq
注意:Kea 和 dnsmasq 提供的 DHCP 服务器的局限性目前,kea 和 dnsmasq 软件包提供的 DHCP 服务器不支持通过 IPv6 实现 HTTP 引导,无法按照 UEFI 规范要求,向 HTTP 客户端返回
vendor-class选项。(可选)如果计划支持其他平台,可安装额外的体系结构专用 GRUB 2 目标。
对于 AMD64/Intel 64 体系结构:
>sudozypper install grub2-x86_64-efi grub2-i386-pc对于 AArch64 体系结构:
>sudozypper install grub2-aarch64-efi对于 ppc64le 体系结构:
>sudozypper install grub2-ppc64le-ieee1275
注意:PXE 服务器如何向与自身体系结构不同的客户端提供 GRUB 2 软件包无论 PXE 服务器所在计算机使用的是哪种体系结构,GRUB 2 各体系结构专用的 noarch.rpm 软件包均包含在安装媒体/储存库的
noarch子目录中。例如,可在运行于 AMD64/Intel 64 计算机上的 PXE 服务器上,安装 grub2-arm64-efi 和 grub2-powerpc-ieee1275 软件包,以支持其他体系结构的客户端。(可选)如果需要为 AMD64/Intel 64 或 AArch64 启用 UEFI 安全引导,但不希望使用安装媒体 ISO 中的文件,可安装 shim 软件包。
>sudozypper install shim(可选)如果希望将 PXE 服务器用作路由器(不推荐用于生产环境网络),可安装路由器通告守护程序 radvd。
>sudozypper install radvd安装 rsync 实用程序,以便便捷地复制或同步 ISO 和目录树。
>sudozypper install rsync确保服务已安装但尚未启动。后续章节将介绍具体配置。
4 为 PXE 服务器创建 GRUB 2 网络引导目录 #
本章介绍如何使用 grub2-mknetdir 命令为 PXE 服务器创建 GRUB 2 网络引导目录,该命令会为 AMD64/Intel 64(UEFI 和 BIOS)、AArch64 和 ppc64le 系统生成体系结构专用目录。如果需要支持 UEFI 安全引导,管理员必须从安装媒体复制已签名的 EFI 文件,或使用 shim 软件包替换默认的未签名引导加载程序文件。
4.1 简介 #
本章介绍如何为多体系结构 PXE 服务器部署设置 GRUB 2 网络引导目录。grub2-mknetdir 命令会在 /srv/tftpboot/boot/grub2/ 下为不同平台创建体系结构专用目录。例如,AMD64/Intel 64 系统会生成 UEFI (x86_64-efi) 和传统 BIOS (i386-pc) 目录,AArch64 和 ppc64le 系统会创建各自的 UEFI 目录(arm64-efi 和 powerpc-ieee1275)。
默认的未签名 core.efi 文件不支持 UEFI 安全引导,如果需要支持此功能,管理员可从安装媒体复制已签名的 EFI 文件,或安装 shim 软件包并手动将所需的引导加载程序文件(shim.efi、grub.efi、MokManager.efi)复制到适当的体系结构目录,同时确保符号链接能正确解析,使所有文件均位于 TFTP 根目录内。
4.2 要求 #
已安装以下软件包:grub2、tftp,以及所有其他体系结构专用的 GRUB 2 软件包(如 grub2-x86_64-efi、grub2-i386-pc)。
已准备好用于挂载的安装媒体 (ISO),或系统上已安装 shim 软件包。可从 SUSE Customer Center 下载目标体系结构的安装媒体 (ISO)。
4.3 准备网络引导目录和 UEFI 安全引导 #
以下过程将创建 PXE 网络引导所需的 GRUB 2 目录结构,并可选择性地为多体系结构配置 UEFI 安全引导支持。
创建 GRUB 2 网络引导目录结构。
>sudogrub2-mknetdir --net-directory=/srv/tftpboot --subdir=/boot/grub2此命令会创建体系结构专用目录:
AMD64/Intel 64:
/srv/tftpboot/boot/grub2/x86_64-efi和/srv/tftpboot/boot/grub2/i386-pcAArch64:
/srv/tftpboot/boot/grub2/arm64-efippc64le:
/srv/tftpboot/boot/grub2/powerpc-ieee1275
警告请勿手动覆盖
grub2-mknetdir命令创建的grub.cfg文件。将
/srv/tftpboot/boot/grub2/目录下可用的其他体系结构无关目录(如fonts/、locale/)复制到 TFTP 服务器。AMD64/Intel 64 或 AArch64 体系结构也可使用
grub2-mknetdir命令安装的/srv/tftpboot/boot/grub2/ARCH-efi/core.efi文件进行 UEFI PXE 引导,但这些文件未签名,不支持 UEFI 安全引导。如需为支持的 AMD64/Intel 64 和 AArch64 体系结构选择性启用 UEFI 安全引导,可执行以下任一步骤:从安装媒体 ISO 复制必要文件:
挂载 ISO 映像。
>sudomount -o loop /PATH/TO/SLES.ISO /mnt复制 EFI 文件。
>sudocp -v /mnt/EFI/BOOT/*.efi /srv/tftpboot/boot/grub2/ARCH-efi/1将
ARCH-efi替换为x86_64-efi或arm64-efi(支持 UEFI 安全引导的体系结构)。卸载安装媒体 ISO。
>sudoumount /mnt
如果不希望使用安装媒体 ISO 中的文件,可使用 shim 软件包:
如果尚未安装 shim 软件包,先执行安装。
>sudozypper install shim为所需体系结构复制已签名的引导加载程序文件:
复制
shim.efi文件。对于 AMD64/Intel 64 体系结构:
>sudocp -v -p -L /usr/share/efi/x86_64/shim.efi /srv/tftpboot/boot/grub2/x86_64-efi/bootx64.efi对于 AArch64 体系结构:
>sudocp -v -p -L /usr/share/efi/aarch64/shim.efi /srv/tftpboot/boot/grub2/arm64-efi/bootaa64.efi
复制
grub.efi文件。对于 AMD64/Intel 64 体系结构:
>sudocp -v -p -L /usr/share/efi/x86_64/grub.efi /srv/tftpboot/boot/grub2/x86_64-efi/对于 AArch64 体系结构:
>sudocp -v -p -L /usr/share/efi/aarch64/grub.efi /srv/tftpboot/boot/grub2/arm64-efi/
复制
MokManager.efi文件。对于 AMD64/Intel 64 体系结构:
>sudocp -v -p -L /usr/share/efi/x86_64/MokManager.efi /srv/tftpboot/boot/grub2/x86_64-efi/对于 AArch64 体系结构:
>sudocp -v -p -L /usr/share/efi/aarch64/MokManager.efi /srv/tftpboot/boot/grub2/arm64-efi/
注意-L标志用于解析符号链接,确保文件均位于 TFTP 根目录内。
5 准备安装程序映像内容 #
本章介绍如何从 SUSE Linux Enterprise Server for SAP Applications 16.0 安装媒体中提取并整理 PXE 引导环境所需的安装程序文件。内容涵盖 .install.iso 映像和 RPM 软件包两种提取方式,并提供针对不同体系结构和安装类型的具体说明。
5.1 简介 #
SUSE Linux Enterprise Server for SAP Applications16.0 提供多种格式的安装程序文件,以支持不同的 PXE 引导场景。Agama 安装程序需要三个必要文件:内核映像 (linux)、initrd RAM 磁盘 (initrd) 和压缩根文件系统 (squashfs.img)。这些文件必须从安装媒体中提取,并整理到可通过 TFTP 和 HTTP 访问的目录结构中。
本章将介绍从 .install.iso 映像和 RPM 软件包中提取文件的方法,确保适配 SUSE Linux Enterprise Server for SAP Applications 16.0 支持的各种体系结构和安装类型。
5.2 要求 #
SUSE Linux Enterprise Server for SAP Applications16.0 安装媒体(可从 SUSE Customer Center 获取)。可选类型如下:
在线 ISO:仅包含安装程序,用于网络安装 (
SLES-16.0-Online-ARCH-BUILD.install.iso)完整 ISO:包含安装程序和安装储存库 (
SLES-16.0-Full-ARCH-BUILD.install.iso)RPM 软件包:tftpboot-agama-installer-SUSE_SLE_16_PXE-ARCH
临时挂载点(如
/mnt)。/srv/tftpboot和/srv/install目录下有充足的磁盘空间(根据所选安装方式而定)。具备创建目录和复制文件的管理员权限。
5.3 使用 ISO 映像准备安装程序文件 #
ISO 映像提供了提取安装程序文件的简便方式。以下过程涵盖在线 ISO 和完整 ISO 两种类型,适合不同体系结构。
5.3.1 使用在线 ISO 映像 #
在线 ISO 映像仅包含安装程序组件,系统安装过程中需要通过网络访问安装储存库。与 GRUB 中的 SLES-16.0 Online Installation 引导菜单项对应。
创建安装程序文件的目录结构:
>sudomkdir -p /srv/tftpboot/boot/images/SLES-16.0/ARCH/挂载在线 ISO 映像:
>sudomount -oro,loop /srv/install/iso/SLES-16.0-Online-ARCH-BUILD.install.iso /mnt复制内核和 initrd 文件:
>sudocp /mnt/boot/ARCH/loader/linux /srv/tftpboot/boot/images/SLES-16.0/ARCH/>sudocp /mnt/boot/ARCH/loader/initrd /srv/tftpboot/boot/images/SLES-16.0/ARCH/复制压缩根文件系统:
>sudocp /mnt/LiveOS/squashfs.img /srv/tftpboot/boot/images/SLES-16.0/ARCH/卸载 ISO 映像:
>sudoumount /mnt
创建目录结构:
>sudomkdir -p /srv/tftpboot/boot/images/SLES-16.0/ppc64le/挂载 ISO 映像:
>sudomount -oro,loop /srv/install/iso/SLES-16.0-Online-ppc64le-BUILD.install.iso /mnt复制内核和 initrd 文件(注意 ppc64le 体系结构的路径结构不同):
>sudocp /mnt/boot/ppc64le/linux /srv/tftpboot/boot/images/SLES-16.0/ppc64le/>sudocp /mnt/boot/ppc64le/initrd /srv/tftpboot/boot/images/SLES-16.0/ppc64le/复制压缩根文件系统:
>sudocp /mnt/LiveOS/squashfs.img /srv/tftpboot/boot/images/SLES-16.0/ppc64le/卸载 ISO 映像:
>sudoumount /mnt
5.3.2 使用完整 ISO 映像 #
完整 ISO 映像包含安装程序和安装储存库,无需依赖外部网络即可完成本地安装。与 GRUB 中的 SLES-16.0 Local Installation 引导菜单项对应,需要额外添加参数 inst.install_url=http://pxe.example.net/install/SLES-16.0/${arch}。
为安装程序文件和安装储存库创建目录:
>sudomkdir -p /srv/tftpboot/boot/images/SLES-16.0/ARCH/>sudomkdir -p /srv/install/SLES-16.0挂载完整 ISO 映像:
>sudomount -oro,loop /srv/install/iso/SLES-16.0-Full-ARCH-BUILD.install.iso /mnt复制内核和 initrd 文件(ppc64le 体系结构路径需按前文所述过程调整):
>sudocp /mnt/boot/ARCH/loader/linux /srv/tftpboot/boot/images/SLES-16.0/ARCH/>sudocp /mnt/boot/ARCH/loader/initrd /srv/tftpboot/boot/images/SLES-16.0/ARCH/复制压缩根文件系统:
>sudocp /mnt/LiveOS/squashfs.img /srv/tftpboot/boot/images/SLES-16.0/ARCH/复制安装储存库,供本地 HTTP 服务器访问:
>sudorsync -avP /mnt/install/ /srv/install/SLES-16.0/ARCH/卸载 ISO 映像:
>sudoumount /mnt
5.4 使用 RPM 软件包准备安装程序文件 #
RPM 软件包提供了获取在线安装程序文件的另一种方式。
安装所需的软件包:
>sudozypper in tftpboot-agama-installer-SUSE_SLE_16-ARCH将 linux、initrd、squashfs.img 复制到 tftpboot 中:
>sudomkdir -p /srv/tftpboot/boot/images/SLES-16.0/ARCH>sudocd /srv/tftpboot/boot/images/SLES-16.0/ARCH>sudocp -v /usr/share/tftpboot-installation/agama-installer-SUSE_SLE_16/ARCH/loader/linux .>sudocp -v /usr/share/tftpboot-installation/agama-installer-SUSE_SLE_16/ARCH/loader/initrd .>sudocp -v /usr/share/tftpboot-installation/agama-installer-SUSE_SLE_16/ARCH/loader/squashfs.img .
5.5 推荐的目录结构 #
按以下目录结构整理提取的文件,以确保一致性和可维护性。该结构支持多种体系结构和安装类型。
/srv/tftpboot/ ├── boot/ │ ├── grub2/ │ │ ├── x86_64-efi/ │ │ │ ├── bootx64.efi │ │ │ └── grub.cfg │ │ ├── i386-pc/ │ │ │ └── core.0 │ │ ├── arm64-efi/ │ │ │ └── bootaa64.efi │ │ └── powerpc-ieee1275/ │ │ └── core.elf │ └── images/ │ └── SLES-16.0/ │ ├── x86_64/ │ │ ├── linux 1 │ │ ├── initrd 2 │ │ └── squashfs.img 3 │ ├── aarch64/ │ └── ppc64le/ /srv/install/ └── SLES-16.0/ ├── x86_64/ 4 ├── aarch64/ └── ppc64le/
5.6 验证安装 #
提取并整理安装程序文件后,需要验证所有必需组件是否存在且可访问。
检查必要文件是否存在:
>ls -la /srv/tftpboot/boot/images/SLES-16.0/ARCH/*确保文件权限正确无误:
>sudofind /srv/tftpboot/boot/images/ -type d -exec chmod 0755 {} \;>sudofind /srv/tftpboot/boot/images/ -type f -exec chmod 0644 {} \;
确保所有提取的文件均可被 TFTP 和 HTTP 服务读取。PXE 客户端会在引导过程中访问这些文件,因此正确的权限和服务配置对部署成功至关重要。
5.7 后续步骤 #
正确准备并整理安装程序文件后,可继续执行以下操作:
配置 GRUB 2 以支持 PXE 引导,在菜单项中引用这些文件
设置 HTTP 和 TFTP 服务,以提供提取的内容
配置 DHCP,引导 PXE 客户端使用适当的引导加载程序
GRUB 2 配置中将通过类似 root=live:http://pxe.example.net/boot/images/SLES-16.0/ARCH/squashfs.img 的路径引用提取的文件。
6 配置 GRUB 2 以支持 PXE 引导 #
本章介绍如何在 SUSE Linux Enterprise Server for SAP Applications 16.0 上配置 GRUB 2 引导加载程序以支持 PXE 引导。内容包括创建网络引导目录结构、设置体系结构专用引导加载程序,以及实现支持多体系结构和多种安装场景的灵活配置系统。
6.1 简介 #
GRUB 2 作为 PXE 客户端的网络引导加载程序,负责加载内核和 initrd 文件以启动 Agama 安装程序。本章将演示如何创建功能完善的 GRUB 2 配置:可自动检测客户端体系结构、管理网络接口选择,并提供支持多种安装类型和目标体系结构的统一引导菜单。
该配置采用模块化设计,将体系结构检测、变量定义和引导菜单项分别存储在不同文件中。这样既支持针对特定计算机的配置,也支持自动化安装配置文件,同时又能在不同硬件平台间保持一致性。
6.2 要求 #
已按前文章节所述设置好 GRUB 2 网络引导目录结构。
已按前文章节所述正确整理安装程序文件。
已安装所有目标体系结构的 GRUB 2 软件包:grub2-x86_64-efi、grub2-i386-pc、grub2-aarch64-efi 和 grub2-ppc64le-ieee1275。
已安装用于提供 UEFI 安全引导支持的 shim 软件包(可选)。
具备对
/srv/tftpboot或等效 PXE 根目录的管理员访问权限。
6.3 创建 GRUB 2 配置 #
GRUB 2 配置文件主要负责三项任务:检测客户端体系结构、管理网络接口,以及加载其他配置文件。这种模块化设计提供了很大的灵活性,可支持不同的部署场景。
grub.cfg 文件 #在
/srv/tftpboot/boot/grub2/grub.cfg路径下创建 GRUB 2 主配置文件:>sudocat > /srv/tftpboot/boot/grub2/grub.cfg << 'EOF'# Architecture detection and mapping if [ "$grub_cpu" == "i386" ]; then set arch='x86_64' elif [ "$grub_cpu" == "x86_64" ]; then set arch='x86_64' elif [ "$grub_cpu" == "arm64" ]; then set arch='aarch64' elif [ "$grub_cpu" == "powerpc" ]; then set arch='ppc64le' fi if [ "X$arch" == "X" ]; then echo "ERROR: No architecture found for ${grub_cpu}" exit else echo "Running on $arch CPU architecture" fi export arch # Network interface configuration for PXE-selected NIC # - dracut based images on SLE-16: set ipcfg="ifname=pxe0:${net_default_mac} ip=pxe0:dhcp" export ipcfg # - linuxrc installer on SLE-15: set ifcfg="ifcfg=${net_default_mac}=dhcp" export ifcfg # Define typical serial console kernel parameter #set sconsole="console=tty0 console=ttyS0,115200n8" #export sconsole # Load machine-specific configuration if available if [ -s "${config}/${net_default_mac}/grub.cfg" ]; then ## Source a host specific configuration of grub menu: source "${config}/${net_default_mac}/grub.cfg" else ## Source default grub boot menu: source "${prefix}/menu.cfg" fi EOF
- 体系结构检测
将 GRUB 2 CPU 类型映射至发行套件体系结构,使统一的菜单项可在不同硬件平台上正常工作。
- 网络接口管理
使用 GRUB 2 变量
${net_default_mac}定义${ipcfg}变量,仅在名为pxe0的 PXE 引导接口上启用 DHCP,避免多接口系统出现网络探测问题。- 工具定义
定义包含串行控制台参数的典型
${sconsole}变量。- 针对特定计算机的配置
根据 MAC 地址加载可选的特定计算机配置文件,支持自定义特定计算机的引导参数和自动化安装配置文件。
6.5 针对特定计算机的配置 #
对于高级部署场景,可创建针对特定计算机的配置文件,以覆盖默认设置或提供自动化安装参数。
为针对特定计算机的配置创建目录:
>sudomkdir -p /srv/tftpboot/boot/config对于 MAC 地址为
aa:bb:cc:dd:ee:ff的计算机,创建特定配置:>sudomkdir -p /srv/tftpboot/boot/config/aa:bb:cc:dd:ee:ff创建针对特定计算机的
grub.cfg:>sudocat > /srv/tftpboot/boot/config/aa:bb:cc:dd:ee:ff/grub.cfg << 'EOF'# Machine-specific configuration for aa:bb:cc:dd:ee:ff set default='SLES-16.0 Full Installation' # Activate the menu-entry after 5sec timeout set timeout=5 # Use know predictable network interface name set ipcfg="ip=eno1:dhcp" # Set the autoinstall variable for this machine set autoinstall="inst.auto=http://pxe.example.net/install/profiles/aa:bb:cc:dd:ee:ff/sles16.json" export autoinstall # Load the default menu source "/boot/grub2/menu.cfg" EOF或者,也可在针对特定主机的
grub.cfg中提供自己的菜单项(例如为特定引导尝试生成):>sudocat > /srv/tftpboot/boot/config/aa:bb:cc:dd:ee:ff/grub.cfg << 'EOF'set default='SLES-16.0 Auto-Installation' set timeout=5 menuentry 'SLES-16.0 Auto-Installation' { linux /boot/images/SLES-16.0/${arch}/linux showopts root=live:http://pxe.example.net/boot/images/SLES-16.0/${arch}/squashfs.img inst.install_url=http://pxe.example.net/install/SLES-16.0/${arch} inst.auto=http://pxe.example.net/install/profiles/${net_default_mac}/sles16.json ip=eno1:dhcp initrd /boot/images/SLES-16.0/${arch}/initrd } EOF
-
default 指定自动引导的菜单项
-
timeout 设置引导超时时间(秒)
-
ipcfg 为特定硬件覆盖网络接口配置
-
autoinstall 提供针对特定计算机的自动化安装配置文件 URL
6.6 验证 GRUB 2 配置 #
创建配置文件后,需要验证设置是否正确,且所有必需文件是否就位。
检查 GRUB 2 目录结构:
>find /srv/tftpboot/boot/grub2 -type f -name "*.cfg" -o -name "*.efi" -o -name "core.*"使用 GRUB 2 工具验证配置文件语法:
>grub2-script-check /srv/tftpboot/boot/grub2/grub.cfg>grub2-script-check /srv/tftpboot/boot/grub2/menu.cfg确保文件权限正确无误:
>sudochmod -R 644 /srv/tftpboot/boot/grub2/*.cfg>sudofind /srv/tftpboot/boot/grub2 -type d -exec chmod 0755 {} \;
您需要使用实际 PXE 客户端测试 GRUB 2 配置,以确保体系结构检测和菜单功能正常。${net_default_mac} 变量仅在实际网络引导场景中可用。
6.7 GRUB 2 配置查错 #
以下是 GRUB 2 PXE 配置中常见的问题及其解决方案。每个问题均包含诊断步骤和具体解决命令。
6.7.1 体系结构检测失败 #
当 GRUB 2 无法检测到正确体系结构时,客户端可能会加载错误的二进制文件或完全无法加载。
在 GRUB 2 配置中添加调试输出,以查看检测到的值:
>sudocat >> /srv/tftpboot/boot/grub2/grub.cfg << 'EOF'# Debug architecture detection echo "Detected grub_cpu: ${grub_cpu}" echo "Mapped arch: ${arch}" sleep 3 EOF测试配置语法:
>grub2-script-check /srv/tftpboot/boot/grub2/grub.cfg如果体系结构映射不完整,则扩展检测逻辑:
>sudosed -i '/elif \[ "$grub_cpu" == "powerpc" \]/a\\nelif [ "$grub_cpu" == "riscv64" ]; then\n set arch='\''riscv64'\''\\' /srv/tftpboot/boot/grub2/grub.cfg验证体系结构专用目录是否存在:
>ls -la /srv/tftpboot/boot/grub2/
6.7.2 找不到网络接口 #
部分固件实现可能未正确设置 ${net_default_mac} 变量,导致网络配置失败。
添加调试输出,以检查网络变量:
>sudosed -i '/set ipcfg=/i\\necho "Default MAC: ${net_default_mac}"\necho "Network variables set"\nsleep 2' /srv/tftpboot/boot/grub2/grub.cfg创建备用网络配置:
>sudocat >> /srv/tftpboot/boot/grub2/grub.cfg << 'EOF'# Fallback network configuration if net_default_mac is empty if [ "X${net_default_mac}" == "X" ]; then set ipcfg="ip=dhcp" set ifcfg="ifcfg=*=dhcp" echo "WARNING: Using fallback network configuration" sleep 2 fi EOF使用特定接口测试网络配置:
>sudoecho 'set ipcfg="ip=eno1:dhcp"' > /srv/tftpboot/boot/config/test-network.cfg验证目标系统上的网络接口名称:
>ip link show
6.7.3 找不到文件路径 #
文件路径错误会导致 GRUB 2 无法加载内核和 initrd 文件,致使引导失败。
检查安装程序文件是否位于预期位置:
>find /srv/tftpboot/boot/images -name "linux" -o -name "initrd" -o -name "squashfs.img"验证能否通过 TFTP 访问引导文件:
>tftp localhost -c get /boot/grub2/grub.cfg /tmp/test-grub.cfg测试能否通过 HTTP 访问安装程序文件:
>curl -I http://localhost/boot/images/SLES-16.0/x86_64/linux检查文件权限和所有权:
>ls -la /srv/tftpboot/boot/images/SLES-16.0/*/根据需要更正权限:
>sudochmod -R 644 /srv/tftpboot/boot/images/>sudofind /srv/tftpboot/boot/images/ -type d -exec chmod 755 {} \;验证符号链接是否未被破坏:
>find /srv/tftpboot/boot/images/ -type l -exec ls -la {} \;
6.7.4 EFI 引导失败 #
EFI 和安全引导问题可能会导致引导加载程序无法初始化或身份验证失败。
验证安全引导文件是否存在:
>ls -la /srv/tftpboot/boot/grub2/x86_64-efi/*.efi检查是否已正确复制 shim(bootx64.efi 或 shim.efi)、grub.efi 和 MokManager.efi 文件:
>file /srv/tftpboot/boot/grub2/x86_64-efi/bootx64.efi验证 EFI 文件完整性:
>sha256sum /srv/tftpboot/boot/grub2/x86_64-efi/*.efi测试能否通过 TFTP 访问这些文件:
>tftp localhost -c get /boot/grub2/x86_64-efi/bootx64.efi /tmp/test-shim.efi对于 aarch64 系统,验证 ARM64 EFI 文件:
>ls -la /srv/tftpboot/boot/grub2/arm64-efi/*.efi检查 DHCP 配置是否提供了正确的引导加载程序路径:
>grep -n "bootx64.efi\|shim.efi\|bootaa64.efi" /etc/dnsmasq.d/dhcp.conf /etc/kea/kea-dhcp?.conf /etc/dhcpd?.conf如果文件缺失,从挂载到 /mnt 的 ISO 或 shim 软件包文件中重新复制相应文件:
>sudocp -v /mnt/EFI/BOOT/*.efi /srv/tftpboot/boot/grub2/x86_64-efi/>sudocp -pL /usr/share/efi/x86_64/*.efi /srv/tftpboot/boot/grub2/x86_64-efi/
6.7.6 启用详细日志记录 #
对于持续存在的问题,可启用全面日志记录,以捕获引导过程的详细信息。
创建主配置的调试版本:
>sudocp /srv/tftpboot/boot/grub2/grub.cfg /srv/tftpboot/boot/grub2/grub.cfg.backup添加全面的调试输出:
>sudocat > /srv/tftpboot/boot/grub2/debug.cfg << 'EOF'# Debug configuration for GRUB troubleshooting set debug=all set pager=1 echo "=== GRUB Debug Information ===" echo "grub_cpu: ${grub_cpu}" echo "grub_platform: ${grub_platform}" echo "net_default_mac: ${net_default_mac}" echo "net_default_server: ${net_default_server}" echo "=============================" sleep 5 EOF在主文件中包含调试配置:
>sudosed -i '1i\source "${prefix}/debug.cfg"' /srv/tftpboot/boot/grub2/grub.cfg在引导尝试期间监控 TFTP 日志:
>sudo journalctl -f -u tftp.socket监控 DHCP 日志中的 PXE 请求:
>sudo journalctl -f -u dhcpd完成查错后禁用调试模式:
>sudosed -i '/source "${prefix}\/debug.cfg"/d' /srv/tftpboot/boot/grub2/grub.cfg
6.8 后续步骤 #
正确配置 GRUB 2 后,可继续执行以下操作:
配置 HTTP 和 TFTP 服务,以提供引导文件和安装程序内容
设置 DHCP 服务,引导 PXE 使用适当的引导加载程序
在目标硬件上测试完整的 PXE 引导过程
灵活的 GRUB 2 配置系统通过统一界面支持多种体系结构和安装类型,为复杂的 PXE 部署场景奠定了基础。
7 配置 TFTP 以支持 PXE 引导 #
本章介绍如何配置 TFTP 服务,以提供安装 SUSE Linux Enterprise Server for SAP Applications 16.0 时所需的 GRUB 2 引导加载程序和 PXE 引导内容。内容涵盖传统的 in.tftpd 服务器和 dnsmasq 提供的集成 TFTP 功能。
7.1 简介 #
TFTP 可在网络引导过程中向 PXE 客户端提供引导加载程序文件。SUSE Linux Enterprise Server for SAP Applications 16.0 支持两种 TFTP 服务器实现:tftp 软件包提供的传统 in.tftpd 服务器,以及 dnsmasq 中集成的 TFTP 功能。
7.2 要求 #
已安装 tftp 软件包或 dnsmasq 软件包
已在
/srv/tftpboot下整理好 PXE 引导文件具备配置服务的管理员权限
7.3 配置 in.tftpd 服务器 #
in.tftpd 服务器使用 /etc/sysconfig/tftp 配置文件定义 TFTP 根目录和服务器选项。
(可选)通过设置 TFTP 选项启用详细日志记录:
>sudosed -i 's/^TFTP_OPTIONS=.*/TFTP_OPTIONS="-v"/' /etc/sysconfig/tftp-v选项会启用详细日志记录,可用于查看通过 TFTP 获取的文件名。启用并启动 TFTP 服务:
>sudosystemctl enable --now tftp.service
7.4 配置 dnsmasq TFTP 服务器 #
dnsmasq 提供内置的 TFTP 服务器,后者可启用并配置为使用 /srv/tftpboot 目录。
创建 TFTP 配置文件:
>sudocat > /etc/dnsmasq.d/tftp.conf << 'EOF'enable-tftp tftp-root=/srv/tftpboot EOF启用并启动 dnsmasq 服务:
>sudosystemctl enable --now dnsmasq
7.5 验证 TFTP 配置 #
测试 TFTP 服务器功能,确保其能向 PXE 客户端提供文件。
创建测试文件:
>echo "test file" | sudo tee /srv/tftpboot/test.txt通过 TFTP 检索测试文件:
>tftp localhost -c get test.txt /tmp/tftp-test.txt验证是否成功检索了文件:
>cat /tmp/tftp-test.txt清理测试文件:
>sudorm /srv/tftpboot/test.txt /tmp/tftp-test.txt
7.6 TFTP 配置查错 #
以下是为 PXE 引导环境配置 TFTP 服务时常见的问题。
7.6.1 端口 69 上的服务冲突 #
in.tftpd 和 dnsmasq 均使用 UDP 69 端口提供 TFTP 服务,因此不能同时运行。
检查哪些服务正在运行:
>systemctl status tftp.service dnsmasq检查哪些进程在使用 69 端口:
>ss -ulnp | grep :69停止冲突的服务(以 dnsmasq 为例):
>sudosystemctl stop dnsmasq启动您首选的 TFTP 服务:
>sudosystemctl start tftp.service
7.6.2 TFTP 目录问题 #
无法访问 TFTP 根目录会导致无法提供文件。
验证 in.tftpd 的 TFTP 目录设置:
>grep TFTP_DIRECTORY /etc/sysconfig/tftp验证 dnsmasq 的 TFTP 目录设置:
>grep tftp-root /etc/dnsmasq.d/tftp.conf检查目录是否存在:
>ls -la /srv/tftpboot/如果目录缺失,则创建目录:
>sudomkdir -p /srv/tftpboot
7.6.3 启用 TFTP 日志记录 #
详细日志记录有助于找出 TFTP 传输中的文件访问问题。
检查当前的 TFTP 选项:
>grep TFTP_OPTIONS /etc/sysconfig/tftp启用详细日志记录:
>sudosed -i 's/^TFTP_OPTIONS=.*/TFTP_OPTIONS="-v"/' /etc/sysconfig/tftp重启 TFTP 服务:
>sudosystemctl restart tftp.service监控 TFTP 日志:
>journalctl -u tftp.service -f
7.7 后续步骤 #
TFTP 配置完毕后,可继续配置 HTTP 服务以提供安装程序文件,以及配置 DHCP 服务以引导 PXE 客户端使用适当的引导加载程序。
8 配置 nginx 以实现 HTTP 分发 #
本章介绍如何配置 nginx,以通过 HTTP 提供 PXE 引导内容,使客户端能从某个集中位置加载内核、initrd、squashfs 映像等安装程序文件。HTTP 分发大型文件的性能比 TFTP 好,使用 Agama 安装 SUSE Linux Enterprise Server for SAP Applications 16.0 时需要启用该功能。
8.1 简介 #
nginx 作为 PXE 引导环境的 HTTP 服务器,通过 Web 方式提供安装程序文件访问途径。HTTP 服务器会公开 TFTP 引导目录和安装储存库,使 PXE 客户端能通过 HTTP(而非传输速度较慢的 TFTP 协议)下载内核映像、initrd 文件和 Agama 安装程序组件。
8.2 要求 #
已安装 nginx 软件包
已在
/srv/tftpboot/boot下整理好 PXE 引导文件已在
/srv/install下准备好安装储存库具备修改 nginx 配置的管理员权限
8.3 配置 nginx 以支持 PXE 引导 #
nginx 配置通过定义位置别名,通过 HTTP URL 将 TFTP 引导目录和安装储存库向客户端公开。
编辑 nginx 配置文件:
>sudovim /etc/nginx/nginx.conf在
http部分中配置 HTTP 服务器块:>sudocat > /etc/nginx/nginx.conf << 'EOF'http { include mime.types; default_type application/octet-stream; charset utf-8; sendfile on; keepalive_timeout 65; server { listen 80 default_server; listen [::]:80 default_server; location / { root /srv/www/htdocs/; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /srv/www/htdocs/; } # Expose TFTP boot directory for HTTP boot location /boot { alias /srv/tftpboot/boot; autoindex on; } # Expose installation repositories and profiles location /install { alias /srv/install; autoindex on; } } } events { worker_connections 1024; } EOF测试 nginx 配置语法:
>sudonginx -t启用并启动 nginx 服务:
>sudosystemctl enable --now nginx.service
8.4 验证 nginx 配置 #
测试 HTTP 服务器功能,确保其能向客户端提供 PXE 引导文件和安装内容。
测试能否通过 HTTP 访问引导文件:
>curl -I http://localhost/boot/测试能否访问安装目录:
>curl -I http://localhost/install/验证特定安装程序文件是否可访问:
>curl -I http://localhost/boot/images/SLES-16.0/x86_64/liveiso/LiveOS/squashfs.img
8.5 nginx 配置查错 #
以下是配置 nginx 以实现 PXE 引导 HTTP 分发时常见的问题。
8.5.1 配置语法错误 #
不正确的 nginx 配置语法会导致服务无法正常启动或重新加载。
测试配置语法:
>sudonginx -t如果 nginx 服务启动失败,则检查其状态:
>systemctl status nginx.service查看详细错误日志:
>journalctl -u nginx.service -f检查 nginx 错误日志文件:
>tail -f /var/log/nginx/error.log
8.5.2 文件访问和权限问题 #
nginx 可能会因权限错误或目录缺失而无法提供文件。
检查引导目录是否存在且可访问:
>ls -la /srv/tftpboot/boot/检查安装目录是否存在:
>ls -la /srv/install/验证 nginx 能否读取这些目录:
>sudo -u nginx ls /srv/tftpboot/boot/如果目录缺失,则创建目录:
>sudomkdir -p /srv/install设置适当的权限:
>sudochmod -R 755 /srv/tftpboot/boot /srv/install
8.5.3 端口绑定冲突 #
如果其他服务占用了 80 端口,nginx 将无法启动。
检查哪些进程在使用 80 端口:
>ss -tlnp | grep :80根据需要停止冲突的服务:
>sudosystemctl stop apache2启动 nginx 服务:
>sudosystemctl start nginx.service验证 nginx 是否在 80 端口侦听:
>ss -tlnp | grep :80
8.6 后续步骤 #
为实现 HTTP 分发完成 nginx 配置后,可继续配置 DHCP 服务,以引导 PXE 客户端使用适当的引导加载程序和 HTTP 资源。
9 使用 dnsmasq 配置 DNS 服务器 #
本章介绍如何使用 dnsmasq 配置 DNS 服务,为访问 SUSE Linux Enterprise Server for SAP Applications 16.0 安装资源的 PXE 客户端提供主机名解析功能。DNS 配置使客户端能在引导 URL 和 DHCP 配置中使用主机名(而非 IP 地址)。
9.1 简介 #
DNS 服务使 PXE 客户端能解析引导 URL 和安装源中的主机名。虽然本文不会介绍完整的 DNS 服务器配置,但本章将提供使用 dnsmasq 的基本 DNS 配置,使客户端能将 PXE 服务器主机名 (PXE.EXAMPLE.NET) 解析为对应的 IP 地址。
如果未配置 DNS,引导 URL 必须直接使用 IP 地址(如 http://192.168.1.200/ 或 http://[2001:db8:0:1::200]/)。部分 BIOS/UEFI 固件实现不支持在 DHCP TFTP URL 中使用主机名,需使用类似 tftp://[2001:db8:0:1::200]/ 的 IP 地址格式。
9.2 要求 #
已安装 dnsmasq 软件包
已为 PXE 服务器配置静态 IP 地址
具备配置 DNS 服务的管理员权限
9.3 配置 dnsmasq DNS 服务 #
dnsmasq DNS 配置提供本地主机名解析功能,并使用上游名称服务器处理外部查询。
为 dnsmasq 创建 DNS 配置文件:
>sudocat > /etc/dnsmasq.d/dns.conf << 'EOF'# DNS configuration file for dnsmasq # Log DNS queries log-queries # DNS cache behavior cache-size=10000 local-ttl=60 neg-ttl=10 # Never forward A or AAAA queries for plain names to upstream name servers domain-needed # Add local domain to simple names in /etc/hosts and DHCP expand-hosts # Specifies DNS domain and networks including local forward and reverse declarations domain=EXAMPLE.NET,192.168.1.0/24,local domain=EXAMPLE.NET,2001:db8:0:1::/64,local EOF在系统 hosts 文件中添加主机名条目:
>sudocat >> /etc/hosts << 'EOF'192.168.1.200 PXE.EXAMPLE.NET 2001:db8:0:1::200 PXE.EXAMPLE.NET EOF测试 dnsmasq 配置:
>sudodnsmasq --test启用并启动 dnsmasq 服务:
>sudosystemctl enable --now dnsmasq
默认情况下,dnsmasq 会将 /etc/resolv.conf 中的名称服务器用作转发器,并提供从 /etc/hosts 中获取的记录。这种配置使 PXE 服务器既能解析外部主机名,又能为 PXE 相关服务提供本地解析。
9.4 验证 DNS 配置 #
测试 DNS 服务器功能,确保 PXE 客户端能正常进行主机名解析。
测试 IPv4 主机名解析:
>nslookup PXE.EXAMPLE.NET localhost测试 IPv6 主机名解析:
>nslookup PXE.EXAMPLE.NET localhost | grep 2001:db8测试 IPv4 反向 DNS 查询:
>nslookup 192.168.1.200 localhost验证外部 DNS 转发是否仍正常工作:
>nslookup google.com localhost
9.5 DNS 配置查错 #
以下是为 PXE 环境配置 dnsmasq DNS 服务时常见的问题。
9.5.1 配置和服务问题 #
dnsmasq 可能会因配置错误或端口冲突而无法启动。
测试 dnsmasq 配置语法:
>sudodnsmasq --test检查 dnsmasq 服务状态:
>systemctl status dnsmasq检查哪些进程在使用 DNS 53 端口:
>ss -ulnp | grep :53查看 dnsmasq 错误日志:
>journalctl -u dnsmasq -f根据需要停止冲突的 DNS 服务:
>sudosystemctl stop systemd-resolved
9.5.2 主机名解析失败 #
DNS 查询可能会因配置错误或主机名条目缺失而失败。
检查 hosts 文件中是否存在主机名条目:
>grep PXE.EXAMPLE.NET /etc/hosts验证 dnsmasq 中的域名配置:
>grep domain= /etc/dnsmasq.d/dns.conf以详细输出模式测试 DNS 查询:
>dig @localhost PXE.EXAMPLE.NET监控 dnsmasq 查询日志:
>journalctl -u dnsmasq | grep "query"重启 dnsmasq 以重新加载配置:
>sudosystemctl restart dnsmasq
9.5.3 DNS 转发问题 #
如果上游名称服务器配置错误,外部 DNS 查询可能会失败。
检查上游名称服务器配置:
>cat /etc/resolv.conf尝试直接向上游名称服务器发送查询:
>nslookup google.com 8.8.8.8检查 dnsmasq 转发配置:
>grep -E "server=|no-resolv" /etc/dnsmasq.d/dns.conf根据需要添加特定上游名称服务器:
>sudoecho "server=8.8.8.8" >> /etc/dnsmasq.d/dns.conf重启 dnsmasq 服务:
>sudosystemctl restart dnsmasq
9.6 后续步骤 #
DNS 服务配置完毕后,PXE 客户端现在可解析引导 URL 和安装源中的主机名。您接下来可配置引用该 DNS 服务器的 DHCP 服务,用于客户端配置。
10 使用 chrony 配置 NTP 服务器 #
本章介绍如何使用 chrony 配置 NTP 服务,以在 SUSE Linux Enterprise Server for SAP Applications 16.0 安装过程中为 PXE 客户端提供精准的时间同步。在基于网络的安装过程中,正确的时间同步对证书验证和系统日志记录至关重要。
10.1 简介 #
NTP 服务可确保网络基础架构中的时间精准同步。在 PXE 引导环境中,同步的时间对 HTTPS 连接期间的证书验证、正确的日志时间戳以及协调的系统操作都至关重要。本章将介绍如何使用 chrony 进行基本的 NTP 服务器配置。
10.2 要求 #
已安装 chrony 软件包
>sudozypper install chrony能通过网络连接到上游 NTP 服务器
具备配置 NTP 服务的管理员权限
10.3 配置 chrony NTP 服务 #
chrony 服务具备 NTP 功能,既能够自动与上游服务器实现时间同步,又拥有为网络客户端提供本地时间服务的能力。
chrony NTP 服务器 #启用并启动
chrony服务:>sudosystemctl enable --now chronyd.service
10.4 验证 NTP 配置 #
测试 NTP 服务功能,确保时间同步正常工作。
检查
chrony服务状态:>systemctl status chronyd.service查看当前时间同步状态:
>chronyc tracking列出已配置的 NTP 源:
>chronyc sources查看 NTP 服务器统计信息:
>chronyc sourcestats
10.5 NTP 配置查错 #
以下是为 PXE 环境配置 chrony NTP 服务时常见的问题。
10.5.1 服务启动问题 #
chrony 服务可能会因配置错误或网络连接问题而无法启动。
检查
chrony服务状态和日志:>systemctl status chronyd.service查看详细服务日志:
>journalctl -u chronyd.service -f测试
chrony配置:>sudochronyd -Q根据需要重启服务:
>sudosystemctl restart chronyd.service
10.5.2 时间同步失败 #
时间同步可能会因网络问题或服务器配置错误而失败。
查看当前同步状态:
>chronyc tracking查看 NTP 源连接情况:
>chronyc sources -v强制立即同步:
>sudochronyc makestep检查系统时间与硬件时钟是否一致:
>timedatectl status验证与 NTP 服务器的网络连接:
>chronyc activity
10.5.3 防火墙和网络问题 #
防火墙规则可能会阻止 NTP 流量,导致时间同步失败。
检查防火墙中的 NTP 端口是否开放:
>firewall-cmd --list-services | grep ntp根据需要将 NTP 服务添加到防火墙:
>sudofirewall-cmd --permanent --add-service=ntp重新加载防火墙配置:
>sudofirewall-cmd --reload手动测试 NTP 连接情况:
>ntpdate -q pool.ntp.org检查
chrony端口使用情况:>ss -ulnp | grep :123
10.6 后续步骤 #
NTP 服务配置完毕后,PXE 服务器与客户端的时间将保持精准同步。这可确保在基于网络的安装过程中,能正常进行证书验证和系统操作协调。
11 配置 IPv6 路由器通告 #
本章介绍如何配置 IPv6 路由器通告 (RA) 功能,以便为 PXE 客户端提供充足的路由器通告。IPv6 RA 可实现 IPv6 路由配置和有状态 DHCPv6 地址自动配置,以支持 SUSE Linux Enterprise Server for SAP Applications 16.0 安装。
11.1 简介 #
IPv6 路由器通告 (RA) 会向 PXE 客户端提供关键的网络配置信息,包括 IPv6 路由和 DHCPv6 地址自动配置设置。本章假设已完成 IPv6 路由器的配置 - 该路由器会发送充足的路由器通告,以完成以下两项任务:一是配置到目标网络的 IPv6 路由及默认路由;二是通过设置 AdvManagedFlag on,启用有状态 DHCPv6 地址自动配置功能。
11.2 要求 #
已安装 radvd 软件包
服务器接口已完成 IPv6 网络配置
具备配置路由器通告服务的管理员权限
11.3 配置 radvd 以支持 IPv6 路由器通告 #
radvd 服务通过 /etc/radvd.conf 中定义的配置提供 IPv6 路由器通告功能。
radvd IPv6 路由器通告 #配置
radvd服务:>sudocat > /etc/radvd.conf << 'EOF'interface eno1 { # radvd options IgnoreIfMissing on; # Do not fail and exit when interface is missed AdvSendAdvert on; # Sending RAs on the interface is not disabled # Configuration settings AdvManagedFlag on; # Request IPv6 address and dns options via DHCPv6 AdvOtherConfigFlag off; # Request only dns info via DHCPv6, IP via SLAAC AdvDefaultLifetime 1800; # Add default route via this router for 1800sec prefix 2001:db8:0:1::/64 # Add direct route for this local network/prefix { AdvAutonomous off; # Assign IPv6 address via SLAAC AdvValidLifetime 7200; AdvPreferredLifetime 3600; }; }; EOF启用并启动
radvd服务:>sudosystemctl enable --now radvd
11.4 验证 IPv6 路由器通告 #
测试 IPv6 RA 功能,确保其配置正确且运行正常。
检查
radvd服务状态:>systemctl status radvd使用
ravdump查看并验证 IPv6 RA 设置>radvdumpradvdump实用程序会显示 IPv6 路由器每隔几分钟发送的 IPv6 RA 设置。
11.5 为路由器功能配置 IP 转发 #
如果 PXE 服务器同时作为路由器,则必须启用 IP 转发以使其具备路由器功能。
创建网络配置文件:
>sudocat > /etc/sysctl.d/90-network.conf << 'EOF'# This machine is a router net.ipv4.conf.all.forwarding = 1 net.ipv6.conf.all.forwarding = 1 # Accept host autoconf on router uplink net.ipv6.conf.uplink.accept_ra = 2 EOF应用网络配置设置:
>sudosysctl -p /etc/sysctl.d/90-network.conf
默认情况下,路由器不会处理用于主机自动配置的 IPv6 RA。如果要在路由器上行接口上接受 IPv6 RA,需要指定 accept_ra = 2 sysctl 设置。有关路由器配置的更多详细信息(包括防火墙调整和其他必要步骤),请参见《管理指南》中的“网络配置”章节。
11.6 IPv6 路由器通告查错 #
以下是为 PXE 环境配置 IPv6 路由器通告时常见的问题。
11.6.1 radvd 服务问题 #
radvd 服务可能会因配置错误或接口问题而无法启动。
radvd 服务问题 #检查
radvd服务状态和日志:>systemctl status radvd查看详细服务日志:
>journalctl -u radvd -f测试
radvd配置语法:>sudoradvd -C /etc/radvd.conf检查指定接口是否存在:
>ip link show eno1修复配置后重启服务:
>sudosystemctl restart radvd
11.6.2 IP 转发配置问题 #
不正确的 IP 转发设置会导致路由器功能无法正常工作。
检查当前 IP 转发状态:
>sysctl net.ipv4.conf.all.forwarding检查 IPv6 转发状态:
>sysctl net.ipv6.conf.all.forwarding验证 sysctl 配置文件:
>cat /etc/sysctl.d/90-network.conf如果值不正确,应用配置:
>sudosysctl -p /etc/sysctl.d/90-network.conf检查上行接口的 accept_ra 设置:
>sysctl net.ipv6.conf.uplink.accept_ra
11.6.3 路由器通告接收问题 #
客户端可能无法正确接收或处理 IPv6 路由器通告。
使用
ravdump监控路由器通告:>radvdump -d检查客户端上的 IPv6 接口配置:
>ip -6 addr show验证客户端上的 IPv6 路由表:
>ip -6 route show测试与路由器的 IPv6 连接:
>ping6 2001:db8:0:1::1检查防火墙的 ICMPv6 规则:
>firewall-cmd --list-protocols | grep ipv6-icmp
11.7 后续步骤 #
IPv6 路由器通告配置完毕后,PXE 客户端便可获取正确的 IPv6 网络配置。这一配置不仅能实现 DHCPv6 功能,还能为基于网络的安装提供 IPv6 连接能力。
12 使用 dnsmasq 配置 DHCP 服务器 #
本章介绍如何使用 dnsmasq 配置 DHCP 服务,以提供安装 SUSE Linux Enterprise Server for SAP Applications 16.0 时所需的网络配置和 PXE 引导信息。dnsmasq DHCP 服务器采用基于标签的配置,支持具备 UEFI 和 BIOS 引导能力的 IPv4 和 IPv6 PXE 客户端。
12.1 简介 #
dnsmasq DHCP 服务器通过基于标签的系统来匹配客户端类型和提供适当的引导加载程序,为 PXE 客户端提供网络配置和引导文件信息。此配置支持对 DHCPv4 和 DHCPv6 生效的 PXEClient 和 HTTPClient 匹配规则,可在多体系结构系统上实现 UEFI 和 BIOS 引导。
dnsmasq 2.90 及更早版本不支持向 DHCPv6 客户端返回用于 HTTPClient 配置的 6:16 供应商类别选项。如果需要完整的 HTTPClient 支持,建议使用 Kea 或 ISC DHCP 服务器。
12.2 要求 #
已安装 dnsmasq 软件包
已在
/srv/tftpboot下正确整理 PXE 引导文件已为 DHCP 服务配置网络接口
具备配置 DHCP 服务的管理员权限
12.3 配置 dnsmasq DHCP 服务 #
dnsmasq DHCP 配置包括客户端类型匹配、网络范围,以及为 IPv4 和 IPv6 网络分配引导文件。
为 dnsmasq 创建 DHCP 配置文件:
>sudocat > /etc/dnsmasq.d/dhcp.conf << 'EOF'# DHCP configuration file for dnsmasq # Log DHCP processing log-dhcp # This is the only DHCP server, don't ignore unknown clients/send NAK dhcp-authoritative # Disable re-use of the DHCPv4 servername and filename fields as extra # option space, which may confuse old or broken clients dhcp-no-override # IPv4 PXE/HTTP boot client matches (no enterprise number) # Match client type in PXEClient:Arch and map to a tag dhcp-vendorclass=set:tftp_bios_x86_pc,PXEClient:Arch:00000 dhcp-vendorclass=set:tftp_uefi_x86_64,PXEClient:Arch:00007 dhcp-vendorclass=set:tftp_ieee_ppc_64,PXEClient:Arch:0000e dhcp-vendorclass=set:tftp_uefi_arm_64,PXEClient:Arch:00011 # Match client type in HTTPClient:Arch and map to a tag dhcp-vendorclass=set:http_uefi_x86_64,HTTPClient:Arch:00016 dhcp-vendorclass=set:http_uefi_arm_64,HTTPClient:Arch:00019 # IPv6 PXE/HTTP boot client matches (enterprise:343 intel) # Match client type in PXEClient:Arch and map to a tag dhcp-vendorclass=set:tftp_bios_x86_pc,enterprise:343,PXEClient:Arch:00000 dhcp-vendorclass=set:tftp_uefi_x86_64,enterprise:343,PXEClient:Arch:00007 dhcp-vendorclass=set:tftp_ieee_ppc_64,enterprise:343,PXEClient:Arch:0000e dhcp-vendorclass=set:tftp_uefi_arm_64,enterprise:343,PXEClient:Arch:00011 # Match client type in HTTPClient:Arch and map to a tag dhcp-vendorclass=set:http_uefi_x86_64,enterprise:343,HTTPClient:Arch:00016 dhcp-vendorclass=set:http_uefi_arm_64,enterprise:343,HTTPClient:Arch:00019 EOF配置 IPv4 DHCP 范围和选项:
>sudocat >> /etc/dnsmasq.d/dhcp.conf << 'EOF'# IPv4 range and options dhcp-range=set:net0v4,192.168.1.100,192.168.1.199,255.255.255.0,1h dhcp-option=tag:net0v4,option:domain-search,example.net dhcp-option=tag:net0v4,option:dns-server,192.168.1.200 dhcp-option=tag:net0v4,option:ntp-server,192.168.1.1 dhcp-option=tag:net0v4,option:router,192.168.1.1 EOF配置 IPv4 PXE 引导选项:
>sudocat >> /etc/dnsmasq.d/dhcp.conf << 'EOF'# IPv4 PXEClient boot dhcp-boot=tag:net0v4,tag:tftp_bios_x86_pc,/boot/grub2/i386-pc/core.0,192.168.1.200 dhcp-boot=tag:net0v4,tag:tftp_uefi_x86_64,/boot/grub2/x86_64-efi/bootx64.efi,192.168.1.200 dhcp-boot=tag:net0v4,tag:tftp_ieee_ppc_64,/boot/grub2/powerpc-ieee1275/core.elf,192.168.1.200 dhcp-boot=tag:net0v4,tag:tftp_uefi_arm_64,/boot/grub2/arm64-efi/bootaa64.efi,192.168.1.200 # IPv4 HTTPClient boot dhcp-option-force=tag:net0v4,tag:http_uefi_x86_64,option:vendor-class,HTTPClient dhcp-boot=tag:net0v4,tag:http_uefi_x86_64,http://192.168.1.200/boot/grub2/x86_64-efi/bootx64.efi dhcp-option-force=tag:net0v4,tag:http_uefi_arm_64,option:vendor-class,HTTPClient dhcp-boot=tag:net0v4,tag:http_uefi_arm_64,http://192.168.1.200/boot/grub2/arm64-efi/bootaa64.efi EOF配置 IPv6 DHCP 范围和选项:
>sudocat >> /etc/dnsmasq.d/dhcp.conf << 'EOF'# IPv6 range and options dhcp-range=set:net0v6,2001:db8:0:1:d::,2001:db8:0:1:d::ffff,64,1h dhcp-option=tag:net0v6,option6:domain-search,example.net dhcp-option=tag:net0v6,option6:dns-server,[2001:db8:0:1::200] dhcp-option=tag:net0v6,option6:sntp-server,[2001:db8:0:1::1] EOF配置 IPv6 PXE 引导选项:
>sudocat >> /etc/dnsmasq.d/dhcp.conf << 'EOF'# IPv6 PXEClient boot dhcp-option=tag:net0v6,tag:tftp_bios_x86_pc,option6:bootfile-url,tftp://[2001:db8:0:1::200]/boot/grub2/i386-pc/core.0 dhcp-option=tag:net0v6,tag:tftp_uefi_x86_64,option6:bootfile-url,tftp://[2001:db8:0:1::200]/boot/grub2/x86_64-efi/bootx64.efi dhcp-option=tag:net0v6,tag:tftp_ieee_ppc_64,option6:bootfile-url,tftp://[2001:db8:0:1::200]/boot/grub2/powerpc-ieee1275/core.elf dhcp-option=tag:net0v6,tag:tftp_uefi_arm_64,option6:bootfile-url,tftp://[2001:db8:0:1::200]/boot/grub2/arm64-efi/bootaa64.efi # IPv6 HTTPClient boot # Note: dnsmasq <= 2.90 does not support sending vendor-class option6:16 back to client EOF测试 dnsmasq 配置:
>sudodnsmasq --test启用并启动 dnsmasq 服务:
>sudosystemctl enable --now dnsmasq
12.4 验证 DHCP 配置 #
测试 DHCP 服务器功能,确保能向 PXE 客户端提供正确的网络配置和引导文件。
检查 dnsmasq 服务状态:
>systemctl status dnsmasq验证 DHCP 端口绑定:
>ss -ulnp | grep :67监控 DHCP 租约分配:
>journalctl -u dnsmasq -f查看有效的 DHCP 租约:
>cat /var/lib/dhcp/dhcpd.leases
12.5 dnsmasq DHCP 配置查错 #
以下是为 PXE 环境配置 dnsmasq DHCP 服务时的常见问题。
12.5.1 服务启动和配置问题 #
dnsmasq 可能会因配置错误或与其他 DHCP 服务发生端口冲突而无法启动。
测试 dnsmasq 配置语法:
>sudodnsmasq --test检查是否存在 DHCP 端口冲突:
>ss -ulnp | grep :67停止冲突的 DHCP 服务:
>sudosystemctl stop dhcpd查看详细服务日志:
>journalctl -u dnsmasq -f解决冲突后重启 dnsmasq:
>sudosystemctl restart dnsmasq
12.5.2 DHCP 租约分配问题 #
客户端可能会因范围配置或网络连接问题而无法获取 IP 地址。
检查 DHCP 范围配置:
>grep dhcp-range /etc/dnsmasq.d/dhcp.conf实时监控 DHCP 请求:
>journalctl -u dnsmasq -f | grep DHCP检查网络接口状态:
>ip addr show验证 DHCP 权威服务器设置:
>grep dhcp-authoritative /etc/dnsmasq.d/dhcp.conf使用 dhcping 测试 DHCP 响应:
>dhcping -s 192.168.1.200
12.5.3 PXE 引导文件分发问题 #
PXE 客户端能获取 IP 地址,但因引导文件配置错误或客户端类型匹配问题而无法引导。
检查客户端供应商类别匹配:
>grep dhcp-vendorclass /etc/dnsmasq.d/dhcp.conf验证引导文件路径:
>grep dhcp-boot /etc/dnsmasq.d/dhcp.conf测试能否通过 TFTP 访问引导文件:
>tftp 192.168.1.200 -c get /boot/grub2/x86_64-efi/bootx64.efi监控与 PXE 相关的 DHCP 日志:
>journalctl -u dnsmasq | grep -E "PXE|HTTP"查看日志中的标签分配:
>journalctl -u dnsmasq | grep "tags:"
12.5.4 IPv6 DHCP 配置问题 #
IPv6 DHCP 客户端需要正确的路由器通告配置,且其地址配置要求可能与 IPv4 不同。
验证 IPv6 DHCP 范围配置:
>grep "2001:db8" /etc/dnsmasq.d/dhcp.conf检查 IPv6 路由器通告状态:
>systemctl status radvd监控 DHCPv6 请求:
>journalctl -u dnsmasq | grep "DHCPv6"测试 IPv6 连接:
>ping6 2001:db8:0:1::200检查 IPv6 选项配置:
>grep option6 /etc/dnsmasq.d/dhcp.conf
12.6 后续步骤 #
dnsmasq DHCP 服务配置完毕后,PXE 客户端在 IPv4 和 IPv6 环境下,均能获取网络配置和引导文件信息。基于标签的系统可根据客户端体系结构和引导方式要求,灵活分配引导文件。
13 使用 Kea 配置 DHCP 服务器 #
本章介绍如何使用 Kea 配置 DHCP 服务,以提供安装 SUSE Linux Enterprise Server for SAP Applications 16.0 时所需的网络配置和 PXE 引导信息。Kea 是一款现代化 DHCP 服务器,支持 IPv4 和 IPv6,并具备客户端类别匹配功能,可用于 PXE 和 HTTP 引导场景。
13.1 简介 #
Kea 是由 ISC 开发的现代化 DHCP 服务器,作为旧版 ISC DHCP 服务器的继任者。它对 DHCPv4 和 DHCPv6 均提供稳定支持,具备客户端分类能力,可根据客户端体系结构和引导方式提供合适的引导文件。Kea 采用基于 JSON 格式的配置文件,支持供应商类别识别等高级功能,适用于 HTTP 引导场景。
13.2 要求 #
已安装 Kea DHCP 软件包:kea-dhcp4 和 kea-dhcp6
已在
/srv/tftpboot下正确整理 PXE 引导文件已为 DHCP 服务配置网络接口
具备配置 DHCP 服务的管理员权限
13.3 配置 Kea DHCPv4 服务器 #
Kea DHCPv4 配置使用客户端类别来匹配 PXE 和 HTTP 客户端类型,并针对不同体系结构提供适当的引导文件。
配置 Kea DHCPv4 服务器:
>sudocat > /etc/kea/kea-dhcp4.conf << 'EOF'{ "Dhcp4": { "interfaces-config": { "interfaces": [ "eno1" ] }, "control-socket": { "socket-type": "unix", "socket-name": "/tmp/kea4-ctrl-socket" }, "lease-database": { "type": "memfile", "persist": true, "name": "/var/lib/kea/dhcp4.leases", "lfc-interval": 3600 }, "expired-leases-processing": { "reclaim-timer-wait-time": 10, "flush-reclaimed-timer-wait-time": 25, "hold-reclaimed-time": 3600, "max-reclaim-leases": 100, "max-reclaim-time": 250, "unwarned-reclaim-cycles": 5 }, "renew-timer": 1800, "rebind-timer": 3150, "valid-lifetime": 3600, "option-data": [], "client-classes": [ { "name": "pxeclients#00000", "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00000'", "next-server": "192.168.1.200", "boot-file-name": "/boot/grub2/i386-pc/core.0" }, { "name": "pxeclients#00007", "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00007'", "next-server": "192.168.1.200", "boot-file-name": "/boot/grub2/x86_64-efi/bootx64.efi" }, { "name": "pxeclients#0000e", "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:0000e'", "next-server": "192.168.1.200", "boot-file-name": "/boot/grub2/powerpc-ieee1275/core.elf" }, { "name": "pxeclients#00011", "test": "substring(option[60].hex,0,20) == 'PXEClient:Arch:00011'", "next-server": "192.168.1.200", "boot-file-name": "/boot/grub2/arm64-efi/bootaa64.efi" }, { "name": "httpclients#00016", "test": "substring(option[60].hex,0,21) == 'HTTPClient:Arch:00016'", "boot-file-name": "http://192.168.1.200/boot/grub2/x86_64-efi/bootx64.efi", "option-data": [ { "name": "vendor-class-identifier", "data": "HTTPClient" } ] }, { "name": "httpclients#00019", "test": "substring(option[60].hex,0,21) == 'HTTPClient:Arch:00019'", "boot-file-name": "http://192.168.1.200/boot/grub2/arm64-efi/bootaa64.efi", "option-data": [ { "name": "vendor-class-identifier", "data": "HTTPClient" } ] } ], "subnet4": [ { "id": 1, "subnet": "192.168.1.0/24", "pools": [ { "pool": "192.168.1.100 - 192.168.1.199" } ], "option-data": [ { "name": "routers", "data": "192.168.1.1" }, { "name": "ntp-servers", "data": "192.168.1.1" }, { "name": "domain-name-servers", "data": "192.168.1.200" }, { "name": "domain-search", "data": "example.net" } ], "reservations": [] } ], "loggers": [ { "name": "kea-dhcp4", "output-options": [ { "output": "/var/log/kea/dhcp4.log" } ], "severity": "INFO", "debuglevel": 0 } ] } } EOF创建 Kea 日志目录:
>sudomkdir -p /var/log/kea测试 Kea DHCPv4 配置:
>sudokea-dhcp4 -t /etc/kea/kea-dhcp4.conf启用并启动 Kea DHCPv4 服务:
>sudosystemctl enable --now kea-dhcp4
13.4 配置 Kea DHCPv6 服务器 #
Kea DHCPv6 配置通过供应商类别匹配功能针对不同客户端体系结构提供 IPv6 地址分配和引导文件信息。
配置 Kea DHCPv6 服务器:
>sudocat > /etc/kea/kea-dhcp6.conf << 'EOF'{ "Dhcp6": { "interfaces-config": { "interfaces": [ "eno1" ] }, "control-socket": { "socket-type": "unix", "socket-name": "/tmp/kea6-ctrl-socket" }, "lease-database": { "type": "memfile", "persist": true, "name": "/var/lib/kea/dhcp6.leases", "lfc-interval": 3600 }, "expired-leases-processing": { "reclaim-timer-wait-time": 10, "flush-reclaimed-timer-wait-time": 25, "hold-reclaimed-time": 3600, "max-reclaim-leases": 100, "max-reclaim-time": 250, "unwarned-reclaim-cycles": 5 }, "renew-timer": 1800, "rebind-timer": 2880, "preferred-lifetime": 3600, "valid-lifetime": 7200, "option-data": [], "option-def": [], "client-classes": [ { "name": "pxeclients#00000", "test": "substring(option[16].hex,6,20) == 'PXEClient:Arch:00000'", "option-data": [ { "name": "bootfile-url", "data": "tftp://[2001:db8:0:1::200]/boot/grub2/i386-pc/core.0" } ] }, { "name": "pxeclients#00007", "test": "substring(option[16].hex,6,20) == 'PXEClient:Arch:00007'", "option-data": [ { "name": "bootfile-url", "data": "tftp://[2001:db8:0:1::200]/boot/grub2/x86_64-efi/bootx64.efi" } ] }, { "name": "pxeclients#0000e", "test": "substring(option[16].hex,6,20) == 'PXEClient:Arch:0000e'", "option-data": [ { "name": "bootfile-url", "data": "tftp://[2001:db8:0:1::200]/boot/grub2/powerpc-ieee1275/core.elf" } ] }, { "name": "pxeclients#00011", "test": "substring(option[16].hex,6,20) == 'PXEClient:Arch:00011'", "option-data": [ { "name": "bootfile-url", "data": "tftp://[2001:db8:0:1::200]/boot/grub2/arm64-efi/bootaa64.efi" } ] } ], "subnet6": [ { "id": 1, "subnet": "2001:db8:0:1::/64", "interface": "eno1", "pools": [ { "pool": "2001:db8:0:1:d::/112" } ], "option-data": [ { "name": "sntp-servers", "data": "2001:db8:0:1::1" }, { "name": "dns-servers", "data": "2001:db8:0:1::200" }, { "name": "domain-search", "data": "example.net" } ], "reservations": [] } ], "loggers": [ { "name": "kea-dhcp6", "output-options": [ { "output": "/var/log/kea/dhcp6.log" } ], "severity": "INFO", "debuglevel": 0 } ] } } EOF测试 Kea DHCPv6 配置:
>sudokea-dhcp6 -t /etc/kea/kea-dhcp6.conf启用并启动 Kea DHCPv6 服务:
>sudosystemctl enable --now kea-dhcp6
13.5 验证 Kea DHCP 配置 #
测试 Kea DHCP 服务器功能,确保能向 PXE 客户端提供正确的网络配置和引导文件。
检查 Kea DHCPv4 服务状态:
>systemctl status kea-dhcp4检查 Kea DHCPv6 服务状态:
>systemctl status kea-dhcp6验证 DHCP 端口绑定:
>ss -ulnp | grep -E ":67|:547"监控 DHCPv4 日志:
>tail -f /var/log/kea/dhcp4.log监控 DHCPv6 日志:
>tail -f /var/log/kea/dhcp6.log查看有效的 DHCP 租约:
>cat /var/lib/kea/dhcp4.leases
13.6 Kea DHCP 配置查错 #
以下是为 PXE 引导环境配置 Kea DHCP 服务器时常见的问题。
13.6.1 配置和服务问题 #
Kea 服务可能会因 JSON 配置错误或网络接口问题而无法启动。
测试 DHCPv4 配置语法:
>sudokea-dhcp4 -t /etc/kea/kea-dhcp4.conf测试 DHCPv6 配置语法:
>sudokea-dhcp6 -t /etc/kea/kea-dhcp6.conf检查是否存在 JSON 语法错误:
>python3 -m json.tool /etc/kea/kea-dhcp4.conf验证网络接口配置:
>ip addr show eno1查看 Kea 服务日志:
>journalctl -u kea-dhcp4 -f
13.6.2 DHCP 租约分配问题 #
客户端可能会因子网配置或地址池耗尽问题而无法获取 IP 地址。
检查子网和地址池配置:
>grep -A 10 "subnet4\|pools" /etc/kea/kea-dhcp4.conf实时监控租约分配:
>tail -f /var/log/kea/dhcp4.log | grep -E "ALLOC|DISCOVER"检查租约数据库是否存在冲突:
>cat /var/lib/kea/dhcp4.leases | tail -20验证接口绑定:
>grep interfaces /etc/kea/kea-dhcp4.conf根据需要清理租约数据库:
>sudosystemctl stop kea-dhcp4>sudomv /var/lib/kea/dhcp4.leases /var/lib/kea/dhcp4.leases.backup>sudosystemctl start kea-dhcp4
13.6.3 PXE 客户端类别匹配问题 #
PXE 客户端能获取 IP 地址,但因客户端类别配置问题而无法获取正确的引导文件。
检查客户端类别定义:
>grep -A 5 "client-classes" /etc/kea/kea-dhcp4.conf监控日志中的客户端类别匹配:
>tail -f /var/log/kea/dhcp4.log | grep -i class验证供应商类别标识符模式:
>grep "PXEClient\|HTTPClient" /etc/kea/kea-dhcp4.conf测试引导文件可访问性:
>curl -I http://192.168.1.200/boot/grub2/x86_64-efi/bootx64.efi启用调试日志记录以获取详细的客户端分析信息:
>sudosed -i 's/"debuglevel": 0/"debuglevel": 99/' /etc/kea/kea-dhcp4.conf>sudosystemctl restart kea-dhcp4
13.6.4 DHCPv6 特有的问题 #
IPv6 DHCP 客户端需要正确的路由器通告配置,且其供应商类别选项处理方式与 IPv4 不同。
检查 DHCPv6 子网配置:
>grep -A 10 "subnet6" /etc/kea/kea-dhcp6.conf验证 IPv6 路由器通告状态:
>systemctl status radvd监控 DHCPv6 供应商类别匹配:
>tail -f /var/log/kea/dhcp6.log | grep "option\[16\]"检查 IPv6 bootfile-url 选项格式:
>grep "bootfile-url" /etc/kea/kea-dhcp6.conf测试与引导服务器的 IPv6 连接:
>ping6 2001:db8:0:1::200
13.7 后续步骤 #
Kea DHCP 服务配置完毕后,PXE 客户端在 IPv4 和 IPv6 环境下,均能获取全面的网络配置和引导文件信息。客户端分类系统可根据客户端体系结构精准分配引导文件,同时支持传统 PXE 引导和现代化 HTTP 引导方式。
14 使用 ISC DHCP 配置 DHCP 服务器 #
本章介绍如何配置 ISC DHCP 服务器,以提供安装 SUSE Linux Enterprise Server for SAP Applications 15 时所需的网络配置和 PXE 引导信息。SUSE Linux Enterprise Server for SAP Applications 16.0 不再提供 ISC dhcp-server 软件包。ISC DHCP 使用类别和子类匹配来支持多客户端体系结构的 PXE 引导和 HTTP 引导场景。
14.1 简介 #
ISC DHCP 是传统的 DHCP 服务器,通过类别和子类系统为 PXE 客户端提供网络配置和引导文件信息。尽管 ISC 已于 2022 年宣布该服务器已终止服务,但它在现有部署中仍被广泛使用,且能通过供应商类别识别功能稳定支持 PXE 和 HTTP 引导场景。
ISC 已于 2022 年宣布 ISC DHCP 已终止服务。对于新部署,建议改用 Kea 或 dnsmasq。本文提供此配置仅为适配现有 ISC DHCP 安装环境。
14.2 要求 #
已安装 ISC DHCP 软件包:dhcp-server
已在
/srv/tftpboot下正确整理 PXE 引导文件已为 DHCP 服务配置网络接口
具备配置 DHCP 服务的管理员权限
14.3 配置 ISC DHCPv4 服务器 #
ISC DHCPv4 配置使用类别和子类声明来匹配 PXE 和 HTTP 客户端类型,并针对不同体系结构提供适当的引导文件。
配置 ISC DHCPv4 服务器:
>sudocat > /etc/dhcpd.conf << 'EOF'# /etc/dhcpd.conf # # Sample configuration file for ISC dhcpd # # *** PLEASE CONFIGURE IT FIRST *** # # Don't forget to set the DHCPD_INTERFACE in the # /etc/sysconfig/dhcpd file. # # if you want to use dynamical DNS updates, you should first read # read /usr/share/doc/packages/dhcp-server/DDNS-howto.txt # ddns-updates off; # Use this to enable / disable dynamic dns updates globally. ddns-update-style none; # default lease time default-lease-time 3600; max-lease-time 7200; ## ## PXE / HTTP boot option declarations ## class "pxeclients" { # PXEClient:Arch:00000:UNDI:002001 match substring (option vendor-class-identifier, 0, 20); } class "httpclients" { # HTTPClient:Arch:00016:UNDI:003001 match substring (option vendor-class-identifier, 0, 21); } ## ## PXE / HTTP boot subclass request matches ## subclass "pxeclients" "PXEClient:Arch:00000" { next-server 192.168.1.200; filename "/boot/grub2/i386-pc/core.0"; } subclass "pxeclients" "PXEClient:Arch:00007" { next-server 192.168.1.200; filename "/boot/grub2/x86_64-efi/bootx64.efi"; } subclass "pxeclients" "PXEClient:Arch:0000e" { next-server 192.168.1.200; filename "/boot/grub2/powerpc-ieee1275/core.elf"; } subclass "pxeclients" "PXEClient:Arch:00011" { next-server 192.168.1.200; filename "/boot/grub2/arm64-efi/bootaa64.efi"; } subclass "httpclients" "HTTPClient:Arch:00016" { option vendor-class-identifier "HTTPClient"; filename "http://192.168.1.200/boot/grub2/x86_64-efi/bootx64.efi"; } subclass "httpclients" "HTTPClient:Arch:00019" { option vendor-class-identifier "HTTPClient"; filename "http://192.168.1.200/boot/grub2/arm64-efi/bootaa64.efi"; } ## ## Subnet declaration for the pxe network ## subnet 192.168.1.0 netmask 255.255.255.0 { authoritative; range dynamic-bootp 192.168.1.100 192.168.1.199; option subnet-mask 255.255.255.0; option routers 192.168.1.1; option ntp-servers 192.168.1.1; option domain-name-servers 192.168.1.200; option domain-name "example.net"; option domain-search "example.net"; } EOF在 sysconfig 中配置 DHCP 接口:
>sudoecho 'DHCPD_INTERFACE="eno1"' > /etc/sysconfig/dhcpd测试 DHCPv4 配置:
>sudodhcpd -t -cf /etc/dhcpd.conf启用并启动 ISC DHCPv4 服务:
>sudosystemctl enable --now dhcpd
14.4 配置 ISC DHCPv6 服务器 #
ISC DHCPv6 配置通过供应商类别匹配和正确处理 DHCPv6 选项,提供 IPv6 地址分配和引导文件信息。
配置 ISC DHCPv6 服务器:
>sudocat > /etc/dhcpd6.conf << 'EOF'# /etc/dhcpd6.conf # # Sample DHCPv6 configuration file for ISC dhcpd # # *** PLEASE CONFIGURE IT FIRST *** # # Don't forget to set the DHCPD6_INTERFACE in the # /etc/sysconfig/dhcpd file. # # if you want to use dynamical DNS updates, you should first # read /usr/share/doc/packages/dhcp-server/DDNS-howto.txt ddns-updates off; # Use this to enable / disable dynamic dns updates globally. ddns-update-style none; # IPv6 address valid lifetime # (at the end the address is no longer usable by the client) # (set to 30 days, the usual IPv6 default) default-lease-time 7200; # IPv6 address preferred lifetime # (at the end the address is deprecated, i.e., the client should use # other addresses for new connections) # (set to 7 days, the usual IPv6 default) preferred-lifetime 3600; ## ## PXE / HTTP boot option declarations ## # The dhcp6 option 16 is in fact an: # { uint32 enterprise-number, array of { uint16 len, string tag} vendor-class-data } # this declaration is using the whole option data as string for substring match: option dhcp6.vendor-class-as-string code 16 = string; # this declaration is using the enterprise-number with 1st tag length and string: option dhcp6.vendor-class-en-len-tag code 16 = {integer 32, integer 16, string}; class "pxeclients" { # PXEClient:Arch:00000:UNDI:002001 # note: +6 to skip the enterprise-number+len until the PXEClient string match substring (option dhcp6.vendor-class-as-string, 6, 20); } class "httpclients" { # HTTPClient:Arch:00016:UNDI:003001 # note: +6 to skip the enterprise-number+len until the HTTPClient string match substring (option dhcp6.vendor-class-as-string, 6, 21); } ## ## PXE / HTTP boot subclass request matches ## subclass "pxeclients" "PXEClient:Arch:00000" { option dhcp6.bootfile-url "tftp://[2001:db8:0:1::200]/boot/grub2/i386-pc/core.0"; } subclass "pxeclients" "PXEClient:Arch:00007" { option dhcp6.bootfile-url "tftp://[2001:db8:0:1::200]/boot/grub2/x86_64-efi/bootx64.efi"; } subclass "pxeclients" "PXEClient:Arch:0000e" { option dhcp6.bootfile-url "tftp://[2001:db8:0:1::200]/boot/grub2/powerpc-ieee1275/core.elf"; } subclass "pxeclients" "PXEClient:Arch:00011" { option dhcp6.bootfile-url "tftp://[2001:db8:0:1::200]/boot/grub2/arm64-efi/bootaa64.efi"; } subclass "httpclients" "HTTPClient:Arch:00016" { option dhcp6.vendor-class-en-len-tag 343 10 "HTTPClient"; option dhcp6.bootfile-url "http://[2001:db8:0:1::200]/boot/grub2/x86_64-efi/bootx64.efi"; } subclass "httpclients" "HTTPClient:Arch:00019" { option dhcp6.vendor-class-en-len-tag 343 10 "HTTPClient"; option dhcp6.bootfile-url "http://[2001:db8:0:1::200]/boot/grub2/arm64-efi/bootaa64.efi"; } ## ## Subnet declaration for the pxe network ## subnet6 2001:db8:0:1::/64 { authoritative; range6 2001:db8:0:1:d:: 2001:db8:0:1:d::ffff; option dhcp6.sntp-servers 2001:db8:0:1::1; option dhcp6.name-servers 2001:db8:0:1::200; option dhcp6.domain-search "example.net"; } EOF在 sysconfig 中配置 DHCPv6 接口:
>sudoecho 'DHCPD6_INTERFACE="eno1"' >> /etc/sysconfig/dhcpd测试 DHCPv6 配置:
>sudodhcpd -6 -t -cf /etc/dhcpd6.conf启用并启动 ISC DHCPv6 服务:
>sudosystemctl enable --now dhcpd6
14.5 验证 ISC DHCP 配置 #
测试 ISC DHCP 服务器功能,确保能向 PXE 客户端提供正确的网络配置和引导文件。
检查 ISC DHCPv4 服务状态:
>systemctl status dhcpd检查 ISC DHCPv6 服务状态:
>systemctl status dhcpd6验证 DHCP 端口绑定:
>ss -ulnp | grep -E ":67|:547"监控 DHCP 日志:
>journalctl -u dhcpd -f查看有效的 DHCP 租约:
>cat /var/lib/dhcp/dhcpd.leases监控 DHCPv6 活动:
>journalctl -u dhcpd6 -f
14.6 ISC DHCP 配置查错 #
以下是为 PXE 引导环境配置 ISC DHCP 服务器时常见的问题。
14.6.1 配置和服务问题 #
ISC DHCP 服务会可能因配置语法错误或接口绑定问题而无法启动。
测试 DHCPv4 配置语法:
>sudodhcpd -t -cf /etc/dhcpd.conf测试 DHCPv6 配置语法:
>sudodhcpd -6 -t -cf /etc/dhcpd6.conf检查接口配置:
>cat /etc/sysconfig/dhcpd验证网络接口状态:
>ip addr show eno1检查是否存在端口冲突:
>ss -ulnp | grep :67查看详细服务日志:
>journalctl -u dhcpd -xe
14.6.2 DHCP 租约分配问题 #
客户端可能会因子网配置或授权问题而无法获取 IP 地址。
检查子网和地址范围配置:
>grep -A 10 "subnet\|range" /etc/dhcpd.conf验证权威服务器设置:
>grep authoritative /etc/dhcpd.conf实时监控租约分配:
>tail -f /var/log/messages | grep dhcpd检查租约数据库是否存在错误:
>tail -20 /var/lib/dhcp/dhcpd.leases手动测试 DHCP 响应:
>dhcping -s 192.168.1.200 -h aa:bb:cc:dd:ee:ff
14.6.3 类别和子类匹配问题 #
PXE 客户端能获取 IP 地址,但因类别匹配配置问题而无法获取正确的引导文件。
检查类别定义:
>grep -A 3 "class.*clients" /etc/dhcpd.conf验证子类条目:
>grep -A 5 "subclass" /etc/dhcpd.conf监控供应商类别识别:
>tail -f /var/log/messages | grep -E "PXEClient|HTTPClient"测试引导文件可访问性:
>tftp 192.168.1.200 -c get /boot/grub2/x86_64-efi/bootx64.efi启用详细日志记录:
>sudosed -i '1i\log-facility local7;' /etc/dhcpd.conf>sudosystemctl restart dhcpd
14.6.4 DHCPv6 供应商类别选项问题 #
IPv6 DHCP 客户端的供应商类别选项处理过程较为复杂,需要特定配置才能支持 PXE 引导。
检查 DHCPv6 选项定义:
>grep -A 3 "option dhcp6" /etc/dhcpd6.conf验证供应商类别字符串解析:
>grep "substring.*6.*20\|21" /etc/dhcpd6.conf监控 DHCPv6 供应商类别匹配:
>journalctl -u dhcpd6 | grep -i vendor检查 IPv6 bootfile-url 格式:
>grep "bootfile-url" /etc/dhcpd6.conf验证路由器通告的依赖服务:
>systemctl status radvd测试 IPv6 连接:
>ping6 2001:db8:0:1::200
14.7 后续步骤 #
ISC DHCP 服务配置完毕后,PXE 客户端便可通过传统的类别和子类系统获取网络配置和引导文件信息。尽管 ISC DHCP 已终止服务,但此配置仍能为需要 PXE 和 HTTP 引导功能的现有多客户端体系结构部署提供兼容性支持。
15 验证 PXE 服务器设置 #
本章介绍如何验证和测试完整的 PXE 服务器设置,确保所有组件均能正常工作,以支持 SUSE Linux Enterprise Server for SAP Applications 16.0 的网络安装。内容涵盖服务验证、网络连接测试及端到端 PXE 引导验证。
15.1 简介 #
当包括 TFTP、HTTP、DNS、DHCP 和 GRUB 2 引导加载程序服务在内的所有 PXE 服务器组件均配置完毕后,必须验证整个系统是否能正常运行。此验证过程可确保 PXE 客户端能成功引导至 Agama 安装程序,并可通过网络执行 SUSE Linux Enterprise Server for SAP Applications 16.0 安装。
15.2 要求 #
所有 PXE 服务器组件均已配置且处于运行状态
具备 PXE 引导能力的测试客户端系统
PXE 服务器与客户端之间的网络连通
具备监控服务器服务的管理员权限
15.3 验证 PXE 服务器服务 #
在使用 PXE 客户端测试前,先验证所有必要的 PXE 服务器服务是否正常运行且配置正确。
验证 TFTP 服务状态:
>systemctl status tftp.socket预期结果:服务处于活跃状态,且在 69 端口侦听。
检查 nginx HTTP 服务:
>systemctl status nginx预期结果:服务处于活跃状态,且在 80 端口侦听。
验证 DNS 服务(如果使用 dnsmasq):
>systemctl status dnsmasq预期结果:服务处于活跃状态,且在 53 端口侦听。
检查 DHCP 服务状态(选择相应的服务):
>systemctl status dhcpd如果使用 dnsmasq DHCP:
>systemctl status dnsmasq如果使用 Kea DHCP:
>systemctl status kea-dhcp4 kea-dhcp6预期结果:DHCP 服务处于活跃状态,且在适当的端口侦听。
验证 IPv6 路由器通告(如果已配置):
>systemctl status radvd预期结果:服务处于活跃状态(适用于 IPv6 环境)。
检查 NTP 服务:
>systemctl status chronyd预期结果:服务处于活跃状态且已完成时间同步。
15.4 测试网络连接和文件访问 #
验证 PXE 客户端能否通过 TFTP 和 HTTP 两种协议访问网络中的引导文件和安装内容。
测试能否通过 TFTP 访问引导加载程序文件:
>tftp localhost -c get /boot/grub2/x86_64-efi/bootx64.efi /tmp/test-bootx64.efi验证是否成功检索了文件:
>file /tmp/test-bootx64.efi清理测试文件:
>rm /tmp/test-bootx64.efi测试能否通过 HTTP 访问 GRUB 2 配置:
>curl -I http://localhost/boot/grub2/grub.cfg预期结果:返回 HTTP 200 OK 响应。
验证能否通过 HTTP 访问安装程序文件:
>curl -I http://localhost/boot/images/SLES-16.0/x86_64/liveiso/LiveOS/squashfs.img预期结果:返回 HTTP 200 OK 响应,并包含正确的内容长度。
测试 DNS 解析(如果配置了本地 DNS):
>nslookup pxe.example.net localhost预期结果:能正确解析出 A 记录和 AAAA 记录。
验证自动索引目录的浏览功能:
>curl http://localhost/boot/预期结果:显示目录列表,包含引导文件。
15.5 验证 DHCP 功能 #
测试 DHCP 服务器的响应,确认其能为不同类型的客户端提供正确的引导信息。
检查 DHCP 端口绑定:
>ss -ulnp | grep -E ":67|:547"预期结果:DHCP 服务在 67 端口 (IPv4) 和 547 端口 (IPv6) 侦听。
实时监控 DHCP 请求:
>journalctl -u dhcpd -f如果使用 dnsmasq:
>journalctl -u dnsmasq -f使此命令保持运行状态,以便在测试期间观察 DHCP 活动。
使用 dhcping(如果可用)测试 DHCP 响应:
>dhcping -s 192.168.1.200预期结果:从服务器收到成功的 DHCP 响应。
查看有效的 DHCP 租约:
>cat /var/lib/dhcp/dhcpd.leases如果使用 Kea:
>cat /var/lib/kea/dhcp4.leases预期结果:测试客户端的租约条目存在。
15.6 端到端 PXE 引导测试 #
使用实际客户端系统执行完整的 PXE 引导测试,验证从 DHCP 地址获取到 Agama 安装程序启动的整个流程。
准备测试客户端系统:
配置 BIOS/UEFI 以启用网络引导功能
将网络引导设置为第一引导优先级
将客户端连接到 PXE 服务器所在的同一网络
在客户端引导期间监控 PXE 服务器日志:
>journalctl -f | grep -E "dhcp|tftp|nginx"引导测试客户端,并观察以下流程是否正常:
客户端通过 DHCP 获取 IP 地址
客户端通过 TFTP 下载引导加载程序
显示包含安装选项的 GRUB 2 菜单
通过 HTTP 加载内核和 initrd
Agama 安装程序成功启动
通过测试不同类型的客户端,验证客户端体系结构检测功能:
传统 BIOS x86_64 系统(应获取 core.0)
UEFI x86_64 系统(应获取 bootx64.efi)
UEFI aarch64 系统(应获取 bootaa64.efi)
测试 IPv6 PXE 引导(如果已配置 IPv6):
在测试客户端上启用仅限 IPv6 的网络配置
验证 DHCPv6 地址分配
确认 IPv6 bootfile-url 已正确分发
15.7 验证 Agama 安装程序功能 #
验证 Agama 安装程序能否正常启动,且能访问安装源以完成 SUSE Linux Enterprise Server for SAP Applications 16.0 安装。
验证 Agama Web 界面的可访问性:
在客户端引导过程中,记录分配到的 IP 地址,通过以下方式访问:
http://CLIENT_IP_ADDRESS
预期结果:Agama Web 界面能成功加载。
在客户端上检查 Agama 安装程序日志:
切换到控制台(按 Alt+F2),运行以下命令:
#journalctl -u agama-web-server -f预期结果:Agama 启动过程中无严重错误。
验证安装源的可访问性:
对于完整 ISO 安装,检查储存库的访问情况:
#curl -I http://192.168.1.200/install/SLES-16.0/x86_64/预期结果:返回 HTTP 200 OK 响应,并显示目录列表。
测试软件包安装能力:
在 Agama 界面中,验证以下功能:
系统能检测到可用磁盘
网络配置保持正常
软件包储存库可访问
安装流程能正常执行至完成
15.8 排查验证失败问题 #
以下是 PXE 服务器验证过程中常见的问题及其解决步骤。
15.8.1 DHCP 分配失败 #
客户端在 PXE 引导过程中无法获取 IP 地址。
检查 DHCP 服务冲突:
>ss -ulnp | grep :67验证网络接口是否已启用:
>ip addr show eno1检查 DHCP 地址范围可用性:
>nmap -sn 192.168.1.100-199监控 DHCP 日志中的错误:
>journalctl -u dhcpd | tail -50
15.8.2 引导文件分发失败 #
客户端能获取 IP 地址,但无法下载引导文件。
验证 TFTP 服务可访问性:
>tftp 192.168.1.200 -c get /boot/grub2/x86_64-efi/bootx64.efi检查文件权限:
>ls -la /srv/tftpboot/boot/grub2/x86_64-efi/监控 TFTP 访问日志:
>journalctl -u tftp.socket -f验证客户端体系结构检测:
>grep -E "PXEClient|HTTPClient" /var/log/messages
15.8.3 Agama 安装程序启动失败 #
引导文件已成功加载,但 Agama 安装程序无法启动。
检查能否通过 HTTP 访问安装程序文件:
>curl -I http://192.168.1.200/boot/images/SLES-16.0/x86_64/liveiso/LiveOS/squashfs.img验证 GRUB 2 配置中的内核参数语法:
>grep "root=live:" /srv/tftpboot/boot/grub2/menu.cfg监控客户端引导过程:
>journalctl -f | grep -E "kernel|initrd|agama"检查网络配置持久性:
#ip addr show
15.9 PXE 服务器验证清单 #
使用以下清单系统性地验证 PXE 服务器配置的所有方面。
| 组件 | 验证步骤 | 状态 |
|---|---|---|
| TFTP 服务 | 服务处于活跃状态、在 69 端口侦听、文件可访问 | ☐ |
| HTTP 服务 | nginx 处于活跃状态、在 80 端口侦听、安装程序文件可访问 | ☐ |
| DNS 服务 | 主机名解析正常、在 53 端口侦听 | ☐ |
| DHCP 服务 | IP 分配正常、引导选项已传递 | ☐ |
| GRUB 2 配置 | 菜单加载正常、体系结构检测正常 | ☐ |
| IPv6 支持 | 路由器通告处于活跃状态、DHCPv6 功能正常 | ☐ |
| PXE 引导 | 客户端成功引导、获取了正确的引导加载程序 | ☐ |
| Agama 安装程序 | 安装程序启动、Web 界面可访问 | ☐ |
| 安装源 | 储存库可访问、软件包可安装 | ☐ |
| 网络持久性 | 安装过程中网络配置保持正常 | ☐ |
15.10 验证总结 #
经过正确验证的 PXE 服务器应能展现完整的端到端功能 - 从客户端网络引导到 Agama 安装程序启动的整个流程均可成功完成。所有服务需无错误运行,且客户端应能通过网络完成 SUSE Linux Enterprise Server for SAP Applications 16.0 安装。定期执行验证测试可确保 PXE 基础架构在自动化部署场景中持续可靠运行。
16 法律声明 #
版权所有© 2006–2025 SUSE LLC 和撰稿人。保留所有权利。
根据 GNU 自由文档许可证 (GNU Free Documentation License) 版本 1.2 或(根据您的选择)版本 1.3 中的条款,在此授予您复制、分发和/或修改本文档的权限;本版权声明和许可证附带不可变部分。许可版本 1.2 的副本包含在“GNU Free Documentation License”部分。
有关 SUSE 商标,请参见 https://www.suse.com/company/legal/。所有其他第三方商标分别为相应所有者的财产。商标符号(®、™ 等)代表 SUSE 及其关联公司的商标。星号 (*) 代表第三方商标。
本指南力求涵盖所有细节,但这不能确保本指南准确无误。SUSE LLC 及其关联公司、作者和译者对于可能出现的错误或由此造成的后果皆不承担责任。