因部署完对象存储,需要进行性能测试,使用到cosbench,进而稍加整理至此
一、介绍:
COSBench 是一个用于测试云对象存储系统的分布式基准测试工具,也允许用户为额外的存储系统创建适配器。
由两个主要组件组成
Driver(Load Generator):
- 负责生成工作负载,向目标云对象存储发出操作;性能统计
- 可通过http://:18088/driver/index.html访问
Controller:
- 负责协调drivers集体执行工作,收集和汇总聚合来自driver实例的运行时状态或基准测试结果
- 可通过 http://:19088/controller/index.html访问
两个组件可以混合部署在一个节点上,也可以分开来部署
二、安装依赖包:
1、
java:
需要java1.6 版本及以上
2、
nc(nmap-ncat):
用来检测服务端口
[root@ceph-node1 ~]# yum install java nc
[root@ceph-node1 ~]# java -version #测试java是否可用
openjdk version "1.8.0_312"
OpenJDK Runtime Environment (build 1.8.0_312-b07)
OpenJDK 64-Bit Server VM (build 25.312-b07, mixed mode)
三、安装cosbench:
1、下载解压并查看
[root@ceph-node1 ~]# wget https://github.com/intel-cloud/cosbench/releases/download/v0.4.2.c4/0.4.2.c4.zip
[root@ceph-node1 ~]# unzip 0.4.2.c4.zip
官方英文使用文档(超详细,可以翻翻看)
[root@ceph-node1 0.4.2.c4]# ll *.pdf
-rw-r--r--. 1 root root 348912 Jul 9 2014 3rd-party-licenses.pdf
-rw-r--r--. 1 root root 985318 Jul 9 2014 COSBenchAdaptorDevGuide.pdf
-rw-r--r--. 1 root root 2516640 Apr 27 2016 COSBenchUserGuide.pdf
服务调用脚本说明
[root@ceph-node1 0.4.2.c4]# ll *.sh
-rw-r--r--. 1 root root 2639 Oct 30 00:25 cli.sh #通过命令行操作cosbench
-rw-r--r--. 1 root root 2944 Apr 27 2016 cosbench-start.sh #其他启动脚本调用的脚本
-rw-r--r--. 1 root root 1423 Dec 30 2014 cosbench-stop.sh #其他启动脚本调用的脚本
-rw-r--r--. 1 root root 727 Apr 27 2016 start-all.sh #在当前节点启动driver和controller组件
-rw-r--r--. 1 root root 724 Apr 27 2016 stop-all.sh #在当前节点停止driver和controller组件
-rw-r--r--. 1 root root 1062 Jul 9 2014 start-controller.sh #在当前节点启动controller
-rw-r--r--. 1 root root 1912 Oct 30 00:22 start-driver.sh #在当前节点启动driver
-rw-r--r--. 1 root root 809 Jul 9 2014 stop-controller.sh #在当前节点关闭controller
-rw-r--r--. 1 root root 1490 Apr 27 2016 stop-driver.sh #在当前节点关闭driver
2、修改driver配置(如果是本地访问可忽略)
默认driver配置的页面地址为127.0.0.1,要修改为当前服务器IP,用以其他节点访问
[root@ceph-node1 0.4.2.c4]# cat /root/0.4.2.c4/start-driver.sh
#!/bin/bash
ip=192.168.1.51 #默认为127.0.0.1,将之修改为部署节点的IP,供其他节点访问
num=1
base_port=18088
……
3、启动cosbench
启动前为了保证driver和controller之间交互正常,需要关闭HTTP代理
[root@ceph-node1 0.4.2.c4]# unset http_proxy
启动controller和driver
[root@ceph-node1 0.4.2.c4]# sh start-all.sh
Launching osgi framwork ...
Successfully launched osgi framework!
Booting cosbench driver ...
.
Starting cosbench-log_0.4.2 [OK]
.
Starting cosbench-tomcat_0.4.2 [OK]
Starting cosbench-config_0.4.2 [OK]
Starting cosbench-http_0.4.2 [OK]
Starting cosbench-cdmi-util_0.4.2 [OK]
Starting cosbench-core_0.4.2 [OK]
Starting cosbench-core-web_0.4.2 [OK]
Starting cosbench-api_0.4.2 [OK]
Starting cosbench-mock_0.4.2 [OK]
Starting cosbench-ampli_0.4.2 [OK]
Starting cosbench-swift_0.4.2 [OK]
Starting cosbench-keystone_0.4.2 [OK]
Starting cosbench-httpauth_0.4.2 [OK]
Starting cosbench-s3_0.4.2 [OK]
Starting cosbench-librados_0.4.2 [OK]
Starting cosbench-scality_0.4.2 [OK]
Starting cosbench-cdmi-swift_0.4.2 [OK]
Starting cosbench-cdmi-base_0.4.2 [OK]
Starting cosbench-driver_0.4.2 [OK]
Starting cosbench-driver-web_0.4.2 [OK]
Successfully started cosbench driver!
Listening on port 0.0.0.0/0.0.0.0:18089 ...
Persistence bundle starting...
Persistence bundle started.
----------------------------------------------
!!! Service will listen on web port: 18088 !!!
----------------------------------------------
======================================================
Launching osgi framwork ...
Successfully launched osgi framework!
Booting cosbench controller ...
.
Starting cosbench-log_0.4.2 [OK]
.
Starting cosbench-tomcat_0.4.2 [OK]
Starting cosbench-config_0.4.2 [OK]
Starting cosbench-core_0.4.2 [OK]
Starting cosbench-core-web_0.4.2 [OK]
Starting cosbench-controller_0.4.2 [OK]
Starting cosbench-controller-web_0.4.2 [OK]
Successfully started cosbench controller!
Listening on port 0.0.0.0/0.0.0.0:19089 ...
Persistence bundle starting...
Persistence bundle started.
----------------------------------------------
!!! Service will listen on web port: 19088 !!!
----------------------------------------------
4、验证(查看java进程和端口)
[root@ceph-node1 0.4.2.c4]# netstat -nplt |grep 18088
tcp6 0 0 :::18088 :::* LISTEN 6084/java
[root@ceph-node1 0.4.2.c4]# netstat -nplt |grep 19088
tcp6 0 0 :::19088 :::* LISTEN 6235/java
[root@ceph-node1 0.4.2.c4]# ps aux |grep java
root 6084 5.3 4.4 3562620 178000 pts/1 Sl 02:26 0:10 java -Dcosbench.tomcat.config=conf/driver-tomcat-server.xml -server -cp main/org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main -configuration conf/.driver -console 18089
root 6235 5.2 3.8 3555108 153032 pts/1 Sl 02:26 0:10 java -Dcosbench.tomcat.config=conf/controller-tomcat-server.xml -server -cp main/org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main -configuration conf/.controller -console 19089
root 6327 0.0 0.0 112812 980 pts/1 S+ 02:29 0:00 grep --color=auto java
使用cli.sh查看启动信息
[root@ceph-node1 0.4.2.c4]# sh cli.sh info
Drivers:
driver1 http://127.0.0.1:18088/driver
Total: 1 drivers
Active Workloads:
Total: 0 active workloads
由上信息得知,controller和driver都已启动
报错提示:
如果不安装nc,会报错
which: no nc in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
No appropriate tool found to detect cosbench driver status.
如果不安装java,会报
Ncat: Connection refused.
访问http://:19088/controller/index.html验证
四、cosbench配置多个driver(不做多driver可忽略)
controller可以管理多个driver,在默认的一个driver之外,可以部署多个driver,用以平均负载。driver有多种部署方式
- 可以和controller部署在同一节点
- 可以部署在同一节点使用不同端口
- 部署在其他节点
这里实验环境,使用方法2实验
修改controller配置文件:
[root@ceph-node1 0.4.2.c4]# cat conf/controller.conf
[controller]
drivers = 3
log_level = INFO
log_file = log/system.log
archive_dir = archive
[driver1]
name = driver1
url = http://192.168.1.51:18088/driver
[driver2]
name = driver2
url = http://192.168.1.51:18188/driver
[driver3]
name = driver3
url = http://192.168.1.51:18288/driver
1、启动基础的controller和driver
[root@ceph-node1 0.4.2.c4]# sh start-all.sh
…………
Successfully started cosbench driver!
Listening on port 0.0.0.0/0.0.0.0:18089 ...
Persistence bundle starting...
Persistence bundle started.
----------------------------------------------
!!! Service will listen on web port: 18088 !!!
----------------------------------------------
…………
Successfully started cosbench controller!
Listening on port 0.0.0.0/0.0.0.0:19089 ...
Persistence bundle starting...
Persistence bundle started.
----------------------------------------------
!!! Service will listen on web port: 19088 !!!
----------------------------------------------
2、启动多个driver(使用本地不同端口)
默认driver使用的是18088端口,这里其他端口用18188/18288
命令格式:sh start-driver.sh n ip base-port (默认会创建出来两个driver节点)
参数详解:
n:第几个节点(不重复即可)
ip:部署节点ip
base-port:部署使用的端口
启动
[root@ceph-node1 0.4.2.c4]# sh start-driver.sh 2 192.168.1.51 18188
………………
Successfully started cosbench driver!
Listening on port 0.0.0.0/0.0.0.0:18189 ...
Persistence bundle starting...
Persistence bundle started.
----------------------------------------------
!!! Service will listen on web port: 18188 !!!
----------------------------------------------
……………………
Successfully started cosbench driver!
Listening on port 0.0.0.0/0.0.0.0:18289 ...
Persistence bundle starting...
Persistence bundle started.
----------------------------------------------
!!! Service will listen on web port: 18288 !!!
----------------------------------------------
3、查看进程(一个controller,三个driver)
[root@ceph-node1 0.4.2.c4]# ps aux |grep java
root 8103 2.8 4.3 3568764 175888 pts/1 Sl 03:35 0:13 java -Dcosbench.tomcat.config=conf/driver-tomcat-server.xml -server -cp main/org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main -configuration conf/.driver -console 18189
root 8263 2.4 4.2 3564640 172748 pts/1 Sl 03:35 0:11 java -Dcosbench.tomcat.config=conf/driver-tomcat-server.xml -server -cp main/org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main -configuration conf/.driver -console 18289
root 8431 18.5 4.0 3563672 161632 pts/1 Sl 03:42 0:11 java -Dcosbench.tomcat.config=conf/driver-tomcat-server.xml -server -cp main/org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main -configuration conf/.driver -console 18089
root 8582 15.0 3.5 3550292 142732 pts/1 Sl 03:42 0:08 java -Dcosbench.tomcat.config=conf/controller-tomcat-server.xml -server -cp main/org.eclipse.equinox.launcher_1.2.0.v20110502.jar org.eclipse.equinox.launcher.Main -configuration conf/.controller -console 19089
root 9092 0.0 0.0 112812 976 pts/1 S+ 03:43 0:00 grep --color=auto java
4、查看页面
五、配置压测文件
默认的模板测试配置文件:conf/s3-config-sample.xml
[root@ceph-node1 0.4.2.c4]# cat conf/s3-config-sample.xml
<?xml version="1.0" encoding="UTF-8" ?>
<workload name="s3-sample" description="sample benchmark for s3">
<storage type="s3" config="accesskey=<accesskey>;secretkey=<scretkey>;proxyhost=<proxyhost>;proxyport=<proxyport>;endpoint=<endpoint>" />
<workflow>
<workstage name="init">
<work type="init" workers="1" config="cprefix=s3testqwer;containers=r(1,2)" />
</workstage>
<workstage name="prepare">
<work type="prepare" workers="1" config="cprefix=s3testqwer;containers=r(1,2);objects=r(1,10);sizes=c(64)KB" />
</workstage>
<workstage name="main">
<work name="main" workers="8" runtime="30">
<operation type="read" ratio="80" config="cprefix=s3testqwer;containers=u(1,2);objects=u(1,10)" />
<operation type="write" ratio="20" config="cprefix=s3testqwer;containers=u(1,2);objects=u(11,20);sizes=c(64)KB" />
</work>
</workstage>
<workstage name="cleanup">
<work type="cleanup" workers="1" config="cprefix=s3testqwer;containers=r(1,2);objects=r(1,20)" />
</workstage>
<workstage name="dispose">
<work type="dispose" workers="1" config="cprefix=s3testqwer;containers=r(1,2)" />
</workstage>
</workflow>
</workload>
参数说明:
-
workload name:
测试时显示的任务名称,这里可以自行定义 -
description :
描述信息,这里可以自己定义,示例写的是(10并发写100个4kb文件) -
storage type:
存储类型,这里配置为s3即可 -
config:
连接信息配置,accesskey和secretkey填写使用用户的key即可;proxyhost和proxyport填写http代理主机的IP和端口,有需要的话填写,没有可以删掉;endpoint填写rgw的访问地址 -
workstage name:
执行的任务事项,cosbench是分阶段按顺序执行 -
init:
初始化阶段,主要是进行bucket的创建,-
workers:
表示执行该阶段的时候开启多少个工作线程,创建bucket通过不会计算为性能,所以单线程也可以; -
config:
配置的是存储桶bucket的名称前缀; -
containers:
表示轮询数,上例中将会创建以s3testqwer为前缀,后缀分别为1和2的bucket
-
-
prepare:
初始化阶段,配置为bucket写入的数据,workers和config以及containers与init阶段相同-
object:
表示一轮写入多少个对象,以及object的大小,示例中的objects=r(1,10);sizes=c(64)KB”代表写入1到10个大小为64KB的对象
-
-
main阶段:
进行测试的阶段,-
workers:
开启多少线程数去执行操作 -
runtime:
表示运行的时间,时间默认为秒(和totalOps可以联合或者单独使用) -
totalOps:
表示执行多少次操作,比如当该值为10,object=(1,00),那么本来是要创建100个对象,加上totalOps后,就要循环从1-100创建10次,总共创建1000个文件,但是实际上创建出的文件数还是只有100个,像覆盖性创建一样 -
operation type:
操作类型,可以是read、write、delete等。-
ratio:
表示该操作所占有操作的比例,例如上面的例子中测试读写read的比例为80%,write的比例为20%; -
config:
配置bucket的前缀后缀信息。注意write的sizes可以根据实际测试进行修改
-
-
-
cleanup:
环境清理阶段,主要是删除bucket中的数据,保证测试后的数据不会保留在集群中 -
dispose:
这个阶段是删除bucket
main的方式是将读写任务写在一个work里,混合读写
也可以直接跳过prepare和main阶段,直接进行写的操作,再直接进行读
示例:
<workstage name="write">
<work name="write" workers="64" totalOps="100000">
<operation type="write" config="cprefix=cosbench;containers=r(1,1);objects=r(1,100000);sizes=c(4)KB" />
</work>
</workstage>
<workstage name="read">
<work name="read" workers="64" totalOps="100000">
<operation type="read" config="cprefix=cosbench;containers=r(1,1);objects=r(1,100000)" />
</work>
</workstage>
根据模板文件编写测试文件
[root@ceph-node1 0.4.2.c4]# cat conf/s3-config-test.xml
<?xml version="1.0" encoding="UTF-8" ?>
<workload name="s3-test1" description="10-100-4kb-test">
<storage type="s3" config="accesskey=OZGQE03XOX2DDD77M9OX;secretkey=yvqhvuWg7mGKWfx3JGggtgM6LdDnkeJhxj8MHJeg;endpoint=http://192.168.1.51:7480" />
<workflow>
<workstage name="init">
<work type="init" workers="1" config="cprefix=cosbench;containers=r(1,1)" />
</workstage>
<workstage name="prepare">
<work type="prepare" workers="1" config="cprefix=cosbench;containers=r(1,1);objects=r(1,100);sizes=c(4)KB" />
</workstage>
<workstage name="main">
<work name="main" workers="8" runtime="30">
<operation type="read" ratio="80" config="cprefix=cosbench;containers=u(1,1);objects=u(1,100)" />
<operation type="write" ratio="20" config="cprefix=cosbench;containers=u(1,1);objects=u(100,200);sizes=c(4)KB" />
</work>
</workstage>
<workstage name="cleanup">
<work type="cleanup" workers="1" config="cprefix=cosbench;containers=r(1,1);objects=r(1,200)" />
</workstage>
<workstage name="dispose">
<work type="dispose" workers="1" config="cprefix=cosbench;containers=r(1,1)" />
</workstage>
</workflow>
</workload>
六、执行启动
两种启动方式
1、通过脚本启动
[root@ceph-node1 0.4.2.c4]# sh cli.sh submit conf/s3-config-test.xml
Accepted with ID: w3
2、通过页面上传配置的xml文件启动
上传文件执行submit
七、结果分析
1、正在运行中的任务
2、结束的任务
3、点击结束任务列中【view details】详情中可查看测试结果
测试结果各参数说明:
-
Op-Type:
操作类型 -
Op-Count:
操作总数 -
Byte-Count:
操作产生的数据总量 -
Avg-ResTime:
操作产生的平均时间 -
Avg-ProcTime:
操作的平均时间,这个是主要的延时参考,它反映了平均每次请求的时延 -
Throughput:
吞吐量,主要反映了操作的并发程度,也是重要的参考(一秒完成的操作) -
Bandwidth:
带宽,反映了操作过程中的平均带宽情况(每秒传输的数据量) -
Succ-Ratio:
操作的成功率
主要看后四个值!!
也可以查看定义的各个任务,查看是否有失败的任务
End……