1. 概述
本篇博客基於《使用pxe和kickstart進行無人值守批量安裝centos7》實現無盤工作站部署。僅實現單個節點的無盤系統,多個節點需要額外的配置。
無盤工作站的意思就是節點把操作系統根文件系統創建在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