使用pxe引导方式创建无盘工作站


1. 概述

本篇博客基于《使用pxe和kickstart进行无人值守批量安装centos7》实现无盘工作站部署。仅实现单个节点的无盘系统,多个节点需要额外的配置。

参考博客:https://www.cnblogs.com/jiangxiaolin/p/5408806.html

无盘工作站的意思就是节点把操作系统根文件系统创建在nfs服务器上,而非本地硬盘。这同样用到了pxe的启动方式,在启动时通过内核参数,把根文件系统挂载到nfs即可

2. 部署过程

2.1 dhcp和tftp

dhcp的配置

$ cat /etc/dhcp/dhcpd.conf 
ddns-update-style none;
default-lease-time 259200;
max-lease-time 518400;    
option routers 192.168.80.1;
option domain-name-servers 192.168.80.1;
subnet 192.168.80.0 netmask 255.255.255.0 {
    range 192.168.80.51 192.168.80.59;
    option subnet-mask 255.255.255.0;
    next-server 192.168.80.17;
    filename "pxelinux.0";
}

host node51 {
    option host-name node51;
    hardware ethernet 00:00:00:80:00:51;
    fixed-address 192.168.80.51;
} 
host node52 {
    option host-name node52;
    hardware ethernet 00:00:00:80:00:52;
    fixed-address 192.168.80.52;
} 

启动dhcp服务器:systemctl start dhcpd

xinetd配置

$ cat /etc/xinetd.d/tftp 
# 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
}

启动xinetd服务:systemctl status xinetd

2.2 nfs

安装和启动nfs服务:yum -y install nfs-utils; systemctl start nfs

创建共享目录:mkdir -p /opt/hpc/os

创建共享配置文件:vim /etc/exportfs,内容:

/opt/hpc/os             192.168.80.0/24(rw,sync,no_root_squash,no_all_squash)

执行命令:exportfs -r

3. 创建文件系统

在node17(centos7.9)上执行:

rsync -av --exclude='/proc' --exclude='/sys' --exclude='/tmp' --exclude='/run' --exclude='/var/tmp' --exclude='/opt/hpc' /* /opt/hpc/os/

在/opt/hcp/os下创建未拷贝的目录:

cd /opt/hpc/os/; mkdir -p proc sys tmp run /var/tmp

修改节点挂载选项:vim /opt/hpc/os/etc/fstab,内容:


#
# /etc/fstab
# Created by anaconda on Mon Jun 20 11:06:39 2022
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
192.168.80.17:/opt/hpc/os       /       nfs     defaults 0 0
#UUID=dccc162e-2c16-4c86-bb12-f97bb57a123a /                       xfs     defaults        0 0
#UUID=f4ff09b8-c8fd-4e14-ae0b-b0172f864dee /boot                   xfs     defaults        0 0

4. 测试

使用virt-manger创建一个虚拟机node52,使用pxe方式启动,定制node52的mac地址:00:00:00:80:00:52保证其通过dhcp获取到指定ip和主机名。

node52启动后,进入系统执行:df -h

$ df -h
文件系统                   容量  已用  可用 已用% 挂载点
devtmpfs                   468M     0  468M    0% /dev
tmpfs                      496M  4.0K  496M    1% /dev/shm
tmpfs                      496M   43M  453M    9% /run
tmpfs                      496M     0  496M    0% /sys/fs/cgroup
192.168.80.17:/opt/hpc/os   20G  7.6G   12G   39% /
tmpfs                      100M     0  100M    0% /run/user/0

原创文章,作者:,如若转载,请注明出处:https://blog.ytso.com/270925.html

(0)
上一篇 2022年7月1日
下一篇 2022年7月1日

相关推荐

发表回复

登录后才能评论