0
点赞
收藏
分享

微信扫一扫

如何搭建深度学习的多 GPU 服务器

七千22 2024-08-08 阅读 27

一、pxe 介绍

PXE技术是一种允许计算机在启动时通过网络加载操作系统的技术。这种技术对于批量快速部署大量服务器操作系统、恢复系统以及在无盘环境中运行系统非常有用。PXE通过使用DHCP和TFTP协议,实现了在没有本地存储设备的情况下,从网络服务器加载启动文件和操作系统镜像。

PXE的工作原理可以概括为以下几个步骤:当计算机启动时,其BIOS或UEFI固件中的PXE客户端会向网络发送广播请求,寻找PXE服务器;DHCP服务器响应这些请求,提供IP地址和其他网络配置信息,包括启动文件的位置;使用TFTP协议,PXE客户端从服务器下载启动文件,这通常是一个小型的引导程序;下载的boot引导程序执行,它可能会加载更完整的操作系统镜像,或者启动一个轻量级的操作系统环境;在引导程序的帮助下,计算机能够加载并运行完整的操作系统。

二、部署过程

1、思路图

 在部署之前,本机服务器的网络必须要配置好,设为手动。然后需要将vmnet8的dhcp服务这样才能够使用本服务器来下发IP,然后下载完http,dhcp服务。

2、使用kickstart 来自动化安装脚本

接下来就在图形界面设置。其配置步骤图如下:

 

 

 

在里面添加三个分区 。

 

 这里面是可以根据你的需要来写的

 

最后就是保存,我们将其保存到根目录下

 

然后就会在根目录下出现ks.cfg。但是我们前面没有配置packages,需要我们在这个文件里面手动配置。

%packages
@base
httpd
%end

最后将这个ks.cfg文件放到/var/www/html/去在网上共享

cp /root/ks.cfg  /var/www/html/
#在这里面能够有这些文件
[root@localhost ~]# ll /var/www/html/
total 4
-rw-r--r--. 1 root root 1173 Aug 4 13:14 ks.cfg
lrwxrwxrwx. 1 root root 5 Aug 4 11:13 mnt -> /mnt/

3、配置dhcp 服务

我们下载完DHCP服务其就会出现配置文件,但是没有里面东西,我们参考其模板再去修改

\cp -f /usr/share/doc/dhcp*/dhcpd.conf.example /etc/dhcp/dhcpd.conf
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
# dhcpd.conf
#
# Sample configuration file for ISC dhcpd
#

# option definitions common to all supported networks...
#这是公司域名
option domain-name "example.org";
#这是对外分发的dns地址
option domain-name-servers 114.114.114.114;

default-lease-time 600;
max-lease-time 7200;

# Use this to enble / disable dynamic dns updates globally.
#ddns-update-style none;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
#authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

#subnet 10.152.187.0 netmask 255.255.255.0 {
#}

# This is a very basic subnet declaration.

subnet 172.25.254.0 netmask 255.255.255.0 {
range 172.25.254.30 172.25.254.40;
option routers 172.25.254.2;
next-server 172.25.254.136;
filename "pxelinux.0";
}

最后要重新启动dhcp服务。

4、配置tftp服务 

#下载软件包,可以先通过yum search 来查看我们有的安装包来安装
[root@localhost ~]# yum install syslinux.x86_64 -y
[root@localhost ~]# yum install tftp-server.x86_64 -y

#启动并开机自启tftp
systemctl enable --now tftp

#将我们挂载目录下ISO镜像文件中的引导文件和相关内容复制到TFTP服务器的根目录,以便在网络启动时提供给客户端计算机。
[root@localhost ~]# cp /mnt/isolinux/* /var/lib/tftpboot/

#将PXE引导程序pxelinux.0文件从syslinux软件包的目录复制到TFTP服务器的根目录下。
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

#ISO镜像文件中的启动配置文件isolinux.cfg复制到PXE引导目录中的默认配置文件default。
[root@localhost ~]# cd /var/lib/tftpboot/
[root@localhost ~]# mkdir pxelinux.cfg
[root@localhost tftpboot]# cp isolinux.cfg /pxelinux.cfg/default

#然后写在default里面添加修改
[root@localhost tftpboot]vim pxelinux.cfg/default

#主要是修改这些内容
label linux
menu label ^Install Red Hat Enterprise Linux 7.9 haaaaaaaaaaaaa
menu default
kernel vmlinuz
append initrd=initrd.img repo=http://172.25.254.136/mnt ks=http://172.25.254.136/ks.cfg quiet

label check
menu label Test this ^media & install Red Hat Enterprise Linux 7.9
kernel vmlinuz
append initrd=initrd.img inst.stage2=hd:LABEL=RHEL-7.9\x20Server.x86_64 rd.live.check quiet

 最后也要重新启动服务。

5、测试

在其他虚拟机上选择打开电源时进入固件,然后就会进入图形界面。如下:注意要把network那一行放到最上面,可以使用+号。

然后退出 保存

最后在会在启动时出现 ,那个haaaaaaaaaa就是我们自己写的。然后就是这个会不停的启动,我们就可以在其启动完一次之后,就关机,并且在第二次可以选择硬件模式,然后就可以在完成后查看IP有没有配置,以及一些服务有没有启动。

主要配置文件代码 

1、dhcp配置文件

2、ks.cfg 

3、 pxelinux.cfg/default

举报

相关推荐

0 条评论