1.单机Lustre的搭建:
主机名 | IP地址 | 内存 | 添加的共享磁盘大小 |
---|---|---|---|
Centos7.9-test机 | 192.168.10.30/24 | 1G | 20G |
1.安装E2fsprogs包
-
下载OSS服务器所需要的包:E2fsprogs包只是在Ext4的原版RPM包基础上增加了对Lustre⽀持
mkdir ~/e2fsprogs && cd ~/e2fsprogs wget -c -r -nd https://downloads.whamcloud.com/public/e2fsprogs/1.44.5.wc1/el7/RPMS/x86_64/ rm -rf index.html* unknown.gif *.gif sha256sum
-
全部rpm安装:
[root@slave1 e2fsprogs]# cd ~/e2fsprogs && rpm -Uvh * 准备中... ################################# [100%] 正在升级/安装... 1:libcom_err-1.42.12.wc1-4.el7.cent################################# [ 8%] 2:e2fsprogs-libs-1.42.12.wc1-4.el7.################################# [ 15%] 3:libcom_err-devel-1.42.12.wc1-4.el################################# [ 23%] 4:libss-1.42.12.wc1-4.el7.centos ################################# [ 31%] 5:e2fsprogs-1.42.12.wc1-4.el7.cento################################# [ 38%] 6:libss-devel-1.42.12.wc1-4.el7.cen################################# [ 46%] 7:e2fsprogs-devel-1.42.12.wc1-4.el7################################# [ 54%] 8:e2fsprogs-static-1.42.12.wc1-4.el################################# [ 62%] 9:e2fsprogs-debuginfo-1.42.12.wc1-4################################# [ 69%] 正在清理/删除... 10:e2fsprogs-1.42.9-19.el7 ################################# [ 77%] 11:e2fsprogs-libs-1.42.9-19.el7 ################################# [ 85%] 12:libss-1.42.9-19.el7 ################################# [ 92%] 13:libcom_err-1.42.9-19.el7 ################################# [100%]
2.安装lustre包:
-
下载MDS服务器所需要的包:
wget命令参数 说明 -c 断点续传 -r 递归下载 -nd 不分层,所有文件下载到当前目录下 rpm包 说明 kernel-*.el7_lustre.x86_64.rpm 带 Lustre 补丁的 Linux 内核 kmod-lustre-*.el7.x86_64.rpm Lustre 补丁内核模块 kmod-lustre-osd-ldiskfs-*.el7.x86_64.rpm 基于 ldiskfs 的 Lustre 后端文件系统工具 lustre-*.el7.x86_64.rpm Lustre 软件命令行工具 lustre-osd-ldiskfs-mount-*.el7.x86_64.rpm 基于ldiskfs 的 mount.lustre和mkfs。lustre相关帮助文档 mkdir ~/lustre2.12.1 && cd ~/lustre2.12.1 yum install -y wget wget \ https://downloads.whamcloud.com/public/lustre/lustre-2.12.1/el7/server/RPMS/x86_64/kernel-3.10.0-957.10.1.el7_lustre.x86_64.rpm \ https://downloads.whamcloud.com/public/lustre/lustre-2.12.1/el7/server/RPMS/x86_64/kmod-lustre-2.12.1-1.el7.x86_64.rpm \ https://downloads.whamcloud.com/public/lustre/lustre-2.12.1/el7/server/RPMS/x86_64/kmod-lustre-osd-ldiskfs-2.12.1-1.el7.x86_64.rpm \ https://downloads.whamcloud.com/public/lustre/lustre-2.12.1/el7/server/RPMS/x86_64/lustre-2.12.1-1.el7.x86_64.rpm \ https://downloads.whamcloud.com/public/lustre/lustre-2.12.1/el7/server/RPMS/x86_64/lustre-osd-ldiskfs-mount-2.12.1-1.el7.x86_64.rpm
-
安装依赖(否则报错error: Failed dependencies:):
yum clean all && yum repolist yum install -y linux-firmware dracut selinux-policy-targeted kexec-tools libyaml perl
-
全部rpm安装:(如果无法安装就强行安装)
cd ~/lustre2.12.1 && rpm -ivh *.rpm --force
-
重启服务器:
init 6
-
检查内核:
[root@master ~]# uname -r 3.10.0-957.el7_lustre.x86_64
-
加载Lustre模块:lustre_rmmod卸载模块
[root@master ~]# modprobe lustre [root@master ~]# lsmod | grep lustre lustre 758679 0 lmv 177987 1 lustre mdc 232938 1 lustre lov 314581 1 lustre ptlrpc 2264705 7 fid,fld,lmv,mdc,lov,osc,lustre obdclass 1962422 8 fid,fld,lmv,mdc,lov,osc,lustre,ptlrpc lnet 595941 6 lmv,osc,lustre,obdclass,ptlrpc,ksocklnd libcfs 421295 11 fid,fld,lmv,mdc,lov,osc,lnet,lustre,obdclass,ptlrpc,ksocklnd
3.格式化和挂载:
-
添加一块20G的硬盘
-
GPT分区:
使用fdisk命令中的帮助查看可以操作的指令,其中m查看帮助、n创建分区、p查看分区情况、t修改分区类型、w保存退出。
[root@master ~]# fdisk /dev/sdb 欢迎使用 fdisk (util-linux 2.23.2)。 更改将停留在内存中,直到您决定将更改写入磁盘。 使用写入命令前请三思。 Device does not contain a recognized partition table 使用磁盘标识符 0xa44e96c5 创建新的 DOS 磁盘标签。 命令(输入 m 获取帮助):
[root@master ~]# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT sda 8:0 0 20G 0 disk ├─sda1 8:1 0 1G 0 part /boot └─sda2 8:2 0 19G 0 part ├─centos-root 253:0 0 17G 0 lvm / └─centos-swap 253:1 0 2G 0 lvm [SWAP] sdb 8:16 0 20G 0 disk ├─sdb1 8:17 0 5G 0 part ├─sdb2 8:18 0 5G 0 part └─sdb3 8:19 0 5G 0 part sr0 11:0 1 9.5G 0 rom
-
当OSS服务器硬盘添加并分区后,Lustre格式化:
Lustre格式化参数 说明 --fsname 设置Lustre集群的名称,Lustre文件系统的标识,必须唯一 --mgsnode mgs节点的IP地址 --mgs 将分区格式化为MGS,MGS(ManaGe Server)是⽤来记录整个Lustre状态的服务 --mdt 将分区格式化为MDT,MDT(MetaData Target)是存放Lustre元数据服务的设备 --ost 将分区格式化为OST,OST(Object Storage Target)则是存储Lustre数据的设备 --reformat 跳过检查,防止格式化操作清除已有的数据 [root@master ~]# mkfs.lustre --mgs --mgsnode=192.168.10.23@tcp --backfstype=ldiskfs --reformat /dev/sdb1 Permanent disk data: Target: MGS Index: unassigned Lustre FS: Mount type: ldiskfs Flags: 0x64 (MGS first_time update ) Persistent mount opts: user_xattr,errors=remount-ro Parameters: mgsnode=192.168.10.20@tcp checking for existing Lustre data: not found device size = 5120MB formatting backing filesystem ldiskfs on /dev/sdb1 target name MGS 4k blocks 1310720 options -q -O uninit_bg,dir_nlink,quota,huge_file,flex_bg -E lazy_journal_init -F mkfs_cmd = mke2fs -j -b 4096 -L MGS -q -O uninit_bg,dir_nlink,quota,huge_file,flex_bg -E lazy_journal_init -F /dev/sdb1 1310720 Writing CONFIGS/mountdata
[root@master ~]# mkfs.lustre --fsname global --mdt --index=0 --mgsnode=192.168.10.23@tcp --backfstype=ldiskfs --reformat /dev/sdb2 Permanent disk data: Target: global:MDT0000 Index: 0 Lustre FS: global Mount type: ldiskfs Flags: 0x61 (MDT first_time update ) Persistent mount opts: user_xattr,errors=remount-ro Parameters: mgsnode=192.168.10.20@tcp checking for existing Lustre data: not found device size = 5120MB formatting backing filesystem ldiskfs on /dev/sdb2 target name global:MDT0000 4k blocks 1310720 options -J size=204 -I 1024 -i 2560 -q -O dirdata,uninit_bg,^extents,dir_nlink,quota,huge_file,flex_bg -E lazy_journal_init -F mkfs_cmd = mke2fs -j -b 4096 -L global:MDT0000 -J size=204 -I 1024 -i 2560 -q -O dirdata,uninit_bg,^extents,dir_nlink,quota,huge_file,flex_bg -E lazy_journal_init -F /dev/sdb2 1310720 Writing CONFIGS/mountdata
[root@master ~]# mkfs.lustre --fsname global --ost --index=0 --mgsnode=192.168.10.23@tcp --backfstype=ldiskfs --reformat /dev/sdb3 Permanent disk data: Target: global:OST0000 Index: 0 Lustre FS: global Mount type: ldiskfs Flags: 0x62 (OST first_time update ) Persistent mount opts: ,errors=remount-ro Parameters: mgsnode=192.168.10.20@tcp checking for existing Lustre data: not found device size = 5120MB formatting backing filesystem ldiskfs on /dev/sdb3 target name global:OST0000 4k blocks 1310720 options -J size=204 -I 512 -q -O extents,uninit_bg,dir_nlink,quota,huge_file,flex_bg -G 256 -E resize="4290772992",lazy_journal_init -F mkfs_cmd = mke2fs -j -b 4096 -L global:OST0000 -J size=204 -I 512 -q -O extents,uninit_bg,dir_nlink,quota,huge_file,flex_bg -G 256 -E resize="4290772992",lazy_journal_init -F /dev/sdb3 1310720 Writing CONFIGS/mountdata
-
格式化之后,挂载Lustre文件系统(mgs,mdt,ost)和客户端:-t指定文件系统的类型
[root@localhost ~]# mkdir /mnt/sdb1;mkdir /mnt/sdb2;mkdir /mnt/sdb3;mkdir /mnt/global1;mkdir /mnt/global2 mount -t lustre /dev/sdb1 /mnt/sdb1 mount -t lustre /dev/sdb2 /mnt/sdb2;mount -t lustre /dev/sdb3 /mnt/sdb3 mount -t lustre 192.168.10.23@tcp:/global /mnt/global1;mount -t lustre 192.168.10.23@tcp:/global /mnt/global2
cat << eof >> /etc/fstab /dev/sdb1 /mnt/sdb1 lustre defaults 0 0 /dev/sdb2 /mnt/sdb2 lustre defaults 0 0 /dev/sdb3 /mnt/sdb3 lustre defaults 0 0 192.168.10.23@tcp:/global /mnt/global1 lustre defaults 0 0 192.168.10.23@tcp:/global /mnt/global2 lustre defaults 0 0 eof
-
查看Lustre的挂载情况:
[root@localhost ~]# mount | grep lustre /dev/sdb1 on /mnt/sdb1 type lustre (ro,svname=MGS,nosvc,mgs,osd=osd-ldiskfs,user_xattr,errors=remount-ro) /dev/sdb2 on /mnt/sdb2 type lustre (ro,svname=global-MDT0000,mgsnode=192.168.10.30@tcp,osd=osd-ldiskfs,user_xattr,errors=remount-ro) /dev/sdb3 on /mnt/sdb3 type lustre (ro,svname=global-OST0000,mgsnode=192.168.10.30@tcp,osd=osd-ldiskfs,errors=remount-ro) 192.168.10.30@tcp:/global on /mnt/global type lustre (rw,lazystatfs) 192.168.10.30@tcp:/global on /mnt/global2 type lustre (rw,lazystatfs)
4.测试:
-
在/mnt/global客户端处,创建文件并写数据:
[root@localhost ~]# echo "Hello Lustre,I am client1" > /mnt/global/first_file