暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

深入学习下Lustre文件布局上篇

215



作者时间QQ技术交流群
perrynzhou@gmail.com2022/05/20672152841




实验环境

类型版本节点
Lustre Server4.18.0-240.1.1.el8_lustre.x86_64,lustre-2.14.010.211.55.6
Lustre Client4.18.0-240.1.1.el8_lustre.x86_64,lustre-2.14.010.211.55.3
节点磁盘类型挂载点
10.211.55.6Lustre ServerMDTmount-lustre:/mgt_mdt,mount-ldiskfs:/mnt/mgt_mdt
10.211.55.6Lustre ServerOST0mount-lustre:/ost0,mount-ldiskfs:/mnt/ost0
10.211.55.6Lustre ServerOST1mount-lustre:/ost1,mount-ldiskfs:/mnt/ost1
10.211.55.6Lustre ServerOST2mount-lustre:/ost2,mount-ldiskfs:/mnt/ost2


测试环境设置

    创建2个目录,一个是/mnt/lustre/dir1
默认是布局
;另外一个是/mnt/lustre/dir2
设置stripe_count=3,stripe_size=1M
.然后分别在2个文件夹下拷贝大于1M
的文件,然后在MDT
OST
观察写入新文件的布局。


[root@CentOS-Lustre-Client ~]$ ls -l -1h lustre.log 
-rw-r--r--. 1 root root 1.1M Jun 22 13:01 lustre.log[root@CentOS-Lustre-Client ~]$ md5sum lustre.log
7b63e9404abf294f25ef692604b8a360 lustre.log[root@CentOS-Lustre-Client ~]$
[root@CentOS-Lustre-Client ~]$ mkdir mnt/lustre/dir1[root@CentOS-Lustre-Client ~]$ mkdir mnt/lustre/dir2[root@CentOS-Lustre-Client ~]$ lfs setstripe -c 3 mnt/lustre/dir2[root@CentOS-Lustre-Client ~]$
[root@CentOS-Lustre-Client ~]$ lfs getstripe mnt/lustre/dir1
/mnt/lustre/dir1
stripe_count: 1 stripe_size: 1048576 pattern: 0 stripe_offset: -1[root@CentOS-Lustre-Client ~]$ lfs getstripe mnt/lustre/dir2
/mnt/lustre/dir2
stripe_count: 3 stripe_size: 1048576 pattern: raid0 stripe_offset: -1[root@CentOS-Lustre-Client ~]$ cp lustre.log mnt/lustre/dir1/[root@CentOS-Lustre-Client ~]$ cp lustre.log mnt/lustre/dir2/


文件
布局概览


MDT
端分析


O
目录说明


// MGT和MDT共享一个磁盘,/mnt/mgt_mdt下的O是数据目录,其中1 是未命名log,10是命名log,200000003 是本地命令对象用于lustre内部使用[root@CentOS-Lustre-Server mnt/mgt_mdt/O]$ tree ./ -L 1./
├── 1├── 10└── 200000003


ROOT
目录说明


// 挂载点的ROOT目录是lustre所有的客户端看到的fs的统一视图
//
[root@CentOS-Lustre-Server mnt/mgt_mdt/ROOT]$ tree ./
./
├── dir1
│ └── lustre.log
└── dir2
└── lustre.log2 directories, 2 files


dir1
属性


[root@CentOS-Lustre-Server mnt/mgt_mdt/ROOT]$ getfattr -d -m ".*"  ./dir1# file: dir1security.selinux="unconfined_u:object_r:unlabeled_t:s0"trusted.link=0s3/HqEQEAAAAuAAAAAAAAAAAAAAAAAAAAABYAAAACAAAABwAAAAEAAAAAZGlyMQ==trusted.lma=0sAAAAAAAAAADRCwAAAgAAAAEAAAAAAAAA[root@CentOS-Lustre-Server mnt/mgt_mdt/ROOT]$ getfattr -d -m ".*"  ./dir1/lustre.log 
# file: dir1/lustre.logsecurity.selinux="unconfined_u:object_r:unlabeled_t:s0"trusted.link=0s3/HqEQEAAAA0AAAAAAAAAAAAAAAAAAAAABwAAAACAAAL0QAAAAEAAAAAbHVzdHJlLmxvZw==trusted.lma=0sAAAAAAAAAADRCwAAAgAAAAMAAAAAAAAA
trusted.lov=0s0AvRCwEAAAADAAAAAAAAANELAAACAAAAAAAQAAEAAAAiAAAAAAAAAAAAAAAAAAAAAAAAAAIAAAA=trusted.som=0sBAAAAAAAAACtFBAAAAAAAAAAAAAAAAAA


OST
端分析


dir1/lustre.log
目录下文件分析

  • MDT
    端不同的是OST
    中的O
    存储的是实际的数据分片,接下来查看lustre.log
    的数据文件分布情况.如下是客户端视角查看lustre.log的布局,从下面信息看出文件位于ost1
    中的O/{grop}/d{objid%32}/34
    这个文件(O/0/d2/34)就是这个文件的分片


[root@CentOS-Lustre-Client ~]$ lfs getstripe  mnt/lustre/dir1/lustre.log 
/mnt/lustre/dir1/lustre.log
// 分片数量
lmm_stripe_count: 1// 每个分片的大小,默认是1M
lmm_stripe_size: 1048576// 采用raid0方式布局
lmm_pattern: raid0
// 文件布局改变的次数
lmm_layout_gen: 0lmm_stripe_offset: 2// objidx是位于哪个ost(index=2),objid是文件分片名称,一个是十进制,一个是16进制;group是数据在O这个文件夹下哪个目录
obdidx objid objid group 2 34 0x22 0
  • 核对文件的数据校验,lustre.log的md5校验值是7b63e9404abf294f25ef692604b8a360
    ,我们验证下ost2
    上面的O/0/d2/34
    和lustre.log的同一个文件,从下面结果发现是同一个文件。


// 进入ost1的以ldiskfs的挂载[root@CentOS-Lustre-Server mnt/ost0/O]$ cd mnt/ost2/O/0/d2[root@CentOS-Lustre-Server mnt/ost2/O/0/d2]$ ls -l
total 1032-rwSrwSrwT 1 root root 0 Dec 31 1969 2-rw-rw-rw- 1 root root 1053869 Jun 22 01:20 34[root@CentOS-Lustre-Server mnt/ost2/O/0/d2]$
// 这里查看是同一个文件[root@CentOS-Lustre-Server mnt/ost2/O/0/d2]$ md5sum 347b63e9404abf294f25ef692604b8a360 34[root@CentOS-Lustre-Server mnt/ost2/O/0/d2]$
  • dir1/lustre.log
    的文件属性


[root@CentOS-Lustre-Server mnt/ost2/O/0/d2]$ getfattr -d -m ".*" ./34# file: 34trusted.fid=0s0QsAAAIAAAADAAAAAAAAAAAAEAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==trusted.lma=0sCAAAAAAAAAAAAAIAAQAAACIAAAAAAAAA


dir2/lustre.log
目录下文件分析

  • dir2
    下的目录是采用3
    个分片的设置,接下来看下这个文件的布局信息。这个文件分别在ost0上的/mnt/ost0/O/0/d2/34
    、ost1上的/mnt/ost1/O/0/d2/34
    、ost2上的/mnt/ost2/O/0/d3/35
    这三个分片。ost0上的是一个空的文件,数据集中在ost1和ost2上


[root@CentOS-Lustre-Client ~]$ lfs getstripe  /mnt/lustre/dir2/lustre.log 
/mnt/lustre/dir2/lustre.log
lmm_stripe_count: 3lmm_stripe_size: 1048576lmm_pattern: raid0
lmm_layout_gen: 0lmm_stripe_offset: 1
obdidx objid objid group 1 34 0x22 0
2 35 0x23 0
0 34 0x22 0


// 查看lustre后端的ost0/ost1/ost2上面的lustre.log的数据分片[root@CentOS-Lustre-Server /mnt/ost1/O/0/d2]$ ls -l /mnt/ost0/O/0/d2/34
-rwSrwSrwT 1 root root 0 Dec 31 1969 /mnt/ost0/O/0/d2/34[root@CentOS-Lustre-Server /mnt/ost1/O/0/d2]$ ls -l /mnt/ost1/O/0/d2/34
-rw-rw-rw- 1 root root 1048576 Jun 22 01:20 /mnt/ost1/O/0/d2/34[root@CentOS-Lustre-Server /mnt/ost1/O/0/d2]$ ls -l /mnt/ost2/O/0/d3/35
-rw-rw-rw- 1 root root 5293 Jun 22 01:20 /mnt/ost2/O/0/d3/35

// 聚合文件到1这个文件,然后比对md5的值[root@CentOS-Lustre-Server ~]$ cat /mnt/ost1/O/0/d2/34 >> ~/lustre_tmp.log[root@CentOS-Lustre-Server ~]$ cat /mnt/ost2/O/0/d3/35 >> ~/lustre_tmp.log[root@CentOS-Lustre-Server ~]$ sync// 最终发现这2个文件的md5是同一个文件内容[root@CentOS-Lustre-Server ~]$ md5sum lustre.log
7b63e9404abf294f25ef692604b8a360 lustre.log[root@CentOS-Lustre-Server ~]$ md5sum lustre_tmp.log
7b63e9404abf294f25ef692604b8a360 lustre_tmp.log
  • dir2/lustre.log
    的文件属性


[root@CentOS-Lustre-Server ~]$ getfattr -d -m ".*"  /mnt/ost1/O/0/d2/34
getfattr: Removing leading '/' from absolute path names# file: mnt/ost1/O/0/d2/34trusted.fid=0s0QsAAAIAAAAEAAAAAAAAAAAAEAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==trusted.lma=0sCAAAAAAAAAAAAAEAAQAAACIAAAAAAAAA[root@CentOS-Lustre-Server ~]$ getfattr -d -m ".*" /mnt/ost2/O/0/d3/35
getfattr: Removing leading '/' from absolute path names# file: mnt/ost2/O/0/d3/35trusted.fid=0s0QsAAAIAAAAEAAAAAQAAAAAAEAADAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA==trusted.lma=0sCAAAAAAAAAAAAAIAAQAAACMAAAAAAAAA


文章转载自存储内核技术交流,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论