Ubuntu 下编译安装 Lustre

获取 lustre 源码

git clone git://git.whamcloud.com/fs/lustre-release.git

Lustre 后端文件系统支持 ldiskfs 和 zfs,下面分别介绍基于 ldiskfs 和 zfs 的 lustre 编译安装

ldiskfs - lustre

ldiskfs 是通过对 ext4 源码打补丁得到的文件系统,在编译时会复制 linux 源码下的 ext4 文件并打补丁,所以要先确定好内核版本源码。如果 ext4 的源码版本与补丁版本的代码差异大,应用补丁会失败,如下:

Applying patch patches/ubuntu20.04.5/ext4-inode-version.patch
Applying patch patches/linux-5.4/ext4-lookup-dotdot.patch
Applying patch patches/linux-5.14/ext4-print-inum-in-htree-warning.patch
Applying patch patches/ubuntu20.04.5/ext4-prealloc.patch
1 out of 12 hunks FAILED
Patch patches/ubuntu20.04.5/ext4-prealloc.patch does not apply (enforce with -f)

1. 查看 ldiskfs 补丁

将 ext4 转换为 ldiskfs 所需的补丁在 ldiskfs/kernel_patches 目录下

ls ldiskfs/kernel_patches/series | grep ubuntu

可以看到对应内核版本的ldiskfs

ldiskfs-4.15.0-20-ubuntu18.series
ldiskfs-4.15.0-24-ubuntu18.series
ldiskfs-5.0.0-13-ubuntu19.series
ldiskfs-5.11.0-40-ubuntu20.series
ldiskfs-5.15.0-106-ubuntu20.series
ldiskfs-5.15.0-83-ubuntu20.series
ldiskfs-5.19.0-35-ubuntu.series
ldiskfs-5.4.0-42-ubuntu20.series
ldiskfs-5.4.0-66-ubuntu20.series
ldiskfs-5.4.0-80-ubuntu20.series
ldiskfs-5.4.0-90-ubuntu20.series
ldiskfs-5.8.0-53-ubuntu20.series
ldiskfs-5.8.0-63-ubuntu20.series

通过分析 configure 文件可以知道,脚本会根据 linux 内核版本匹配相应或相近的 ldiskfs 补丁序列,所以内核源码版本应尽量与这些版本相近,避免因差异过大导致应用补丁失败。

下面以 ubuntu22-5.19.0 为例编译安装 ldiskfs-lustre

2. 获取内核源代码
sudo apt install linux-source-5.19.0=5.19.0-41.42\~22.04.1

=号后面的内容可以通过tab自行选择,其它获取 ubuntu 源码方式ubuntu-wiki

这里选择 41.42(试过可以),其它是否可用可自行测试。ubuntu22尝试过可以应用补丁的 5.15.0 和 5.19.0 的分别有 5.15.0-86 和 5.19.0-41。

apt 下载的源码会在 /usr/src 目录下,解压

cd ~/
tar jxvf /usr/src/linux-source-5.19.0.tar.bz2

解压后源码在~/linux-source-5.19.0

3. 安装工具包
sudo apt install git libtool libtool-bin libyaml-dev ed libreadline-dev dpatch libsnmp-dev mpi-default-dev module-assistant quilt libncurses5-dev libncurses-dev bison flex gnupg libelf-dev gcc libssl-dev bc bzip2 build-essential udev kmod cpio libfuse-dev libattr1-dev libblkid-dev uuid-dev devscripts fakeroot kernel-wedge libudev-dev libpython3-dev swig gettext texinfo debhelper dh-exec update-notifier-common sg3-utils attr mpi-default-bin selinux-utils python2 python2-minimal python2.7 libpython2-stdlib libsgutils2-2 libpython2.7-stdlib python2.7-minimal libpython2.7-minimal

sudo apt install libtool pkg-config libncurses-dev openssl libkeyutils-dev libmount-dev libnl-genl-3-dev

sudo apt install linux-headers-5.19.0-41-generic

linux-headers-5.19.0-41-generic 安装后在 /usr/src

sudo apt install e2fsprogs libext2fs-dev

注意 apt 源中这两个包的版本是否兼容当前 lustre 版本(在lustre/Changelog中),如果版本不正确后续在制作文件系统时可能会有问题。

版本不正确则需要自行编译 e2fsprogs,编译安装e2fsprogs

4. 生成配置文件
sh autogen.sh
./configure --enable-server --enable-client --with-linux=[解压后的linux-source-5.19.0路径] --with-linux-obj=/usr/src/linux-headers-5.19.0-41-generic/ --enable-ldiskfs --without-zfs 
5. 编译 lustre
make -j(nproc)
sudo apt install linux-headers-generic
make debs -j(nproc)

make debs后会生成一个debs目录,里面有编译制作好的deb包

6. 安装内核

需要安装编译时指定的对应的Linux内核以安装使用lustre

sudo apt install linux-image-5.19.0-41-generic linux-headers-5.19.0-41-generic linux-modules-5.19.0-41-generic linux-modules-extra-5.19.0-41-generic

重启,选择安装的内核启动

7. 安装依赖和lustre
cd debs
sudo apt install resource-agents uidmap quota 
sudo dpkg -i *.deb
8. 部署测试 lustre

在单机上部署一个简单的 lustre 服务集群(mgs,mts,oss各一个)

8.1 制作挂载设备
sudo dd if=/dev/zero of=/lustre-mgt.img bs=1M count=256
sudo dd if=/dev/zero of=/lustre-mdt.img bs=1M count=1024
sudo dd if=/dev/zero of=/lustre-ost.img bs=1M count=1024

sudo losetup /dev/loop35 /lustre-mgt.img
sudo losetup /dev/loop36 /lustre-mdt.img
sudo losetup /dev/loop37 /lustre-ost.img
8.2 制作 lustre 文件系统
sudo mkfs.lustre --mgs /dev/loop35

sudo mkfs.lustre --mdt --mgsnode=$(IP)@tcp --fsname=lustrefs --index=0 /dev/loop36

sudo mkfs.lustre --ost --mgsnode=$(IP)@tcp --index=0 --fsname=lustrefs /dev/loop37
  • $(IP) 填写相应的IP地址
  • --fsname 文件系统名
  • --index 指定mdt,ost的索引

制作文件系统会出现以下提示:

Permanent disk data:

Writing CONFIGS/mountdata

出现Writing CONFIGS/mountdata则表明制作成功

8.3挂载文件系统
sudo mkdir -p /mnt/lustre/mgt
sudo mount -t lustre /dev/loop35 /mnt/lustre/mgt

sudo mkdir -p /mnt/lustre/mdt
sudo mount -t lustre /dev/loop36 /mnt/lustre/mdt

sudo mkdir -p /mnt/lustre/ost
sudo mount -t lustre /dev/loop37 /mnt/lustre/ost

sudo mkdir -p /mnt/lustre/client
sudo mount -t lustre $(IP)@tcp:/lustrefs /mnt/lustre/client
8.4客户端上显示MDT和OST空间占用情况
lfs df -h

会出现类似的如下内容:

UUID                       bytes        Used   Available Use% Mounted on
lustrefs-MDT0000_UUID      571.9M        1.6M      520.7M   1% /mnt/lustre/client[MDT:0]
lustrefs-OST0000_UUID      931.9M        1.4M      863.4M   1% /mnt/lustre/client[OST:0]

filesystem_summary:       931.9M        1.4M      863.4M   1% /mnt/lustre/client

附:编译安装 e2fsprogs

1. 编译
git clone git://git.whamcloud.com/tools/e2fsprogs.git  
cd e2fsprogs  
git checkout master-lustre  
sed -i 's/ext2_types-wrapper.h$//g' lib/ext2fs/Makefile.in
./configure  
dpkg-buildpackage -b -us -uc

制作好的deb包在e2fsprogs的上级目录

2. 安装
sudo dpkg -i *.deb
sudo dpkg -i *.deb

使用两次是因为*.deb文件中存在相互依赖问题,导致一些包没安装成功,在执行一次即可。

zfs - lustre

1. 获取ZFS源码
git clone  git clone https://github.com/openzfs/zfs.git
git checkout zfs-2.1.15

具体切换到ZFS的哪个版本,可以在 Lustre Support Matrix中根据 Lustre 版本获得

2. 编译ZFS
sh autogen.sh
./configure
make -j$(nproc)
3. 编译 Lustre
sh autogen.sh
./configure --enable-server --enable-client --with-linux=[linux-source-5.19.0 path] --with-linux-obj=/usr/src/linux-headers-5.19.0-41-generic/ --enable-ldiskfs --with-zfs=[zfs源代码path]
make -j$(nproc)
make debs -j$(proc)
Lustre is a shared disk file system, generally used for large scale cluster computing. The name Lustre is a portmanteau of Linux and cluster. The project aims to provide a file system for clusters of tens of thousands of nodes with petabytes of storage capacity, without compromising speed or security. Lustre is available under the GNU GPL.Lustre is designed, developed and maintained by Sun Microsystems, Inc. with input from many other individuals and companies. Sun completed its acquisition of Cluster File Systems, Inc., including the Lustre file system, on October 2, 2007, with the intention of bringing the benefits of Lustre technologies to Sun's ZFS file system and the Solaris operating system.Lustre file systems are used in computer clusters ranging from small workgroup clusters to large-scale, multi-site clusters. Fifteen of the top 30 supercomputers in the world use Lustre file systems, including the world's fastest supercomputer, the Blue Gene/L at Lawrence Livermore National Laboratory (LLNL). Other supercomputers that use the Lustre file system include systems at Oak Ridge National Laboratory, Pacific Northwest National Laboratory, and Los Alamos National Laboratory in North America, the largest system in Asia at Tokyo Institute of Technology, and the largest system in Europe at CEA.Lustre file systems can support up to tens of thousands of client systems, petabytes (PBs) of storage and hundreds of gigabytes per second (GB/s) of I/O throughput. Businesses ranging from Internet service providers to large financial institutions deploy Lustre file systems in their datacenters. Due to the high scalability of Lustre file systems, Lustre deployments are popular in the oil and gas, manufacturing, rich media and finance sectors.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值