高性能分佈式存儲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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章