Contenu connexe Similaire à Cephfs架构解读和测试分析 (20) Cephfs架构解读和测试分析5. CephFS简介
• 可扩展性
• client读写OSDs
• 共享文件系统
• 多个clients可以同时读写
• 高可用
• MDSs集群,Aactive/Standby MDSs
• 文件/目录Layouts
• 支持配置文件/目录的Layouts使用不同的pool
• POSIX ACLs
• CephFS kernel client默认支持,CephFS FUSE client可配置支持
• Client Quotas
• CephFS FUSE client支持配置任何目录的Quotas
8. CephFS - MDS
• Dynamic subtree placement
• 目录分片级调度
• Traffic Control
• 热度负载均衡
• 客户端缓存“目录-MDS”映射
关系
元数据存储
• per-MDS journals
• Write to OSD cluster
• MetaData
• Write to OSD cluster
10. CephFS Client访问示例
1. Client发送open file请求给MDS
2. MDS返回file inode,file size,capability和stripe信息
3. Client直接Read/Write数据到OSDs
4. MDS管理file的capability
5. Client发送close file请求给MDS,释放file的capability,更新file
详细信息
• 没有分布式文件锁
• 多客户端访问文件的一致性通过文件的capability保证
11. CephFS使用
• 创建MDS Daemon
# ceph-deploy mds create <…>
• 创建CephFS Data Pool
# ceph osd pool create <…>
• 创建CephFS Metadata Pool
# ceph osd pool create <…>
• 创建CephFS
# ceph fs new <…>
• 查看CephFS
# ceph fs ls
name: tstfs, metadata pool: cephfs_metadata, data pools: [cephfs_data ]
• 删除CephFS
# ceph fs rm <fs-name> --yes-i-really-mean-it
12. CephFS使用
• 查看MDS状态
# ceph mds stat
e8: tstfs-1/1/1 up tstfs2-0/0/1 up {[tstfs:0]=mds-daemon-1=up:active}
- e8 :
- e表示epoch,8是epoch号
- tstfs-1/1/1 up :
- tstfs是cephfs名字
- 三个1分别是 mds_map.in/mds_map.up/mds_map.max_mds
- up是cephfs状态
- {[tstfs:0]=mds-daemon-1=up:active} :
- [tstfs:0]指tstfs的rank 0
- mds-daemon-1是服务tstfs的mds daemon name
- up:active是cephfs的状态为 up & active
13. CephFS使用
• CephFS kernel client
• # mount -t ceph <monitor ip>:6789 /mntdir
• # umount /mntdir
• CephFS FUSE
• 安装ceph-fuse pkg
• # ceph-fuse -m <monitor ip>:6789 /mntdir
• # fusermount -u /mntdir
• centos7里没有fusermount命令,可以用umount替代
• 对比
• 性能:Kernel client > ceph-fuse
• Quota支持:只有ceph-fuse(client-side quotas)
14. CephFS Layout和file striping
• CephFS可以配置dir/file的layout和striping
• 保存在dir/file的xattr中
• 目录的layout xattrs为:ceph.dir.layout
• 文件的layout xattrs为:ceph.file.layout
• CephFS支持的layout配置项有
• pool - 数据存储到指定pool
• namespace - 数据存储到指定namespace(rbd/rgw/cephfs都还不支持)
• stripe_unit - 条带大小,单位Byte
• stripe_count - 条带个数
• 默认文件/目录继承父目录的layout和striping
15. CephFS Layout和file striping
# setfattr -n ceph.dir.layout -v "stripe_unit=524288 stripe_count=8 object_size=4194304
pool=cephfs_data2" /mnt/mike512K/
17. CephFS认证
• 创建auth client
# ceph auth get-or-create client.tst1 mon ‘allow r’ mds ‘allow r,
allow rw path=/tst1’ osd ‘allow rw pool=cephfs_data'
- mon ‘allow r’
允许user从monitor读取数据;必须配置
- mds ‘allow r, allow rw path=/tst1’
允许user从mds读取数据,允许user对目录/tst1读写;
其中‘ allow r’必须配置,不然user不能从mds读取数据,mount会报
permission error;
- osd ‘allow rw pool=cephfs_data’
允许user从osd pool=cephfs_data 上读写数据;
若不配置,用户只能从mds上获取FS的元数据信息,没法查看各个文件的数据;
18. CephFS认证
• 检查ceph auth
# ceph auth get client.tst1
exported keyring for client.tst1
[client.tst]
key = AQCd+UBZxpi4EBAAUNyBDGdZbPgfd4oUb+u41A==
caps mds = allow r, allow rw path=/tst1"
caps mon = "allow r"
caps osd = "allow rw pool=cephfs_data"
• Mount 测试
# mount -t ceph <ip>:6789:/tst1 /mnt -o name=tst1,secret=AQCd+UBZxpi4EBAAUNyBDGdZbPgfd4oUb+u41A==
• 认证还不完善
• 上述client.tst1可以mount整个CephFS目录,能看到并读取整个CephFS的文件
# mount -t ceph <ip>:6789:/ /mnt -o name=tst1,secret=AQCd+UBZxpi4EBAAUNyBDGdZbPgfd4oUb+u41A==
• 没找到能支持readonly访问某一目录的方法
只验证了cephfs kernel client,没试过ceph-fuse的认证
19. CephFS FSCK & Repair
• Jewel版本提供了CephFS的scrub/repair工具
• 能处理大部分的元数据损坏
• 修复命令慎重执行,需要专业人士
• 若可以请导出元数据,做好备份
• cephfs-journal-tool
• inspect/import/export/reset
• header get/set
• event get/apply/recover_dentries/splice
20. CephFS FSCK & Repair
• Online check/scrub
- ceph tell mds.<id> damage ls
- ceph tell mds.<id> damage rm <int>
- scrub an inode and output results
# ceph mds mds.<id> scrub_path <path> {force|recursive|repair [force|recursive|repair...]}
• Offline repair
- cephfs-data-scan init [--force-init]
- cephfs-data-scan scan_extents [--force-pool] <data pool name>
- cephfs-data-scan scan_inodes [--force-pool] [--force-corrupt] <data pool name>
- cephfs-data-scan scan_frags [--force-corrupt]
- cephfs-data-scan tmap_upgrade <metadata_pool>
22. CephFS测试目的
• CephFS POSIX基本功能完备?
• CephFS性能跑满整个集群?
• CephFS长时间是否稳定?
• CephFS能否应对MDS异常?
NO:
• 不是针对MDS的参数调优
• 不是MDS的压力测试
• MDS压力测试时建议配置在单独的机器上
• 调大 mds_cache_size
MDS压力测试请参考: https://www.slideshare.net/XiaoxiChen3/cephfs-jewel-mds-performance-benchmark
23. CephFS - Jewel
• Single Active MDS,Active-Standby MDSs
• Single CephFS within a single Ceph Cluster
• CephFS requires at least kernel 3.10.x
• CephFS – Production Ready
• Experimental Features
• Multi Active MDSs
• Multiple CephFS file systems within a single Ceph Cluster
• Directory Fragmentation
24. CephFS测试环境
• 三台物理机搭建 Ceph集群
• 每台物理机上10个4T 7200RPM SATA盘+两个480GB的SATA SSD盘,每个SSD盘
分出5个20GB的分区做5个OSD的journal
• 两个万兆网卡,分别配置为public/cluster network
• SSD盘型号为:Intel S3500系列,其性能指标为:
• 普通7200转SATA盘性能:
• 顺序读写约 120MB/s
• IOPS约为 130
27. CephFS测试分析-功能测试
• 测试方法:手动,fstest
• 手动:mkdir/cd/touch/echo/cat/chmod/chown/mv/ln/rm等
• fstest:一套简化版的文件系统POSIX兼容性测试套件
• 目前有3601个回归测试
• 测试的系统调用覆盖chmod, chown, link, mkdir, mkfifo, open,
rename, rmdir, symlink, truncate, unlink
• 总结:功能测试通过
28. CephFS测试分析-性能测试
• 测试方法:dd,fio,iozone,filebench
• 测试分类:CephFS分为三类stripe配置
1. stripe_unit=1M, stripe_count=4, object_size=4M (目录为: dir-1M-4-4M)
2. stripe_unit=4M, stripe_count=1, object_size=4M (目录为: dir-4M-1-4M,默认)
3. stripe_unit=4M, stripe_count=4, object_size=64M (目录为: dir-4M-4-64M)
• 配置CephFS stripe
• 文件默认继承父目录的attributes
• 配置测试目录的attr
例如:# setfattr -n ceph.dir.layout -v "stripe_unit= 1048576 stripe _count=4
object_size=4194304" dir-1M-4-4M
注:每轮测试前清空client端缓存
30. CephFS测试分析-性能测试-dd
Normal IO: 客户端缓存影响,性能较高,不分析
Direct IO: 写性能只有 150MB/s,读性能只有 600MB/s(cephfs kernel client端IO实现导致)
Sync IO: 随着bs增大性能提升,写性能有 550MB/s,读性能有1GB/s
Stripe模式变化:
1. bs=512k/1M时,各个stripe模
式下的IO性能基本相同
2. bs=4M/16M时
• Direct IO时stripe
unit=1M的条带性能略低
• Sync IO时stripe
unit=1M的条带性能较好
3. 默认的file layout(橙色),
dd的性能就挺好,64Mobjcet
的stripe模式(灰色)没有明显
的性能提升
31. CephFS测试分析-性能测试-fio
• 固定配置
-filename=tstfile 指定测试文件的name
-size=20G 指定测试文件的size为20G
-direct=1 指定测试IO为DIRECT IO
-thread 指定使用thread模式
-name=fio-tst-name 指定job name
• 测试bandwidth时
-ioengine=libaio/sync
-bs=512k/1M/4M/16M
-rw=write/read
-iodepth=64 –iodepth_batch=8 –iodepth_batch_complete=8
• 测试iops时
-ioengine=libaio
-bs=4k
-runtime=300
-rw=randwrite/randread
-iodepth=64 -iodepth_batch=1 -iodepth_batch_complete=1
33. CephFS测试分析-性能测试-fio
IOPS: cephfs stripe对iops影响不大,写为 4200,读为 2400
• randread中,因为有cephfs这一层,所以即使direct IO,在OSD上也不一定会read磁
盘,因为OSD有缓存数据。
• 所以每次测试前要在所有ceph cluster的host上清理缓存。
sync; echo 3 > /proc/sys/vm/drop_caches;
Io mode type dir-1M-4-4M dir-4M-1-4M dir-4M-4-64M
randwrite iops 4791 4172 4130
Latency(ms) 13.35 15.33 15.49
randread iops 2436 2418 2261
Latency(ms) 26.26 26.46 28.30
34. CephFS测试分析-性能测试-iozone
• 测试DIRET IO / SYNC IO - 非throughput模式
• 不指定threads,测试单个线程的iozone性能
# iozone -a -i 0 -i 1 -i 2 -n 1m -g 10G -y 128k -q 16m -I -Rb iozone-directio-
output.xls
# iozone -a -i 0 -i 1 -i 2 -n 1m -g 10G -y 128k -q 16m -o -Rb iozone-syncio-
output.xls
• 测试系统吞吐量 - throughput模式
• 指定threads=16,获取整个系统的throughput
# iozone -a -i 0 -i 1 -i 2 -r 16m -s 2G -I -t 16 -Rb iozone-directio-
throughput-output.xls
# iozone -a -i 0 -i 1 -i 2 -r 16m -s 2G -o -t 16 -Rb iozone-syncio-throughput-
output.xls
37. CephFS测试分析-性能测试-filebench
• filebench 是一款文件系统性能的自动化测试工具,它通过快速模拟真实应用服务器的负载
来测试文件系统的性能
• filebench有很多定义好的workload
• 详细参考:http://www.yangguanjun.com/2017/07/08/fs-testtool-filebench/
• 针对cephfs的测试,选择其中一部分有代表性的workloads即可
• createfiles.f / openfiles.f / makedirs.f / listdirs.f / removedirs.f
• randomrw.f / fileserver.f / videoserver.f / webserver.f
• 结论
1. filebench测试用例,除了读写操作外,其他的都是元数据操作,基本不受cephfs stripe的影响
2. 各种文件操作的时延都不高,可以满足基本的对filesystem的需求
38. CephFS测试分析-稳定性测试
• 读写数据模式
• 选择工具fio
# fio循环测试读写
while now < time
fio write 10G file
fio read 10G
file delete file
• 读写元数据模式
• 采用自写脚本,大规模创建目录、文件、写很小数据到文件中
# 百万级别的文件个数
while now < time
create dirs
touch files
write little data to each file
delete files
delete dirs
39. CephFS测试分析-稳定性测试
• 结论
• 几天的连续测试,CephFS一切正常
• 在上亿级别小文件的测试中,有些问题
• 问题与解决
• 日志中报“Behind on trimming”告警
调整参数 mds_log_max_expiring,mds_log_max_segments
• rm删除上亿文件时报“No space left on device”错误
调大参数 mds_bal_fragment_size_max,mds_max_purge_files,mds_max_purge_ops_per_pg
• 日志中报“_send skipping beacon, heartbeat map not healthy”
调大参数 mds_beacon_grace,mds_session_timeout,mds_reconnect_timeout
MDS log信息 -> 搜索相关Ceph代码 -> 分析原因 -> 调整参数
40. CephFS测试分析-异常测试
• 主从MDS
• 单MDS
• 启停MDS service的命令
# systemctl stop ceph-mds.target
# systemctl start ceph-mds.target
• 相关配置参数
OPTION(mds_tick_interval, OPT_FLOAT, 5)
OPTION(mds_mon_shutdown_timeout, OPT_DOUBLE, 5)
OPTION(mds_op_complaint_time, OPT_FLOAT, 30)
• CephFS允许客户端缓存metadata 30s
• 所以选择测试MDS stop/start的时间间隔取为:2s,10s,60s
• 测试工具:fio
44. 总结
7. CephFS能跑满整个ceph集群的性能
8. 默认stripe模式下(stripe unit=4M, stripe count=1, object size=4M),
CephFS的性能就挺好
9. 小文件的应用场景下,尝试配置小的stripe unit,对比默认stripe的性能
10.CephFS的Direct IO性能有限,分析后是cephfs kernel client的IO处理逻
辑限制的(http://www.yangguanjun.com/2017/06/26/cephfs-dd-direct-io-tst-analysis/)
11.受到CephFS client端的系统缓存影响,非Direct IO的读写性能都会比较高,
这个不具有太大参考意
12.使用CephFS kernel client,且object size大于16M时,一次性读取大于
16M的数据读时IO会hang住(http://www.yangguanjun.com/2017/07/18/cephfs-io-hang-analysis/)
45. 展望 – Ceph Luminous
• Ceph Luminous (v12.2.0) - next long-term stable release series
1.The new BlueStore backend for ceph-osd is now stable and the new
default for newly created OSDs
2.Multiple active MDS daemons is now considered stable
3.CephFS directory fragmentation is now stable and enabled by default
4.Directory subtrees can be explicitly pinned to specific MDS daemons