高性能分布式存储Lustre

前言

近些年,分布式存储因具有高性能、高可用的特性而进入存储市场。除商业产品外,开源分布式存储软件更受欢迎,其中以Lustre、CephFS、GlusterFS为典型代表。

1.简介

Lustre是一个开源、分布式并行文件系统软件平台,具有高可扩展、高性能、高可用等特点。Lustre的构造目标是为大规模高性能计算系统提供一个全局一致的POSIX兼容的命名空间,它支持数百PB数据存储空间,支持数百GB/s乃至数TB/s并发聚合带宽。

1.1环境架构

高性能分布式存储Lustre
MGS(Management Server,管理服务端),MGS存储集群中的所有Lustre文件的配置信息,并为其它Lustre组件提供信息。
MDS(Metadata Servers,元数据服务端),MDS使得元数据对客户端有效,每个MDS管理Lustre文件系统中的名称和目录。
OSS(Object Storage Servers,对象存储服务端),OSS用于存放客户端业务访问数据。

1.2网络规划

高性能分布式存储Lustre

2.环境准备

注:在所有主机执行如下操作

1.设置主机名

hostnamectl set-hostname node1

2.关闭firewalld及selinux

systemctl stop firewalld  && systemctl disable firewalld
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config

3.创建临时yum源

cat >/tmp/lustre-repo.conf <<EOF
[lustre-server]
name=lustre-server
baseurl=https://downloads.whamcloud.com/public/lustre/latest-release/el7/server
gpgcheck=0

[lustre-client]
name=lustre-client
baseurl=https://downloads.whamcloud.com/public/lustre/latest-release/el7/client
gpgcheck=0

[e2fsprogs-wc]
name=e2fsprogs-wc
baseurl=https://downloads.whamcloud.com/public/e2fsprogs/latest/el7
gpgcheck=0
EOF

4.安装相关工具包

yum install yum-utils createrepo perl linux-firmware -y

5.提前将软件包下载到本地

mkdir -p /var/www/html/repo
cd /var/www/html/repo
reposync -c /tmp/lustre-repo.conf -n \
-r lustre-server \
-r lustre-client \
-r e2fsprogs-wc

6.创建本地lustre的yum源

cd /var/www/html/repo
for i in e2fsprogs-wc lustre-client lustre-server; do
(cd $i && createrepo .)
done

7.创建本地lustre源配置文件

cat > /etc/yum.repos.d/CentOS-lustre.repo <<EOF
[lustre-server]
name=lustre-server
baseurl=file:///var/www/html/repo/lustre-server/
enabled=0
gpgcheck=0

[lustre-client]
name=lustre-client
baseurl=file:///var/www/html/repo/lustre-client/
enabled=0
gpgcheck=0

[e2fsprogs-wc]
name=e2fsprogs-wc
baseurl=file:///var/www/html/repo/e2fsprogs-wc/
enabled=0
gpgcheck=0
EOF

8.查看repo

yum repolist all

2.服务端配置

注:在所有服务端主机执行如下操作

1.安装efs2progs

yum --nogpgcheck --disablerepo=* --enablerepo=e2fsprogs-wc \
install e2fsprogs -y

2.卸载内核冲突包

yum remove selinux-policy-targeted -y

3.安装并升级内核

yum --nogpgcheck --disablerepo=base,extras,updates \
--enablerepo=lustre-server install \
kernel \
kernel-devel \
kernel-headers \
kernel-tools \
kernel-tools-libs 

4.重启机器

reboot

5.安装ldiskfs kmod和lustre包

yum --nogpgcheck --enablerepo=lustre-server install \
kmod-lustre \
kmod-lustre-osd-ldiskfs \
lustre-osd-ldiskfs-mount \
lustre \
lustre-resource-agents

6.加载lustre到内核

modprobe -v lustre
modprobe -v ldiskfs
echo 'options lnet networks=tcp0(ens1f1)' > /etc/modprobe.d/lustre.conf
depmod -a

3.客户端配置

注:只在客户端主机上操作

客户端主机安装lustre客户端软件,无需升级带有lustre的内核,直接安装lustre-client即可
1.安装kmod

yum --nogpgcheck --enablerepo=lustre-client install \
kmod-lustre-client \
lustre-client

2.加载lustre参数

echo ' options lnet networks=tcp0(ens1f1)' > /etc/modprobe.d/lustre.conf
depmod -a
modprobe lustre

4.创建Lustre文件系统

配置说明:
--fsname:指定生成后的lustre文件系统名,如sgfs,将来客户端采用mount -t 192.168.100.1@tcp0:192.168.100.2@tcp0:/sgfs /home进行挂载。br/>--mgs:指定为MGS分区
--mgt:指定为MGT分区
--ost:指定为OST分区
--servicenode=ServiceNodeIP@tcp0:指定本节点失效时,接手提供服务的节点,如为InfiniBand网络,那么tcp0需要换成o2ib
--index:指定索引,不能相同
建立MGS和MGT(注:在服务端MGS主机node1上执行)

mkdir -p /data/mdt
mkfs.lustre --fsname=lufs --mgs --mdt --index=0 --servicenode=10.10.201.61@tcp0 --reformat /dev/sdb
mount -t lustre /dev/sdb /data/mdt/

建立OST1(注:在服务端OSS主机node2上执行)

mkdir /data/ost1 –p
mkfs.lustre --fsname=sgfs --mgsnode=10.10.201.61@tcp0 --servicenode=10.10.201.62@tcp0 --servicenode=10.10.201.63@tcp0 --ost --reformat --index=1 /dev/sdb
mount -t lustre /dev/sdb /data/ost1/

建立OST2(注:在服务端OSS主机node3上执行)

mkdir /data/ost2 -p
mkfs.lustre --fsname=sgfs --mgsnode=10.10.201.61@tcp0 --servicenode=10.10.201.63@tcp0 --servicenode=10.10.201.62@tcp0 --ost --reformat --index=2 /dev/sdb
mount -t lustre /dev/sdb /data/ost2/

5.客户端挂载访问

客户端创建挂载目录并进行挂载访问。(注:在客户端主机node4上执行)

mkdir /lustre/sgfs/
mount.lustre 10.10.201.61@tcp0:/sgfs /lustre/sgfs/

如果挂载失败,可用lctl命令检查网络连接,并查看系统日志排查。

lctl ping 10.10.201.61@tcp0

查看是否挂载成功

df -ht lustre

6.常见问题处理

报错1:

[root@node1 ~]# modprobe -v lustre
insmod /lib/modules/3.10.0-957.10.1.el7_lustre.x86_64/extra/lustre/net/libcfs.ko 
insmod /lib/modules/3.10.0-957.10.1.el7_lustre.x86_64/extra/lustre/net/lnet.ko 
insmod /lib/modules/3.10.0-957.10.1.el7_lustre.x86_64/extra/lustre/fs/obdclass.ko 
insmod /lib/modules/3.10.0-957.10.1.el7_lustre.x86_64/extra/lustre/fs/ptlrpc.ko 
modprobe: ERROR: could not insert 'lustre': Cannot allocate memory

错误原因:服务器有2颗CPU,一颗CPU没有插内存条,表现如下

[root@node2 ~]# numactl -H
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 20 21 22 23 24 25 26 27 28 29
node 0 size: 0 MB
node 0 free: 0 MB
node 1 cpus: 10 11 12 13 14 15 16 17 18 19 30 31 32 33 34 35 36 37 38 39
node 1 size: 32654 MB
node 1 free: 30680 MB
node distances:
node   0   1 
  0:  10  20 
  1:  20  10

重新插拔内存后调整状态

[root@node1 ~]# numactl -H
available: 2 nodes (0-1)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 20 21 22 23 24 25 26 27 28 29
node 0 size: 16270 MB
node 0 free: 15480 MB
node 1 cpus: 10 11 12 13 14 15 16 17 18 19 30 31 32 33 34 35 36 37 38 39
node 1 size: 16384 MB
node 1 free: 15504 MB
node distances:
node   0   1 
  0:  10  21 
  1:  21  10

参考解决办法:
https://jira.whamcloud.com/browse/LU-11163

欢迎扫码提问,可在线解答。会定期分享虚拟化、容器、DevOps等相关内容
高性能分布式存储Lustre

猜你喜欢

转载自blog.51cto.com/9099998/2445847