前言
k8s对ceph rbd模式不支持ReadWriteMany(RWX),为了满足k8s的灵活性需求,采用支持多点挂载的cephfs工作模式.网上少有针对cephfs调优的文章,因此在本篇,将针对cephfs进行一些参数调优及性能测试
硬件规划
配置调优
在进行配置调优之前首先理解一下ceph几种基础配置项名词的定义
名词解析:1
2
3
4
5object: ceph数据存储的基本单位,可以是普通data也可以是journal data
osd: ceph数据存储的目标载体,一般一个osd实例对应一块磁盘
pg(Placement Group): 存储位组,object对象的存储时的分组,与osd关联
pgp( Placement Group for Placement purpose):值应与pg保持一致,当此值修改时,pg内的数据对象才会进行rebalance
pool: 数据的逻辑隔离与管理单位,由多个pg构成
关系图:
经过多次的对参数反复调整,将ceph.conf修改成如下配置,比较适合我们的使用场景:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80# cat /etc/ceph/ceph.conf
[global]
fsid = 05bd836f-f307-47fa-ae95-34e302fbd9e8
mon_initial_members = h020112, h020113, h020114
mon_host = 192.168.20.112,192.168.20.113,192.168.20.114
auth_cluster_required = cephx
auth_service_required = cephx
auth_client_required = cephx
public_network= 192.168.20.0/24
osd pool default size = 2
osd pool default pg num = 1024
osd pool default pgp num = 1024
osd data = /var/lib/ceph/osd/ceph-$id
osd journal size = 81920
osd mkfs type = xfs
osd mkfs options xfs = -f
osd max write size = 512 #默认值90 #OSD一次可写入的最大值(MB)
osd client message size cap = 2147483648 #默认值100 #客户端允许在内存中的最大数据(bytes)
osd deep scrub stride = 131072 #默认值524288 #在Deep Scrub时候允许读取的字节数(bytes)
osd op threads = 16 #默认值2 #并发文件系统操作数
osd disk threads = 4 #默认值1 #OSD密集型操作例如恢复和Scrubbing时的线程
osd map cache size = 1024 #默认值500 #保留OSD Map的缓存(MB)
osd map cache bl size = 128 #默认值50 #OSD进程在内存中的OSD Map缓存(MB)
osd mount options xfs = "rw,noexec,nodev,noatime,nodiratime,nobarrier" #默认值rw,noatime,inode64 #Ceph OSD xfs Mount选项
osd recovery op priority = 2 #默认值10 #恢复操作优先级,取值1-63,值越高占用资源越高
osd recovery max active = 10 #默认值15 #同一时间内活跃的恢复请求数
osd max backfills = 4 #默认值10 #一个OSD允许的最大backfills数
osd min pg log entries = 30000 #默认值3000 #修建PGLog是保留的最大PGLog数
osd max pg log entries = 100000 #默认值10000 #修建PGLog是保留的最大PGLog数
osd mon heartbeat interval = 40 #默认值30 #OSD ping一个monitor的时间间隔(默认30s)
osd op log threshold = 50 #默认值5 #一次显示多少操作的log
filestore xattr use omap = true
filestore min sync interval = 10 #默认0.1#从日志到数据盘最小同步间隔(seconds)
filestore max sync interval = 15 #默认5#从日志到数据盘最大同步间隔(seconds)
filestore queue max ops = 25000 #默认500#数据盘最大接受的操作数
filestore queue max bytes = 1048576000 #默认100 #数据盘一次操作最大字节数(bytes
filestore queue committing max ops = 50000 #默认500 #数据盘能够commit的操作数
filestore queue committing max bytes = 10485760000 #默认100 #数据盘能够commit的最大字节数(bytes)
filestore split multiple = 1600 #默认值2 #前一个子目录分裂成子目录中的文件的最大数量
filestore merge threshold = 40 #默认值10 #前一个子类目录中的文件合并到父类的最小数量
filestore fd cache size = 204800 #默认值128 #对象文件句柄缓存大小
filestore omap header cache size = 204800
filestore fiemap = true #默认值false #读写分离
filestore ondisk finisher threads = 2 #默认值为1
filestore apply finisher threads = 2 #默认值为1
mds cache size = 102400000
mds beacon grace = 120
mds session timeout = 15
mds session autoclose = 60
mds reconnect timeout = 15
mds decay halflife = 10
rbd op threads = 4
rbd cache size = 268435456
rbd cache max dirty = 134217728
rbd cache max dirty age = 5
rbd cache max dirty object = 64
journal max write bytes = 1073714824
journal max write entries = 10000
journal queue max ops = 50000
journal queue max bytes = 10485760000
ms_async_op_threads = 5 #默认值3
ms dispatch throttle bytes = 1048576000 #默认值 104857600 #等待派遣的最大消息数
objecter inflight ops = 819200 #默认值1024 #客户端流控,允许的最大未发送io请求数,超过阀值会堵塞应用io,为0表示不受限
client_caps_release_delay = 10
创建mds
1 | ceph-deploy mds create h020112 h020113 h020114 |
性能测试
使用fio命令测试小块(16k)\大块(512k)文件读写\随机读写性能,测试结果如下:
稳定性测试
使用多线程压力测试脚本运行一天两夜往cephfs内写入了几千万个小文件,压力测试脚本如下:
1 | #!/bin/bash |
压测的过程出现过几次客户端响应阻塞的意外,但基本都自动恢复,稳定性尚可.
在写入了5T 4k的小文件后,查看文件大小\目录大小\文件详情等常规操作延迟可以接受,测试基本通过
Ceph监控
ceph性能指标及容量监控,prometheus采集+grafana展示,这里使用digitalocean提供的ceph_exporter prometheus插件.项目主页:
安装ceph_exporter
1 | yum install golang |
prometheus配置job
1 | - job_name: 'ceph-exporter' |
重启prometheus,web ui查看target:
prometheus/grafana安装配置步骤见此前的文章
grafana添加图形模板
导入179号模板:
监控告警配置可以自定义阈值,参考此前文章触发告警接口
Ceph常用命令
1 | # 服务相关: |
最后
Ceph是一套庞大的存储系统,工作原理及涉及组件相当复杂,存储更是系统架构中的重中之重,一定要慎之又慎,同时做好知识储备,多查官方文档,另外再提一个坑,那就是官方的中文文档除了丰富度不如英文文档外,很多参数的默认值与英文文档不一致,英文文档更加准确,因此推荐查看英文文档.
链接:ceph官方文档