之前写的使用COSBench工具对ceph s3接口进行压力测试是入门,在实际使用是,配置内容各不一样,下面列出
压力脚本是xml格式的,套用UserGuide文档说明,如下
有很多模板的例子,在conf目录下,如librados-config-sample.xml、s3-config-sample.xml
这里只有s3的,所以目前只关注s3的相关配置
S3的配置在页面上选择时没有显示出来,所以我们就进行手工配置
第一级workload,格式如下:
<workload name=”demo” description=”demo benchmark with mock storage” />
属性 |
类型 |
默认值 |
备注 |
Name |
String |
名字,随便取 |
|
Descriptipion |
String |
描述 |
对应s3就用storage参数,格式如下:
<storage type="s3" config="accesskey=<accesskey>;secretkey=<scretkey>;endpoint=<endpoint>; proxyhost=<proxyhost>;proxyport=<proxyport>" />
属性 |
类型 |
默认值 |
备注 |
Timeout |
Int |
30,000 |
毫秒 |
Accesskey |
String |
S3 的accesskey |
|
Secretkey |
String |
S3的secretkey |
|
Endpoint |
String |
默认为亚马逊地址 |
|
Proxyhost |
String |
代理地址 |
|
Proxyport |
Int |
代理端口 |
第二级workstorage,格式如下
<workstage name="<name>" ></workstage>
属性 |
类型 |
默认值 |
备注 |
Name |
String |
名字,随便取 |
对应使用work参数,格式如下
<work name="main" type="normal" workers="128" interval="5" division="none" runtime="60" rampup="0" rampdown="0" totalOps="0" totalBytes="0" afr=”200000” config="" > . . . </work>
属性 |
类型 |
默认值 |
备注 |
Name |
String |
名字,随便取 |
|
Type |
String |
“normal” |
工作类型,下面有介绍 |
Workers |
Int |
并发工作数 |
|
Interval |
Int |
5 |
间隔时间 |
Division |
Str |
“none” |
划分数据方式,为container时,通过bucket划分数据,为ojbect,以对像数据划分数据,”none”时,所以的bucket都 有ojbect数据 |
Runtime |
Int |
0 |
运行时长 |
Rampup |
Int |
0 |
多长时间启动完所有的压力 |
Rampdown |
Int |
0 |
结束数,不能与runtime同时配 |
totalOps |
Int |
0 |
操作数 |
totalBytes |
Int |
0 |
多大bytes将传输 |
Driver |
Str |
哪个driver将执行工作,默认的话,所有的drivers将参与工作,平分 |
|
Afr |
Int |
200,000 – normal 0 – special work |
可接受错误速率,毫秒级别 |
Work type支持
init(创建bucket)
格式<work type=”init” workers=”4” config=”containers=r(1,100)” />
参数 |
类型 |
默认值 |
说明 |
Containers |
String |
Bucket选项表达式,比如c(1),r(1,100) |
|
Cprefix |
String |
Mycontainers_ |
Bucket前缀 |
Csuffix |
String |
<null> |
后缀 |
prepare(在bucket中插入特定的对像)
格式
<work type=”perpare” work=”4” config=”containers-=r(1,10);objects=r(1,100);sizes=c(64)KB”/>
参数 |
类型 |
默认值 |
说明 |
Containers |
String |
Bucket选项表达式,比如c(1),r(1,100) |
|
Cprefix |
String |
Mycontainers_ |
Bucket前缀 |
Csuffix |
String |
<null> |
后缀 |
Ojbects |
String |
Object选择表达式,如c(1),u(1,100) |
|
Oprefix |
String |
Myobjects_ |
对像前缀 |
Osuffix |
String |
<null> |
对像后缀 |
Sizes |
String |
大小,单位可以为(B/KB/MG/GB) |
|
Chuncked |
Boolean |
False |
校验上传的数据 |
Content |
String |
“random”(默认) “zero” |
上传数据内容,默认为随机字符号 |
Createcontainer |
Boolean |
False |
如果bucket不存在就创建对赢的bucket |
hashCheck |
Boolean |
False |
Hash检查 |
Cleanup(删除文件)
格式:<work type=”cleanup” workers=”4” config=”containers=r(1,5)”;objects=r(1,100)” />
参数 |
类型 |
默认值 |
说明 |
Containers |
String |
Bucket选项表达式,比如c(1),r(1,100) |
|
Cprefix |
String |
Mycontainers_ |
Bucket前缀 |
Csuffix |
String |
<null> |
后缀 |
Ojbects |
String |
Object选择表达式,如c(1),u(1,100) |
|
Oprefix |
String |
Myobjects_ |
对像前缀 |
Osuffix |
String |
<null> |
对像后缀 |
Deletecontainer |
Boolean |
False |
存在相关的bucket则删除bucket |
Dispolse(删除bucket)
格式 <work type=”dispose” workers=”4” config=”containers=r(1,100)” />
参数 |
类型 |
默认值 |
说明 |
Containers |
String |
Bucket选项表达式,比如c(1),r(1,100) |
|
Cprefix |
String |
Mycontainers_ |
Bucket前缀 |
Csuffix |
String |
<null> |
后缀 |
Delay(延迟)
用的少,不写了
Operation支持:
格式<operation type=”read|write|delete” ratio=”<1-100> config=”<key>=<value>;….” />
参数 |
类型 |
默认值 |
说明 |
Type |
String |
操作类型,只有read write delete list |
|
Ratio |
Int |
比例 |
|
Division |
Int |
||
Config |
String |
参数列表 |
read
格式<operation type=”read” ratio=”79” config=”containers=c(1);objects=u(1,100)” />
参数 |
类型 |
默认值 |
说明 |
Containers |
String |
Bucket选项表达式,比如c(1),r(1,100) |
|
Cprefix |
String |
Mycontainers_ |
Bucket前缀 |
Csuffix |
String |
<null> |
后缀 |
Ojbects |
String |
对像表达式如u(1,100) |
|
Oprefix |
String |
Myobjects_ |
对像前缀 |
Osuffix |
String |
<null> |
对像后缀 |
Hascheck |
Boolean |
False |
是否校验 |
write
格式:
<operation type=”write” ratio=”20” config=”containers=c(2);objects=u(1,10);size=c(2)MB”/>
参数 |
类型 |
默认值 |
说明 |
Containers |
String |
Bucket选项表达式,比如c(1),r(1,100) |
|
Cprefix |
String |
Mycontainers_ |
Bucket前缀 |
Csuffix |
String |
<null> |
后缀 |
objects |
String |
对像表达式如u(1,100) |
|
Oprefix |
String |
Myobjects_ |
对像前缀 |
Osuffix |
String |
<null> |
对像后缀 |
Sizes |
String |
大小 |
|
Chunked |
Boolean |
False |
上传数据是否分片 |
Content |
String |
“radom”(默认值) “zero” |
默认是随机字符填充 |
Hascheck |
Boolean |
False |
是否校验 |
filewrite(文件上传)
格式:
<operation type=”filewrite” ratio=”20” config=”containers=c(2);fileselection=s;files=/tmp”/>
参数 |
类型 |
默认值 |
说明 |
Containers |
String |
Bucket选项表达式,比如c(1),r(1,100) |
|
Cprefix |
String |
Mycontainers_ |
Bucket前缀 |
Csuffix |
String |
<null> |
后缀 |
Fileselection |
String |
上传文件选择方式,如s |
|
Files |
String |
目录 |
|
Chunked |
Boolean |
False |
上传数据是否分片 |
Hascheck |
Boolean |
False |
是否校验 |
delete
格式<operation type=”delete” ratio=”10” config=”containers=c(2);ojbects=u(1,100)” />
参数 |
类型 |
默认值 |
说明 |
Containers |
String |
Bucket选项表达式,比如c(1),r(1,100) |
|
Cprefix |
String |
Mycontainers_ |
Bucket前缀 |
Csuffix |
String |
<null> |
后缀 |
objects |
String |
对像表达式如u(1,100) |
|
Oprefix |
String |
Myobjects_ |
对像前缀 |
Osuffix |
String |
<null> |
对像后缀 |
list(用的少)
在填写参数时,还需要注意各种选择器的使用,如下
Expression |
格式 |
备注 |
Constant(不变的) |
C(number) |
固定在一个数值 |
Uniform(随机) |
U(min,max) |
从[min,max]中随机选择一个数 |
Range |
R(min,max) |
同python里的range函数 更常用在(init,prepare,cleanup,dispose)里,不建议用在operation |
sequential |
S(min,max) |
也是增加函数,常用于operation操作中 |
Histogram |
H(min1|max1|weight1,…..) |
用在文件大小的不同比重中,实际使用少,不解释 |
常见的xml:
初始化bucket,将会创建二个bucket

<?xml version="1.0" encoding="UTF-8" ?> - <workload name="initBucket" description="sample benchmark for s3"> <storage type="s3" config="accesskey=V02TU7BTTHYSVINSRB7P;secretkey=b2u6ZgiNVlnfsDUpBigEbZKX9Na7kvM7UWEMrtPN;endpoint=http://xxx.xxx.xxx/" /> - <workflow> - <workstage name="init_create_bucket"> <work type="init" workers="1" config="cprefix=test;containers=r(1,2)" /> </workstage> </workflow> </workload>
上传特定大小的文件
在test1 bucket中上传100个4M的文件,并发25

<?xml version="1.0" encoding="UTF-8" ?> - <workload name="put-100Workers-4MB" description="sample benchmark for s3"> <storage type="s3" config="accesskey=V02TU7BTTHYSVINSRB7P;secretkey=b2u6ZgiNVlnfsDUpBigEbZKX9Na7kvM7UWEMrtPN;endpoint=http://xxx.xxx.xxx.xxx/" /> - <workflow> - <workstage name="put 4MB data with 100 workers"> - <work name="Put64KBData1" workers="25" totalOps="200" driver="sv40"> <operation type="write" ratio="100" config="cprefix=test;oprefix=100wks_64k;containers=c(1);objects=s(1,100);sizes=c(4)MB" /> </work> </workstage> </workflow> </workload>
读写1:1

<?xml version="1.0" encoding="UTF-8" ?> - <workload name="read&write" description="sample benchmark for s3"> <storage type="s3" config="accesskey=7FRWOW451AM5N1BDGWG6;secretkey=Xb9YEC5ia4KbCR1M7fZgR67RFXi1ARPrOfxa9Bjx;endpoint=http://xxx.xxx.xx.xx/" /> - <workflow> - <workstage name="read &write"> - <work name="read write" workers="25" totalOps="100"> <operation type="write" ratio="50" config="cprefix=test;oprefix=100wks_64k;containers=c(1);objects=s(1,10);sizes=c(50)KB" /> <operation type="read" ratio="50" config="cprefix=test-;oprefix=100wks_64kr;containers=c(1);objects=s(1,10);sizes=c(50)KB" /> </work> </workstage> </workflow> </workload>