RH8编译安装Lustre

2023-05-24
3分钟阅读时长

image-20241115152457584

1. 添加lustre官方源

编辑 /etc/yum.repos.d/lustre.repo

[lustre-server]
name=lustre-server
baseurl=https://downloads.whamcloud.com/public/lustre/lustre-2.15.2/el8.7/server/
gpgcheck=0
[lustre-client]
name=lustre-client
baseurl=https://downloads.whamcloud.com/public/lustre/lustre-2.15.2/el8.7/client/
gpgcheck=0
[e2fsprogs-wc]
name=e2fsprogs-wc
baseurl=https://downloads.whamcloud.com/public/e2fsprogs/latest/el8/
gpgcheck=0

2. 安装依赖

yum --nogpgcheck --enablerepo=*  install -y  audit-libs-devel binutils-devel elfutils-devel kabi-dw ncurses-devel newt-devel numactl-devel openssl-devel pciutils-devel perl perl-devel python2 python3-docutils xmlto xz-devel elfutils-libelf-devel libcap-devel libcap-ng-devel llvm-toolset libyaml libyaml-devel kernel-rpm-macros kernel-abi-whitelists uuid libuuid-devel libblkid libblkid-devel libtirpc-devel libtirpc libaio-devel libattr-devel   libffi-devel libudev-devel ncompress python3-cffi python3-devel python3-packaging  libmount libmount-devel make cmake automake gdb gcc
yum --nogpgcheck --enablerepo=powertools  install libyaml-devel
yum --nogpgcheck --disablerepo=* --enablerepo=e2fsprogs-wc  install  e2fsprogs e2fsprogs-devel e2fsprogs-libs libcom_err libcom_err-devel libss libss-devel 
yum install  --disablerepo=*  --enablerepo=lustre-server kernel-debuginfo-common-x86_64.x86_64 -y

3. 编译并安装zfs

下载源码包

git clone https://github.com/openzfs/zfs.git && cd zfs && git checkout zfs-2.1.5 

编译

sh autogen.sh
./configure --with-spec=redhat  --with-linux=/usr/src/kernels/4.18.0-425.19.2.el8_7.x86_64/ 
make pkg-utils pkg-kmod
mkdir -p zfs-rpm &&  mv *.rpm zfs-rpm/

安装

cd zfs-rpm/
yum localinstall  -y  libuutil*.rpm libnvpair*.rpm zfs-debuginfo*.rpm zfs-debugsource*.rpm 
yum localinstall  -y  libzfs5*.rpm libzfs5*.rpm libzpool5*.rpm  zfs-kmod-debugsource*.rpm
yum localinstall  -y  kmod-zfs*.rpm zfs-2.1.5-1.el8.x86_64.rpm
rpm -ivh zfs-2.1.5-1.el8.src.rpm

加载zfs内核

modprobe zfs

4. 编译并安装lustre

Lustre 主要由 MGSMDSOST (前三者组成Server端)和 Client 组成

下载源码包,更改git 版本,生成系统ac

git clone git://git.whamcloud.com/fs/lustre-release.git
cd lustre-release && git checkout 2.15.2 
cd lustre-release && sh autogen.sh

回到上级目录,复制两份,一份编译客户端,一份编译服务端

cp lustre-release lustre-client -rf
cp lustre-release lustre-server -rf

4.1 编译服务端

加上oi2b参数可以使用ib网络

cd lustre-client
./configure --enable-quota --enable-server --with-o2ib=yes --with-linux=/usr/src/kernels/4.18.0-425.19.2.el8_7.x86_64/ --with-zfs=/usr/src/zfs-2.1.5/
make rpms 
mkdir -p server-rpm &&mv *.rpm server-rpm/

进入server-rpm 安装

rpm -ivh --nodeps  *lustre*.rpm

4.2 编译客户端

cd lustre-client
./configure --disable-server --enable-client --with-o2ib=yes --with-linux=/usr/src/kernels/4.18.0-425.19.2.el8_7.x86_64/ 
make rpms 
mkdir -p client-rpm &&mv *.rpm client-rpm/

进入client-rpm 依次安装

rpm -ivh --nodeps  *lustre*.rpm

4.3 验证

加载lustre内核

modprobe -v lustre

查看版本

lctl get_param version

验证后,从内核卸载Lustre内核 重启机器

lustre_rmmod 
reboot

5. 配置lnet网络

配置网络 需要先卸载lustre内核,加载lnet内核,配置lnet (服务端客户端同样操作) (重启服务器后lnet信息会丢失,每次重启服务器请手动加载lnet网络)

lustre_rmmod
modprobe -v lnet
lnetctl lnet configure

lnetctl net add --net o2ib --if ib0
lnetctl net add --net tcp --if ens5f3
lnetctl net show

lnetctl export > /etc/sysconfig/lnet.conf
systemctl enable lnet

image-20241115152505544

6.服务端创建MGS MDT

查看未使用的硬盘

lsblk

image-20241115152512316

服务端创建MGS MDT,index编号为0

mkfs.lustre --fsname=lustre --mdt --mgs --index=0 --reformat /dev/nvme0n1

MGS和MDS 创建挂载目录,启动服务并挂载

mkdir -p /mnt/mg
mount.lustre  /dev/nvme0n1 /mnt/mg

image-20241115152522293

7.服务端创建OST

(可与上面MGS MDT在同一台服务器)

mkfs.lustre --fsname=lustre --reformat --ost --mgsnode=192.168.6.100@o2ib --index=11 /dev/nvme1n1
mkfs.lustre --fsname=lustre --reformat --ost --mgsnode=192.168.6.100@o2ib --index=12 /dev/nvme2n1
mkfs.lustre --fsname=lustre --reformat --ost --mgsnode=192.168.6.100@o2ib --index=13 /dev/nvme3n1

OSS 创建挂载目录,启动服务并挂载

mkdir -p /mnt/ost1 
mkdir -p /mnt/ost2 
mkdir -p /mnt/ost3
mount -t lustre  /dev/nvme1n1 /mnt/ost1
mount -t lustre  /dev/nvme2n1 /mnt/ost2
mount -t lustre  /dev/nvme3n1 /mnt/ost3

image-20241115152528425

8.客户端挂载

创建全局共享目录/z3 并将lustre挂载到上面

mkdir /z3
mount.lustre 192.168.6.100@o2ib:/lustre /z3
mkdir -p /z3/home  /z3/public

image-20241115152535944

本项目三台节点都有4块7TNVME,我们每一台服务器都有一块硬盘做MGS/MDT,部署详细如下(注意index编号不要重复了)

所有节点:

mkdir /mnt/mg

mkdir /z3

mkdir -p /mnt/ost1

mkdir -p /mnt/ost2

mkdir -p /mnt/ost3

mgs mtd>

node0:

mkfs.lustre –fsname=lustre –reformat –mgs –mdt –servicenode=192.168.6.100@o2ib –index=0 /dev/nvme0n1

mount -t lustre /dev/nvme0n1 /mnt/mg

node1:

mkfs.lustre –fsname=lustre –reformat –mgs –mdt –servicenode=192.168.6.101@o2ib –index=1 /dev/nvme0n1

mount -t lustre /dev/nvme0n1 /mnt/mg

node2:

mkfs.lustre –fsname=lustre –reformat –mgs –mdt –servicenode=192.168.6.102@o2ib –index=2 /dev/nvme0n1

mount -t lustre /dev/nvme0n1 /mnt/mg

ost>

node0:

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=11 /dev/nvme1n1

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=12 /dev/nvme2n1

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=13 /dev/nvme3n1

mount -t lustre /dev/nvme1n1 /mnt/ost1

mount -t lustre /dev/nvme2n1 /mnt/ost2

mount -t lustre /dev/nvme3n1 /mnt/ost3

node1:

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=101 /dev/nvme1n1

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=102 /dev/nvme2n1

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=103 /dev/nvme3n1

mount -t lustre /dev/nvme1n1 /mnt/ost1

mount -t lustre /dev/nvme2n1 /mnt/ost2

mount -t lustre /dev/nvme3n1 /mnt/ost3

node2

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=201 /dev/nvme1n1

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=202 /dev/nvme2n1

mkfs.lustre –fsname=lustre –reformat –ost –mgsnode=192.168.6.100@o2ib –mgsnode=192.168.6.101@o2ib –mgsnode=192.168.6.102@o2ib –index=203 /dev/nvme3n1

mount -t lustre /dev/nvme1n1 /mnt/ost1

mount -t lustre /dev/nvme2n1 /mnt/ost2

mount -t lustre /dev/nvme3n1 /mnt/ost3

umount /mnt/ost*

umount /mnt/mg

所有节点 client>

mount.lustre 192.168.6.100@o2ib:192.168.6.101@o2ib:192.168.6.102@o2ib:/lustre /z3

最后效果如下

image-20241115152545902

重启服务器后,挂载会失效,请手动复现上述挂载的命令,不用重新格式化

上一页 Lvm实战