最开始用的 NFS 作为跨节点文件共享系统,后来发现其对于并行IO(MPI IO)支持不佳,导致跨节点读写HDF5文件性能不佳。尝试切换Lustre并行文件系统,数据显示稳定且性能更佳。本文简要介绍CentOS 7安装Lustre并行文件系统。
Lustre简介
Lustre是一个开源、高可用、高性能和高可拓展性的分布式并行文件系统,支持数万客户端、PB级存储容量和数百GB/s的聚合IO带宽,被广泛用在天河二号等超算系统上。Lustre的官网是:http://lustre.org/。
Lustre基本组件包括:
- MGS(Management Server,管理服务端):存储集群中所有Lustre文件的配置信息,并为其他Lustre组件和Lustre客户端提供信息
- MDS(Metadata Server,元数据服务端):存储和管理Lustre文件系统中的名称和目录,并为一个或多个MDT(Metadata Target,元数据目标)提供网络请求
- OSS(Object Storage Server,对象存储服务端):处理一个或多个本地OST(Object Storage Target)的文件IO服务和网络请求
- Lustre客户端:运行Lustre软件的节点,可以挂载Lustre文件系统
- LNet(Lustre Networking,Lustre网络):用于Lustre客户端和服务端之间的通信,支持常见的InfiniBand(IB)和TCP网络。
以上组件在配置过程中会用到,更多组件和概念介绍可参考 Lustre官网 或网上资料。
CentOS 7安装Lustre并行文件系统
尽管CentOS 7不再维护,但其仍在许多内部系统中被大量使用。本节介绍在CentOS 7安装Lustre并行文件系统。
首先,无论是Lustre的MGS/MDS所在服务器、OSS/OST服务器、或者Lustre客户端,都需要支持Lustre文件系统。为了实现这个目标,需要安装支持Lustre文件系统的内核(Lustre客户端不需要支持Lustre的内核,为了简便本文在各个节点上都安装patch了Lustre的内核)。动手能力强的做法是下载Lustre和内核源码编译安装,另一种更简便的方法是安装已经编译好的内核。本文介绍后一种方法。
安装Lustre内核
根据目前网上的资料,能下载到Lustre内核的最佳源是 Whamcloud(Intel的源已经无法访问)。CentOS 7是过时老旧的系统,支持该系统的Lustre的最高版本是2.13.0,本教程后续都基于这个版本的内核。
在 /etc/yum.repos.d
文件夹下新建 lustre.repo
文件,输入以下内容:
[lustre-server] name=lustre-server baseurl=https://downloads.whamcloud.com/public/lustre/lustre-2.13.0/el7/server # exclude=*debuginfo* gpgcheck=0 [lustre-client] name=lustre-client baseurl=https://downloads.whamcloud.com/public/lustre/lustre-2.13.0/el7/client # exclude=*debuginfo* gpgcheck=0 [e2fsprogs-wc] name=e2fsprogs-wc baseurl=https://downloads.whamcloud.com/public/e2fsprogs/latest/el7 # exclude=*debuginfo* gpgcheck=0
如果希望切换其他版本的Lustre,修改上述文件中的 2.13.0 为其它版本号。如果需要更高版本,可能需要自行编译。
接着升级 e2fsprogs
工具(e2fsprogs
是维护 ext2/3/4 文件系统的工具集,包含多个独立程序):
sudo yum upgrade -y e2fsprogs
一些教程包括官网教程要求基于ZFS文件系统,但实际ext4也是可以的,本教程在ext4文件系统上安装Lustre并行文件系统
接下来安装Lustre文件系统的内核包,为了方便,直接安装 lustre-tests
包:
sudo yum install -y lustre-tests # 也可以分别安装 # 先安装patch了Lustre的内核包 sudo yum --nogpgcheck --disablerepo=base,extras,updates \ --enablerepo=lustre-server install \ kernel \ kernel-devel \ kernel-headers \ kernel-tools \ kernel-tools-libs \ kernel-tools-libs-devel # 接着安装 LDISKFS kmod 和其它Lustre包 sudo yum --nogpgcheck --enablerepo=lustre-server install \ kmod-lustre \ kmod-lustre-osd-ldiskfs \ lustre-osd-ldiskfs-mount \ lustre \
接着创建 LNet 模块配置。编辑 /etc/modprobe.d/lnet.conf
文件,输入以下内容:
options lnet networks=tcp0(eth0)
其中tcp0可以自定义,例如IB网络可以为ib0,eth0是网络接口名称,请改成机器上激活的网络接口名称
接着重启系统,让支持Lustre的内核生效:sudo reboot
。
配置MGS/MDT/MDS/OSS/OST
在MGS/MDT/MDS节点上,需要一块单独的硬盘或者分区格式化成Lustre文件系统,该分区容量不需要很大。创建一个MDT并挂载:
# sdX请换成实际的硬盘或者分区 # fsname名称可以自定义,这里是lustre sudo mkfs.lustre --fsname=lustre --reformat --mgs --mdt --index=0 /dev/sdX # 创建挂载点并挂载 sudo mkdir /mnt/mdt && sudo mount -t lustre /dev/sdX /mnt/mdt
接着配置OSS/OST节点,同样需要一块单独的硬盘或者分区,建议使用大容量硬盘。创建一个OST并挂载:
# 同样,sdX请换成实际硬盘或者分区 # fsname请与MGS中的保持一致, mgsnode中的ip填MGS的ip(不能是127.0.0.1),tcp0是上文中说的网络接口名称 sudo mkfs.lustre --ost --fsname=lustre --mgsnode=192.168.N.N@tcp0 --index=0 /dev/sdX # 创建挂载点并挂载 sudo mkdir /ostoss_mount && sudo mount -t lustre /dev/sdX /ostoss_mount
为了让MGS和OSS节点上的 LNet 模块自动加载,创建一个配置文件并赋予可执行权限:
# create script to load lnet module on boot sudo sh -c 'cat > /etc/sysconfig/modules/lnet.module' <<EOF #!/bin/sh if [ ! -c /dev/lnet ] ; then exec /sbin/modprobe lnet >/dev/null 2>&1 fi EOF sudo chmod 744 /etc/sysconfig/modules/lnet.module
到此,MGS/MDS/OSS节点上的Lustre环境配置就完成了。如果有多个OSS节点,需要分别在各个节点上运行。
配置Lustre客户端
Lustre客户端首先需要加载Lustre模块:sudo modprobe luste
,同时配置开机加载:
# create script to load Lustre module on boot sudo sh -c 'cat > /etc/sysconfig/modules/lustre.modules' <<EOF #!/bin/sh /sbin/lsmod | /bin/grep lustre 1>/dev/null 2>&1 if [ ! $? ] ; then /sbin/modprobe lustre >/dev/null 2>&1 fi EOF sudo chmod 744 /etc/sysconfig/modules/lustre.modules
然后创建挂载点和挂载Lustre文件系统:
sudo mkdir /mnt/lustre # 把192.168.N.N改成MGS的实际ip # 如果MGS和OSS中的fsname不是lustre,需要把 tcp0:/lustre 改成实际的网络接口名称和文件系统名 sudo mount -t lustre 192.168.N.N@tcp0:/lustre /mnt/lustre
至此,客户端也完全配置好,可以正常使用了。可以使用 lctl、lfs 等命令查看信息:
# 显示网络id情况 lctl list_nids # 显示设置列表 lctl device_list # 显示存储使用情况 lfs df
参考
1. Installing the Lustre Software
3. Three-Node-LustreFS-Cluster-Quickstart-Centos7.md
发表回复