tongsiying

阅读|运动|自律

0%

BlockStorage-vdbench

001-vdbench安装

1
2
3
4
5
6
7
8
9
10
11
12
13
1.安装jdk:
mkdir -p /usr/local/java/;tar -vzxf jdk-8u181-linux-x64.tar.gz -C /usr/local/java/
vi /etc/profile
export JAVA_HOME=/usr/local/java/jdk1.8.0_181
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
source /etc/profile

2、检测vdbench能够使用:
进入vdbench相应目录下./vdbench -t 来测试一下vdbench的可用性,如果正常,会在目录下自动生成一个output目录。
root@node1:/home/vdbench/vdbench50406# ./vdbench -t
如果报错,则需修改vdbench的权限:
root@node03:/home/vdbench/vdbench50406# chmod 777 vdbench

002-文件系统测试

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
vdbench文件系统测试详细参数说明:
对于一个文件系统,配置以下参数:
(1)HD:主机定义。与虚拟块设备相同。
(2)FSD:文件系统定义
fsd= 标识文件系统定义的名称
anchor= 将在其中创建目录结构的目录
width= 要在定位符下创建的目录数
depth= 要在定位符下创建的级别数
files= 要在最低级别创建的文件数
sizes= (size,size,...) 将创建的文件大小
distribution= bottom(如果希望仅在最低级别创建文件)和 all(如果希望在所有目录中创建文件)
openflags= 用于打开一个文件系统 (Solaris) 的 flag_list
(3)FWD:文件系统工作负载定义
fwd= 标识文件系统工作负载定义的名称。
fsd= 要使用的文件系统定义的 ID。
host= 要用于此工作负载的主机的 ID。
fileio= random 或 sequential,表示文件 I/O 将执行的方式。
fileselect= random 或 sequential,标识选择文件或目录的方式。
xfersizes= 数据传输(读取和写入操作)处理的数据大小。
operation= mkdir、rmdir、createdeleteopencloseread、write、getattr和setattr。选择要执行的单个文件操作。
rdpct= (仅)读取和写入操作的百分比。
threads= 此工作负载的并发线程数量。每个线程需要至少 1 个文件。
4)RD:运行定义
fwd= 要使用的文件系统工作负载定义的 ID
fwdrate= 每秒执行的文件系统操作数量。
format= yes / no / only / restart / clean / directories。在开始运行之前要执行的操作。
yes:是每次都会先删除目录文件,再重新创建
restart:每次起的时候会先校验文件、目录是否全,不全的补上
no:不校验文件目录直接跑,事先最好将文件灌好
operations= 覆盖fwd操作。选项相同。
openflags=o_direct:处理缓存的方法。"o_direct"使用Linux的"O_DIRECT"选项不使用缓存直接写入磁盘。

vdbench文件系统测试Example:
fsd=fsd1,anchor=/mnt/cephfs02,depth=3,width=10,files=20,size(512,50,4k,50),openflags=o_direct
fwd=fwd1,fsd=fsd1,operation=write,xfersize=(4k,15,8k,35,1M,50),fileio=random,fileselect=random,threads=32
rd=rd1,fwd=fwd1,fwdrate=max,format=yes,elapsed=20,interval=1

3、运行脚本
root@node1:/home/vdbench/vdbench50406# ./vdbench -f examples/filesys/create_files -jn
其中-jn是为了做数据校验,目前还不太懂。

4、输出结果
会回写输出一大堆东西,如果没有出现错误,最后会出现:
Vdbench execution completed successfully. Output directory:  /home/vdbench/vdbench50406/output
每次运行后,vdbench 会创建一个包含以下文件的output文件夹:
1)errorlog.html——当为测试启用了数据验证(-jn)时,它可包含一些数据块中的错误的相关信息:
无效的密钥读取
无效的 lba 读取(一个扇区的逻辑字节地址)
无效的 SD 或 FSD 名称读取
数据损坏,即使在使用错误的 lba 或密钥时
数据损坏
坏扇区
2)flatfile.html——包含 vdbench 生成的一种逐列的 ASCII 格式的信息。
3)histogram.html——一种包含报告柱状图的响应时间、文本格式的文件。
4)logfile.html——包含 Java 代码写入控制台窗口的每行信息的副本。logfile.html 主要用于调试用途
5)parmfile.html——显示已包含用于测试的每项内容的最终结果
6)resourceN-M.html、resourceN.html、resourceN.var_adm_msgs.html
摘要报告、stdout/stderr 报告、主机 N 的摘要报告
最后 “nn” 行文件 /var/adm/messages 和 /var/adm/messages。每个 M 个 JVM/Slave 的目标主机 N 和主机 N 上为 0
7)sdN.histogram.html、sdN.html——每个 N 存储定义的柱状图和存储定义 “N” 报告。
8)summary.html——主要报告文件,显示为在每个报告间隔的每次运行生成的总工作负载,以及除第一个间隔外的所有间隔的加权平均值。
interval:报告间隔序号
I/O rate:每秒观察到的平均 I/O 速率
MB sec:传输的数据的平均 MB 数
bytes I/O:平均数据传输大小
read pct:平均读取百分比
resp time:以读/写请求持续时间度量的平均响应时间。所有 vdbench 时间都以毫秒为单位。
resp max:在此间隔中观察到的最大响应时间。最后一行包含最大值总数。
resp stddev:响应时间的标准偏差
cpu% sys+usr:处理器繁忙 = 100(系统 + 用户时间)(Solaris、Windows、Linux)
cpu% sys:处理器利用率:系统时间
9)swat_mon.txt,swat_mon_total.txt
  vdbench 与 Sun StorageTekTM Workload Analysis Tool (Swat) Trace Facility (STF) 相结合,支持重放使用 Swat 创建的一个轨迹的 I/O 工作负载。
Swat 使用 Create Replay File 选项创建和处理的轨迹文件会创建文件 flatfile.bin(flatfile.bin.gz 用于 vdbench403 和更高版本),其中包含 Swat 所识别的每个 I/O 操作的一条记录。
这些文件包含一个格式化的报告,可将该报告导入 Swat Performance Monitor (SPM)  中来创建性能图表。
1
2
3
4
fsd=fsd1,anchor=/mnt/test832,depth=1,width=1,files=1,size=1024g,openflags=o_direct
fwd=format,threads=1,xfersize=1m
fwd=fwd1,fsd=fsd1,xfersize=1m,fileio=random,fileselect=sequential,rdpct=0,threads=1
rd=rd1,fwd=fwd*,fwdrate=max,format=(restart,only),elapsed=600,interval=1

003-裸盘测试

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
vdbench裸盘测试——详细参数说明:
1、对于一个块设备,配置以下参数:
1)HD:主机定义
如果您希望展示当前主机,则设置 hd= localhost。如果希望指定一个远程主机,hd= label。
system= IP 地址或网络名称。
Example:
     hd=localhost,shell=ssh,vdbench=/home/vdbench/vdbench50406,user=root
     hd=hd1,system=10.147.0.15
     hd=hd2,system=10.147.37.173
注意:vdbench=dir ,这里的目录是指所有主机上的目录,这就表示,所有主机上的vdbench目录都要一样,且对应的配置要放在vdbench下面;

2)SD:存储定义
    sd= 标识存储的名称。
    host= 存储所在的主机的 ID。
    lun= 原始磁盘、磁带或文件系统的名称。vdbench 也可为您创建一个磁盘。
    threads= 对 SD 的最大并发 I/O 请求数量。默认为 8
    hitarea= 调整读取命中百分比的大小。默认为 1m。
    openflags= 用于打开一个lun 或一个文件的 flag_list,为了贴近真实场景,一般在这里选择o_direct,绕过缓存机制,直接写盘。
Example:
      sd=default,threads=32,openflags=o_direct,size=340G
      sd=sd1,hd=hd1,lun=/dev/sdb
      sd=sd2,hd=hd1,lun=/dev/sdc
      sd=sd3,hd=hd1,lun=/dev/sdd
      sd=sd4,hd=hd1,lun=/dev/sde
      sd=sd5,hd=hd1,lun=/dev/sdf
      sd=sd6,hd=hd1,lun=/dev/sdg
      sd=sd7,hd=hd1,lun=/dev/sdh
      sd=sd8,hd=hd1,lun=/dev/sdi
      sd=sd1,hd=hd2,lun=/dev/sdb
      sd=sd2,hd=hd2,lun=/dev/sdc
      sd=sd3,hd=hd2,lun=/dev/sdd
      sd=sd4,hd=hd2,lun=/dev/sde
      sd=sd5,hd=hd2,lun=/dev/sdf
      sd=sd6,hd=hd2,lun=/dev/sdg
      sd=sd7,hd=hd2,lun=/dev/sdh
      sd=sd8,hd=hd2,lun=/dev/sdi
      此配置区分了主机1和主机2,第一行是针对以下所有sd的通用配置;
      
3)WD:工作负载定义
    wd= 标识工作负载的名称。
    sd= 要使用的存储定义的 ID。
    host= 要运行此工作负载的主机的 ID。默认设置为 localhost。
    rdpct= 读取请求占请求总数的百分比。
    rhpct= 读取命中百分比。默认设置为 0
    whpct= 写入命中百分比。默认设置为 0
    xfersize= 要传输的数据大小。默认设置为 4k。
   seekpct= 随机寻道的百分比。可为随机值。
    openflags= 用于打开一个 lun 或一个文件的 flag_list。
    iorate= 此工作负载的固定 I/O 速率。
Example:
wd=wd1,sd=sd*,xfersize=4k,rdpct=0,seekpct=100
此配置,配置了块的大小,读的比例和随机比例;

4)RD:运行定义
    rd= 标识运行的名称。
    wd= 用于此运行的工作负载的 ID。
    iorate= (#,#,...) 一个或多个 I/O 速率。(这里可以控制运行的iops,如果不控制就设置成max)
    elapsed= time:以秒为单位的运行持续时间。默认设置为30。(设置长时间的运行,可能会使得数据更加稳定)
    warmup= time:加热期,最终会被忽略。
    distribution= I/O 请求的分布:指数、统一或确定性。
    pause= 在下一次运行之前休眠的时间,以秒为单位。
    openflags= 用于打开一个 lun 或一个文件的 flag_list。
Example:
rd=run1,wd=wd1,iorate=max,el=100000,in=1,warmup=600
此配置,配置了iorate(iops),运行时间,数据打印频率
vdbench裸盘测试examples:
hd=localhost,shell=ssh,vdbench=/home/vdbench/vdbench50406,user=root
hd=hd1,system=200.200.213.30
sd=default,threads=16,openflags=o_direct,size=30G
sd=sd1,hd=hd1,lun=/dev/sdb
sd=sd2,hd=hd1,lun=/dev/sdc
sd=sd3,hd=hd1,lun=/dev/sdb
sd=sd4,hd=hd1,lun=/dev/sdc
sd=sd5,hd=hd1,lun=/dev/sdb
sd=sd6,hd=hd1,lun=/dev/sdc
sd=sd7,hd=hd1,lun=/dev/sdb
sd=sd8,hd=hd1,lun=/dev/sdc
wd=wd1,sd=sd*,xfersize=4k,rdpct=0,seekpct=100
rd=run1,wd=wd1,iorate=max,el=100000,in=1,warmup=600

输出结果(部分):
Aug 13, 2018  interval        i/o   MB/sec   bytes   read     resp     read    write     resp     resp  queue  cpu%  cpu%
                             rate  1024**2     i/o    pct     time     resp     resp      max    stddev depth sys+u   sys
07:37:56.397         1      85.00     0.33    4096   0.00 2968.303    0.000 2968.303 6136.625 1844.150  308.5  83.4  23.9
07:37:56.459         2      83.00     0.32    4096   0.00 3184.730    0.000 3184.730 7861.568 1795.753  348.0  95.5  68.2
07:37:56.478         3      23.00     0.09    4096   0.00 3441.907    0.000 3441.907 5995.742 1011.997   61.2  71.4  42.9
07:37:56.493         4       0.00     0.00       0   0.00    0.000    0.000    0.000    0.000    0.000    0.7   NaN   NaN
07:37:56.647         5       0.00     0.00       0   0.00    0.000    0.000    0.000    0.000    0.000    0.8  83.3  33.3
07:38:01.132         6       0.00     0.00       0   0.00    0.000    0.000    0.000    0.000    0.000   40.8  85.7  33.3
07:38:01.162         7      44.00     0.17    4096   0.00 4070.731    0.000 4070.731 10818.509 2883.771  226.7  66.7  66.7
07:38:01.181         8       0.00     0.00       0   0.00    0.000    0.000    0.000    0.000    0.000    1.4  88.9  11.1
07:38:01.201         9      26.00     0.10    4096   0.00 4508.067    0.000 4508.067 15048.031 2778.336   27.7  91.7  55.6
07:38:01.630        10       8.00     0.03    4096   0.00 1806.932    0.000 1806.932 4328.737 1174.638   48.3  90.0  86.7
07:38:01.760 Detailed reporting is running behind; reporting of intervals 11-27 has been skipped.
07:38:54.054        28       0.00     0.00       0   0.00    0.000    0.000    0.000    0.000    0.000   15.9   NaN   NaN
07:39:01.272        29      17.00     0.07    4096   0.00 4937.274    0.000 4937.274 7454.897 1474.074   39.4   NaN   NaN
07:39:03.858 Detailed reporting is running behind; reporting of intervals 30-42 has been skipped.
07:39:59.480        89      84.00     0.33    4096   0.00 7764.630    0.000 7764.630 14029.705 2984.238  654.5  75.9  48.1
07:39:59.561        90       0.00     0.00       0   0.00    0.000    0.000    0.000    0.000    0.000  0.6  NaN NaN

004-多客户端运行

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
多客户端运行
1.Vdbench运行及结果查看
  ./vdbench -f parafile
  parafiile为配置文件,如果需要校验文件一致性可以可以指定-v参数,./vdbench -vf parafile
  在vdbench安装目录下面有output目录,可以查看运行及输出结果,适用于windows及linux。
  
2.Linux下联机运行
2.1 每个客户的都需要安装vdbench,路径保持一致
2.2 SSH互信,选一个客户的为父节点,把每个子节点都信任父节点(这种互信可能有问题建议dsa)
  父节点为93.93.41.5,子节点为93.93.41.6
  ssh-keygen -t rsa                           生成秘钥
  chmod 755 /root/.ssh/                    修改生成秘钥的权限
  scp /root/.ssh/id_rsa.pub 93.93.41.6:/root/.ssh/authorized_keys 拷贝公钥
2.3 验证SSH互信
  在父节点上ssh每一个子节点,如果不需要输入秘钥就能登录,则互信成功。
2.4 多客户端配置文件
hd=default,dbench=/home/Vdbench/,user=root,shell=ssh
hd=hd1,system=93.93.31.7
hd=hd2,system=93.93.41.8
hd=hd3,system=93.93.41.9
fsd=fsd1,anchor=/tmp/yht/client1,depth=2,width=100,files=2000,size=100m,shared=yes
fsd=fsd2,anchor=/tmp/yht/client2,depth=1,width=1000,files=2000,zies=(20m,40,100m,60),shared=yes
fsd=fsd3,anchor=/tmp/yht/client3,depth=1000,width=1,files2000,size=1m,shared=yes
fwd=fwd1,fsd=fsd1,host=hd1,operation=read,xfersize=(1m,40,64k,60),fileio=random,fileselect=sequantial,threads=32
fwd=fwd2,fsd=fsd2,host=hd2,operation=write,xfersize=64k,fileio=random,fileselect=sequantial,threads=32
fwd=fwd3,fsd=fsd3,host=hd3,rdpct=60,xfersize=4k,fileio=random,fileselect=sequantial,threads=32
rd=rd1,fwd=(fwd1-fwd3),fwdrate=max,format=restart,elapsed=600,interval=10

elapsed:定义测试时间
interval:测试结果刷新频率(1秒钟刷新一次测试结果)
iorate=max:运行最大io性能
openflags=o_direct:不走缓存,遍历整个磁盘(测试裸设备时使用)
sd:使用之前定义过的sd。
seekpct:定义顺序(seq)或随机(random)。为0则为顺序;为100则为随机
rdpct定义读写比率:100100%读,100%写。xfersize:定义测试文件块大小。
sd:存储描述,定义测试磁盘。
lun:定义测试磁盘为/dev/sdk。
threads:定义并行测试进程为64进程。
wd:工作描述,定义策略。
fwdrate= 每秒执行的文件系统操作数量。
format=yes/no/only/restart/clean/directories
在开始运行之前要执行的操作
yes:删除之前的文件结构,根据配置文件重新创建目录和文件
no:默认使用原来的文件目录结构,不会创建文件
restart:每次都会校验一下数据,是否达到背景数据要求,没有的话会继续创建目录和文件
elapsed:以秒为单位的运行持续时间,默认设置为  30s

脚本内容:(可按实际测试要求更改):
sd=sd1,lun=/dev/sdk,threads=64,range=(100g,150g)或者range=(30,50)容量百分比
wd=wd1,sd=sd*,seekpct=seq,rdpct=100,xfersize=1M,openflags=o_direct
rw=rd1,wd=wd*,elapses=120,interval=1,iorate=max
若是跑文件系统,先要挂载,之后在挂载的盘上建立文件,之后把脚本里的lun=/mnt/***就可以了
注:fsd中shared,vdbench不允许不同的slave之间共享同一个目录结构下的所有文件,因为这样会带来很大的开销,但是它们允许共享同一个目录结构。加入设置了shared=yes,那么不同的slave可以平分一个目录下所有的文件来进行访问,相当于每个slave有各自等分的访问区域,因此不能测试多个客户的对同一个文件的读写。一般不需要带
例如:
./vdbench -f 1M_seq_read -o /1M 测试脚本名称为1M_seq_read,测试结果放在/1M目录下,到所在目录查看sd1

005-vdbench遇到的问题

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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
报错:
19:24:18.955 Trying to connect to the Vdbench rsh daemon on host 10.243.88.221
19:24:18.955 The Vdbench rsh daemon must be started on each target host.
19:24:18.955 This requires a one-time start of './vdbench rsh' on the target host.
19:24:18.955 Trying this for 60 seconds only.
19:24:24.029 Waiting for slave connection: hd1-0

解决:
报错:Connection to closed by remote host
解决:
--增加ssh连接数:
修改服务器上的这个文件:/etc/ssh/sshd_config,找到两行:
MaxSessions:最大允许链接数,默认10.
MaxStartups:最大允许保持多少个未认证链接(未输入登录密码),默认值是10.
把他们的数字改大,例如改成
MaxSessions 1000
MaxStartups 1000
修改server端的配置文件/etc/ssh/sshd_config
# server每隔60秒给客户端发送一次保活信息包给客户端
ClientAliveInterval 60
# server端发出的请求客户端没有回应的次数达到86400次的时候就断开连接,正常情况下客户端都会相应
ClientAliveCountMax 86400
sed -i 's/#MaxSessions 10/MaxSessions 1000/g' /etc/ssh/sshd_config
sed -i 's/#MaxStartups 10:30:100/MaxStartups 1000/g' /etc/ssh/sshd_config
sed -i 's/#ClientAliveInterval 0/ClientAliveInterval 60/g' /etc/ssh/sshd_config
sed -i 's/#ClientAliveCountMax 3/ClientAliveCountMax 86400/g' /etc/ssh/sshd_config

最终发现:
使用dsa方式免密能解决:
在每台设备执行:
[root@sam ~]# rm -rf ~/.ssh
[root@sam ~]# mkdir ~/.ssh
[root@sam ~]# chmod 755 ~/.ssh
[root@sam .ssh]# /usr/bin/ssh-keygen -t dsa

将每个主机上的公共密钥文件id_dsa.pub的内容复制到~/.ssh/authorized_keys文件中。并把这个文件分别放到所有机器中。注意,当您第一次使用ssh访问远程主机时,其RSA密钥是未知的,所以提示确认一下,确认完毕后SSH将记录远程主机的RSA密钥,以后连接该主机就不用密码了。
[root@sam .ssh]# cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
将各个设备上的authorized_keys复制到其他设备上


报错:
18:55:17.085 removeKillAtEnd(): Unable to find ssh 10.238.162.4 -l root /opt/vdbench/vdbench SlaveJvm -m 10.238.162.1 -n 10.238.162.4-13-190922-18.44.03.130 -l hd4-0 -p 5570
18:55:17.225 removeKillAtEnd(): Unable to find /opt/vdbench/vdbench SlaveJvm -m 10.238.162.1 -n 10.238.162.1-10-190922-18.44.03.130 -l hd1-0 -p 5570
java.lang.RuntimeException: Slave hd5-0 prematurely terminated.
    at Vdb.common.failure(common.java:335)
    at Vdb.SlaveStarter.startSlave(SlaveStarter.java:198)
    at Vdb.SlaveStarter.run(SlaveStarter.java:47)
解决:
https://community.oracle.com/docs/DOC-1020657
修复了“ vdbench工作负载在带有errno的linux ext4挂载的分区上失败:INCORRECT_SIZE:'Vdbench确定没有足够的字节被读取或写入'”
将此类文件放在/opt/vdbench/classes/Vdb中

问题:
vdbench Too many thread blocks报错
解决:
每台设备的目录要不一样


正常测试是测试内存的2
比如内存是8g,那就是测试16g的数据
16g/目录数=结果*1024*1024=转换的结果/文件大小=结果(结果为每个目录的文件数)
根据上面的vdbench的配置文件就是:
16/100^2=0.0016*1024*1024=1677/128=15  测试的时候需要将file写成15就可以了

遇到ssh连接数超的情况:
增加ssh连接数:
修改服务器上的这个文件:/etc/ssh/sshd_config,找到两行:
MaxSessions:最大允许链接数,默认10.
MaxStartups:最大允许保持多少个未认证链接(未输入登录密码),默认值是10.
把他们的数字改大,例如改成
MaxSessions 1000
MaxStartups 1000

Out of memory:
modify the vdbench script and increase the '-Xmx512m' value where 512m equals the java  heap size requested.
解决:
方法1:Xmx改大一点,具体改多大,看你实际内存,Xms256m改小
if [ "$1" == "SlaveJvm" ]; then
  $java -client -Xmx16384m  -Xms256m -cp $cp Vdb.SlaveJvm $*
  exit $?
else
  $java -client -Xmx1024m  -Xms256m -cp $cp Vdb.Vdbmain $*
其它环境:4096不一定是最大的,我们现在物理环境是:110000
ulimit -u 4096

网址:
https://stackoverflow.com/questions/24763899/vdbench-outofmemoryerror-unable-to-create-new-native-thread
或者您正在使用CentOS,编辑/etc/security/limits.d/90-nproc.conf 并将行更改为:
* soft nproc 4096
workingsetsize=8388608kb,具体值为内存大小除以8
fsd=fsd7,workingsetsize=8388608kb,anchor=/mnt/data001/sntest-small/,depth=2,width=100,files=200,size=256k,openflags=o_direct


如下报错:
09:06:15.675 UnknownHostException: hd=hd1,system=10.244.25.11
09:06:15.676 ==> where: Vdb.common.getCurrentIP(common.java:1656)
09:06:16.181
09:06:16.181 common.failure():
            java.net.UnknownHostException: dev-11: dev-11: Temporary  failure in name resolution
java.net.UnknownHostException: dev-11: dev-11: Temporary failure in name  resolution
      at java.net.InetAddress.getLocalHost(InetAddress.java:1505)
      at Vdb.common.getCurrentIP(common.java:1649)
      at Vdb.SlaveStarter.startSlave(SlaveStarter.java:142)
      at Vdb.SlaveStarter.run(SlaveStarter.java:47)
Caused by: java.net.UnknownHostException: dev-11: Temporary failure in  name resolution
      at java.net.Inet6AddressImpl.lookupAllHostAddr(Native Method)
      at java.net.InetAddress$2.lookupAllHostAddr(InetAddress.java:928)
      at  java.net.InetAddress.getAddressesFromNameService(InetAddress.java:1323)
      at java.net.InetAddress.getLocalHost(InetAddress.java:1500)
      ... 3 more
解决:
修改vdbench case所在设备的hostname,以及/etc/hosts
Thanks ,Henk.
I have a question to consult, the about VDbench set time.
_________________________________________________________________________
hd=localhost
sd=default,threads=20
sd=sd_ro,lun=\\.\e:,range=(0,50)
sd=sd_rw,lun=\\.\e:,range=(51,100)
wd=default,xfersize=(4k,60,8k,20,16k,14,64k,6)
wd=wd_ro,sd=(sd_ro),rdpct=30,priority=1,seekpct=56,xfersize=(4k,48,8k,30,16k,11,32k,7,64k,3,128k,1)
wd=wd_rw,sd=(sd_rw),rdpct=30,priority=2,seekpct=88,xfersize=(4k,82,8k,9,16k,5,32k,2,64k,1,128k,1)
rd=run1,wd=(wd_ro,wd_rw),iorate=max,interval=1,elapsed=172800
_________________________________________________________________________
In the configuration file that setting time is feasible?
Because I read advice on some information in the configuration file don't set too long time.
very thankful,
ka
priority优先队列

005-vdbench常见问题

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
vdbench常见问题:http://blog.sina.com.cn/s/blog_96d0ebdb0102xc3j.html

1、-f参数后面多个配置文件是同时执行还是顺序执行;
   -f后面的配置文件里的参数通过parseParameterLines()函数进行顺序解析,写入并生成输出文件parmfile.html和parmscan.html(包含了完整的参数配置)。
执行时,首先运行rd,进入RD中调用的wd或fwd,然后进入WD或FWD中的sd或fsd(若有HD,同上调用)。

2、-v校验中逻辑字节地址/数据校验关键字是存储在哪个位置;
   数据块的大小是xfersize的值,数据校验时,每写入数据块512个字节包含一个8字节的lba和一个1字节的key值。
其中lba指的是字节地址,与文件系统的偏移量和文件的偏移量有关。
Key值记录了写入块的次数,每写入块一次,key值加1,加到126后直接返回1
3、-v校验中的校验是发生在什么时候;
每写入一次数据块时,先读后写,写前写后内容进行校验。
进行数据校验需要执行-v,也可以在参数文件中写入Validate=yes,也就是说,在配置文件执行生成系统文件后,校验一直进行。
4、-vt时间戳显示在哪,是什么意思,是否可以查看;
内存中最后一次写入或读取成功的时间戳。可以在输出结果中查看:
5、逻辑地址有啥用。
Lba记录了每个数据块的地址,校验时根据lba方便查找校验错误的地方。
6、校验错输出script_name什么意思,data_errors参数的作用;
返回校验错误,描述出错的位置,方便测试人员定位查阅。如问题5,定位在fsd=fsd1文件系统中出错及第二行中显示的文件名字及出错的位置。
7、-v该末尾一个字节。是否能校验么,报错的位置是否正确;
在文件末尾插入字节,可以被校验出。报错位置正确,定位在文件的结尾位置。
8、lba后面的值有什么意思;
lba指的是逻辑字节地址,与文件系统的偏移量和文件的偏移量有关。校验错误返回的lba指的是在文件中的出错位置。
9、-j和-v之间的区别;
-v的数据校验,校验文件会输出到内存中,但是一旦vdbench关闭或者系统重启,校验就会失败。而-j能进行持续校验,等下次重启时,会恢复原始数据重新校验。如果只写-j而不加-v,也会进行-v操作。
10、-j中有几个fsd就有几个jnl文件map文件
是的
运行./vdbench –j –f testcount ,生成日志文件所在的目录如下:
11、jnl和map文件有什么区别么?
开始执行时,vdbench会生成两个文件Map backup file 和journal file。系统出现故障时(仅仅丢失了内存映射表中的数据),这两个文件由于保留了原始数据(恢复数据时首先读取journal文件的数据,如果失败,再从Map backup文件中写入),方便测试人员继续进行读写和校验。
1)正常时:内存中数据校验映射表的内容写入到backup和journal文件。日志更新内容持续写入到journal文件结尾部分并生成日志记录。
2)系统出现问题时: Vdbench重启并进行数据修复,从journal文件开始部分读出原始数据,并把数据更新到内存映射表中。一旦journal到达文件结尾,读取并验证用“modified” 标记的所有数据块。接着执行(1)过程。
如果由于系统崩溃,journal文件的原始数据写入内存映射表中失败,直接读取backup文件内容并写入。
综上,可以看出,map backup文件修复数据性能更高。
12、命令之间有没有冲突
没有,但是命令设置时必须-f后面加 parmfile文件,如果有-s命令则会模拟执行文件。如果命令中只有-j却无-v,则隐含着进行数据校验生成日志文件。
13、count参数的意思
count=(nn,mm) 快速创建SD序列(nn是开始数字,mm是数字个数)
如fsd=fsd,anchor=/ww,count=(1,5)在/ww1-/ww5中创建fsd1-fsd5
如运行:
/mnt目录下显示的目录结构如下:
若在wd中限定fsd1,则只显示wwz1一个目录:
若在fsd中限定fsd1,则会出错,如下
14、range的wd的寻找范围,是否可以运用到fsd中
文件系统中不可用, 测试过程如下:
15、rdpct-rhpct-whpct区别
Sd中:
rdpct=nn
读操作的比例,默认为100%。rdpct=80代表读写比例41
rhpct=nn
只在读裸设备时使用,读缓存命中率,默认值为0
whpct=nn
只在写裸设备时使用,写缓存命中率,默认值为0
Fsd中不存在rhpct及whpct参数:
rdpct在文件上的读写操作比例。rdpct=80代表读写比例41。必须同时添加fileio=random参数,不能留空(系统默认fileio=sequential)
计算公式如下:
rdpct  = read.operations * 100. / (read.operations + write.operations);
16、缓存命中,rhpct部分,1M的意思。
只针对sd而言。
每一个存储体积被分成两部分:hit area指用于缓存命中部分(这由hitarea=nn设定,hitarea默认为1M),miss area 指SD剩下的部分缓存未命中的部分。
17、xfersize=(1-64k,d)执行顺序
   在文件系统中不支持这种方式。只支持xfersize=nn或xfersize=(x1,nn1,x2,nn2,…)其中nn1+nn2+…=100,报错如下:
18、xfersize=(1k,10)这种格式,是报错还是按照4k块大小执行剩余的90%
   直接报错,代码如下:
19、skew,IO倾斜比,没有IOrate参数时,参数是否生效;
直接会报错
在fsd中,fwdrate不存在时
vdbench常见问题
20、skew对IOPS生效还是对带宽生效
iops生效,skew时对fwdrate或iorate的分配
21、iorate指的是带宽还是iops
iops
22、rd的名字是否有要求
没有要求,可以任意定义,只是个名字而已。
23、count中,是否创建多个fsd?还是创建了5个目录?
多个fsd,每个fsd下又存在多个目录,见问题13
24、count中,rd引入部分fsd是否可以?
可以,见问题13

007-脚本举例

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
https://www.codercto.com/a/49559.html
*example workload: Single run, 10 raw disk



*HD: HOST Define
*SD: Storage Definition
*WD: Workload Definition
*RD: Run Definition
*
hd=default,vdbench=/root/vdbench,user=root,shell=ssh
hd=hd1,system=192.168.129.40
hd=hd2,system=192.168.129.41
sd=sd1,lun=/dev/sdb,host=hd1,openflags=o_direct,hitarea=0,range=(0,100),threads=2
sd=sd2,lun=/dev/sdb,host=hd2,openflags=o_direct,hitarea=0,range=(0,100),threads=2
wd=wd1,sd=(sd1,sd2),xfersize=(4096,100),rdpct=0,seekpct=100
rd=run1,wd=wd1,iorate=max,elapsed=600,warmup=300
* 2 rbd disks, 100% random, 0% read of 4k blocks at unlimited rate
上面的例子是测试两台机器的磁盘,每个磁盘两个线程写,4K的块大小,100%的写,100%随机,热身写300s,然后测试600s

openflags= 用于打开一个 lun 或一个文件的 flag_list,为了贴近真实场景,一般在这里选择o_direct,绕过缓存机制,直接写盘。
hitarea= 调整读取命中百分比的大小。默认为 1m
,range=(100g,150g)或者range=(30,50)容量百分比
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
文件系统:fileio=sequential/random
创建背景数据:(默认创建文件的块大小为128k)
【实际操作:
1、先通过format=restart将文件和目录数据灌注好
2、将format=restart改为format=no,直接在灌注好的文件目录上进行测试:读写
3、yes是删除原来的数据重新建】

data_errors=1000000000000000000000000
hd=default,vdbench=/opt/vdbench,user=root,shell=ssh,jvms=1
hd=hd1,system=10.244.208.11
hd=hd2,system=10.244.208.12
hd=hd3,system=10.244.208.13
hd=hd4,system=10.244.208.14
hd=hd5,system=10.244.208.15
hd=hd6,system=10.244.208.16
hd=hd7,system=10.244.208.17
hd=hd8,system=10.244.208.18
hd=hd9,system=10.244.208.19
hd=hd10,system=10.244.208.20

fsd=fsd1,anchor=/mysql/snbs001/,depth=1,width=5,files=5,size=1g
fsd=fsd2,anchor=/mysql/snbs002/,depth=1,width=5,files=5,size=1g
fsd=fsd3,anchor=/mysql/snbs003/,depth=2,width=10,files=1,size=1g
fsd=fsd4,anchor=/mysql/snbs004/,depth=2,width=10,files=1,size=1g
fsd=fsd5,anchor=/mysql/snbs005/,depth=2,width=10,files=2,size=1g
fsd=fsd6,anchor=/mysql/snbs006/,depth=2,width=10,files=2,size=1g
fsd=fsd7,anchor=/mysql/snbs007/,depth=2,width=10,files=3,size=1g
fsd=fsd8,anchor=/mysql/snbs008/,depth=2,width=10,files=3,size=1g
fsd=fsd9,anchor=/mysql/snbs009/,depth=2,width=10,files=3,size=1g
fsd=fsd10,anchor=/mysql/snbs010/,depth=2,width=10,files=3,size=1g

fsd=fsd11,anchor=/mysql/snbs011/,depth=2,width=100,files=5,size=256k
fsd=fsd12,anchor=/mysql/snbs012/,depth=2,width=100,files=5,size=256k
fsd=fsd13,anchor=/mysql/snbs013/,depth=2,width=100,files=10,size=256k
fsd=fsd14,anchor=/mysql/snbs014/,depth=2,width=100,files=10,size=256k
fsd=fsd15,anchor=/mysql/snbs015/,depth=2,width=100,files=30,size=256k
fsd=fsd16,anchor=/mysql/snbs016/,depth=2,width=100,files=30,size=256k
fsd=fsd17,anchor=/mysql/snbs017/,depth=2,width=100,files=60,size=256k
fsd=fsd18,anchor=/mysql/snbs018/,depth=2,width=100,files=60,size=256k
fsd=fsd19,anchor=/mysql/snbs019/,depth=2,width=100,files=60,size=256k
fsd=fsd20,anchor=/mysql/snbs020/,depth=2,width=100,files=60,size=256k


fwd=fwd1,fsd=fsd1,host=hd1,operation=create,threads=5
fwd=fwd2,fsd=fsd2,host=hd2,operation=create,threads=5
fwd=fwd3,fsd=fsd3,host=hd3,operation=create,threads=5
fwd=fwd4,fsd=fsd4,host=hd4,operation=create,threads=5
fwd=fwd5,fsd=fsd5,host=hd5,operation=create,threads=5
fwd=fwd6,fsd=fsd6,host=hd6,operation=create,threads=5
fwd=fwd7,fsd=fsd7,host=hd7,operation=create,threads=5
fwd=fwd8,fsd=fsd8,host=hd8,operation=create,threads=5
fwd=fwd9,fsd=fsd9,host=hd9,operation=create,threads=5
fwd=fwd10,fsd=fsd10,host=hd10,operation=create,threads=5

fwd=fwd11,fsd=fsd11,host=hd1,operation=create,threads=5
fwd=fwd12,fsd=fsd12,host=hd2,operation=create,threads=5
fwd=fwd13,fsd=fsd13,host=hd3,operation=create,threads=5
fwd=fwd14,fsd=fsd14,host=hd4,operation=create,threads=5
fwd=fwd15,fsd=fsd15,host=hd5,operation=create,threads=5
fwd=fwd16,fsd=fsd16,host=hd6,operation=create,threads=5
fwd=fwd17,fsd=fsd17,host=hd7,operation=create,threads=5
fwd=fwd18,fsd=fsd18,host=hd8,operation=create,threads=5
fwd=fwd19,fsd=fsd19,host=hd9,operation=create,threads=5
fwd=fwd20,fsd=fsd20,host=hd10,operation=create,threads=5

rd=rd1,fwd=fwd*,fwdrate=max,format=restart,elapsed=60,interval=5

顺序写:
[root@dev-11 cases]# cat seq_write
data_errors=1000000000000000000000000
hd=default,vdbench=/opt/vdbench,user=root,shell=ssh,jvms=1
hd=hd1,system=10.244.208.11
hd=hd2,system=10.244.208.12

fsd=fsd1,anchor=/mysql/snbs001/,depth=1,width=5,files=5,size=1g
fsd=fsd2,anchor=/mysql/snbs002/,depth=1,width=5,files=5,size=1g

fsd=fsd11,anchor=/mysql/snbs011/,depth=2,width=100,files=5,size=256k
fsd=fsd12,anchor=/mysql/snbs012/,depth=2,width=100,files=5,size=256k

fwd=fwd1,fsd=fsd1,host=hd1,operation=write,xfersize=16k,fileio=sequential,fileselect=random,threads=5
fwd=fwd2,fsd=fsd2,host=hd2,operation=write,xfersize=16k,fileio=sequential,fileselect=random,threads=5

fwd=fwd11,fsd=fsd11,host=hd1,operation=write,xfersize=16k,fileio=sequential,fileselect=random,threads=5
fwd=fwd12,fsd=fsd12,host=hd2,operation=write,xfersize=16k,fileio=sequential,fileselect=random,threads=5

rd=rd1,fwd=fwd*,fwdrate=max,format=restart,elapsed=600,interval=5

随机读写:
[root@dev-11 cases]# cat rand_readwrite
data_errors=1000000000000000000000000
hd=default,vdbench=/opt/vdbench,user=root,shell=ssh,jvms=1
hd=hd1,system=10.244.208.11
hd=hd2,system=10.244.208.12

fsd=fsd1,anchor=/mysql/snbs001/,depth=1,width=5,files=5,size=1g
fsd=fsd2,anchor=/mysql/snbs002/,depth=1,width=5,files=5,size=1g

fsd=fsd11,anchor=/mysql/snbs011/,depth=2,width=100,files=5,size=256k
fsd=fsd12,anchor=/mysql/snbs012/,depth=2,width=100,files=5,size=256k

fwd=fwd1,fsd=fsd1,host=hd1,operation=read,xfersize=16k,fileio=random,fileselect=random,threads=5
fwd=fwd2,fsd=fsd2,host=hd2,operation=read,xfersize=16k,fileio=random,fileselect=random,threads=5

fwd=fwd11,fsd=fsd11,host=hd1,operation=read,xfersize=16k,fileio=random,fileselect=random,threads=5
fwd=fwd12,fsd=fsd12,host=hd2,operation=read,xfersize=16k,fileio=random,fileselect=random,threads=5

fwd=fwd21,fsd=fsd1,host=hd1,operation=write,xfersize=16k,fileio=random,fileselect=random,threads=5
fwd=fwd22,fsd=fsd2,host=hd2,operation=write,xfersize=16k,fileio=random,fileselect=random,threads=5

fwd=fwd31,fsd=fsd11,host=hd1,operation=write,xfersize=16k,fileio=random,fileselect=random,threads=5
fwd=fwd32,fsd=fsd12,host=hd2,operation=write,xfersize=16k,fileio=random,fileselect=random,threads=5

rd=rd1,fwd=fwd*,fwdrate=max,format=restart,elapsed=600,interval=5
1
2
3
4
5
6
7
8
9
文件系统顺序读写:
fwd=fwd1,fsd=fsd*,operation=read,xfersize=1m,fileio=sequential,fileselect=random,threads=32
fwd=fwd2,fsd=fsd*,operation=write,xfersize=1m,fileio=sequential,fileselect=random,threads=32

块设备
hd=default,vdbench=/var/www/html/vdbench504,user=root,shell=sshs
sd=sd1,lun=/dev/vdc,openflags=o_direct,threads=1w
wd=wd1,sd=sd1,xfersize=16k,readpct=0,seekpct=100r
rd=rd1,wd=wd1,iorate=max,elapsed=120,maxdata=5500g,interval=1,warmup=30

008-python脚本

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
生成vedbench脚本:
#!/usr/bin/python
# -*- coding:utf8 -*-

import sys
import commands
BLOCK_NUM=["vdb","vdc"]
def gen_test_file(file_name, rs_list):
for num,rs in enumerate(rs_list):
with open(file_name + "-" + str(num), 'w') as fw:
fw.write("hd=default,vdbench=/opt/vdbench/vdbench,user=root,shell=ssh"+"\n")
for num,block in enumerate(BLOCK_NUM):
fw.write("sd=sd"+str(num)+",lun=/dev/"+block+",openflags=o_direct,threads=1"+"\n")
TEST_CONF="wd=wd1,sd=sd*,xfersize=16k,readpct={readpct},seekpct={seekpct}"
fw.write(TEST_CONF.format(readpct=rs['readpct'], seekpct=rs['seekpct'])+"\n")
fw.write("rd=rd1,wd=wd1,iorate=max,elapsed=300,maxdata=10g,interval=1,warmup=3"+"\n")
return

def main():
fn = 'test'
rs_list = [
{'readpct':100, 'seekpct':100},
{'readpct':0, 'seekpct':100},
{'readpct':100, 'seekpct':0},
{'readpct':0, 'seekpct':0},
]*3 #*3是这4个用例循环3次的意思
gen_test_file('./{}'.format(fn), rs_list)

if __name__ == '__main__':
main()
sys.exit(0)
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
#!/usr/bin/python
# -*- coding:utf8 -*-

import sys
import commands
BLOCK_NUM=["vdb","vdc"]
def gen_test_file(file_name, rs_list):
for num,rs in enumerate(rs_list):
with open(file_name + "-" + str(num), 'w') as fw:
fw.write("hd=default,vdbench=/opt/vdbench/vdbench,user=root,shell=ssh"+"\n")
for num,block in enumerate(BLOCK_NUM):
fw.write("sd=sd"+str(num)+",lun=/dev/"+block+",openflags=o_direct,threads=1"+"\n")
TEST_CONF="wd=wd1,sd=sd*,xfersize=16k,readpct={readpct},seekpct={seekpct}"
fw.write(TEST_CONF.format(readpct=rs['readpct'], seekpct=rs['seekpct'])+"\n")
fw.write("rd=rd1,wd=wd1,iorate=max,elapsed=300,maxdata=10g,interval=1,warmup=3"+"\n")
return

def main():
fn = 'test'
rs_list = [
{'readpct':100, 'seekpct':100},
{'readpct':0, 'seekpct':100},
{'readpct':100, 'seekpct':0},
{'readpct':0, 'seekpct':0},
]*3 #*3是这4个用例循环3次的意思
gen_test_file('./{}'.format(fn), rs_list)

for num0,rs in enumerate(rs_list):
cmd='/opt/vdbench/vdbench -f {}'.format(fn) + "-" + str(num0) + ' -o ./res' + str(num0)
print cmd
print commands.getoutput(cmd)


if __name__ == '__main__':
main()
sys.exit(0)
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
#!/usr/bin/python
# -*- coding:utf8 -*-

import sys
import commands

TEST_CONF="""
#hd=default,vdbench=/opt/vdbench/vdbench,user=root,shell=ssh
sd=sd1,lun=/dev/vdb,openflags=o_direct,threads=1
wd=wd1,sd=sd1,xfersize=16k,readpct={readpct},seekpct={seekpct}
rd=rd1,wd=wd1,iorate=max,elapsed=300,maxdata=10g,interval=1,warmup=3
"""
def gen_test_file(file_name, rs_list):
for num,rs in enumerate(rs_list):
with open(file_name + "-" + str(num), 'w') as fw:
fw.write(TEST_CONF.format(
readpct=rs['readpct'], seekpct=rs['seekpct'])
)
return

def main():
fn = 'test'
rs_list = [
{'readpct':100, 'seekpct':100},
{'readpct':0, 'seekpct':100},
{'readpct':100, 'seekpct':0},
{'readpct':0, 'seekpct':0},
]*3 #*3是这4个用例循环3次的意思
gen_test_file('./{}'.format(fn), rs_list)

for num0,rs in enumerate(rs_list):
cmd='/opt/vdbench/vdbench -f {}'.format(fn) + "-" + str(num0) + ' -o ./res' + str(num0)
print cmd
print commands.getoutput(cmd)
if __name__ == '__main__':
main()
sys.exit(0)
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
004 vdbench-python生成图片
# encoding: utf-8
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

file = open('map.txt') #打开文档
data = file.readlines() #读取文档数据
para_1 = [] #新建列表,用于保存第一列数据
para_2 = [] #新建列表,用于保存第二列数据
para_3 = []
para_4 = []
para_5 = []
para_6 = []
for num in data:
para_1.append(float(num.split(',')[0]))
para_2.append(float(num.split(',')[1]))
para_3.append(float(num.split(',')[2]))
para_4.append(float(num.split(',')[4]))
para_5.append(float(num.split(',')[5]))
para_6.append(float(num.split(',')[6]))

def figure_show(a,x,y):
plt.figure()
plt.title(a)
plt.plot(x, y)
plt.xlabel("second")
plt.ylabel(a)
plt.figtext(0.75, 0.45, a,
fontsize=40, color='gray',
ha='right', va='bottom', alpha=0.4)

plt.savefig(a+".png")

name = ["iops","MB","resp","read-resp","write-resp"]
y = [para_2, para_3, para_4, para_5, para_6]
for (i, j) in zip(name, y):
figure_show(i,para_1,j)
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
005 vdbench 批量生成脚本
config.py
#!/usr/bin/python
# -*- coding:utf8 -*-

import sys
import commands
import os
import ConfigParser

# 项目路径
rootDir = os.path.split(os.path.realpath(__file__))[0]
# config.ini文件路径
configFilePath = os.path.join(rootDir, 'config.ini')

def get_config_values(section, option):
"""
根据传入的section获取对应的value
:param section: ini配置文件中用[]标识的内容
:return:
"""
config = ConfigParser.ConfigParser()
config.read(configFilePath)
return config.get(section=section, option=option)

block = get_config_values('vdbench', 'block')
ip = get_config_values('vdbench', 'ip')
xfersize = get_config_values('vdbench', 'xfersize')
readpct = get_config_values('vdbench', 'readpct')
seekpct = get_config_values('vdbench', 'seekpct')
iorate = get_config_values('vdbench', 'iorate')
elapsed = get_config_values('vdbench', 'elapsed')
interval = get_config_values('vdbench', 'interval')
threads = get_config_values('vdbench', 'threads')

def gen_test_file(file_name):
with open(file_name , 'w') as fw:
fw.write("hd=default,vdbench=/opt/vdbench/vdbench,user=root,shell=ssh"+"\n"+"\n")
for num,IP in enumerate(ip.split(",")):
fw.write("hd=hd"+str(num)+",system="+IP+"\n")
fw.write("\n")
num2 = 0
for time in range(len(ip.split(","))):
for BLOCK in block.split(","):
num2 = num2+1
fw.write("sd=sd"+str(num2)+",host=hd"+str(time)+",lun=/dev/"+BLOCK+",openflags=o_direct,threads="+threads+"\n")
fw.write("\n")
fw.write("wd=wd1,sd=sd*,xfersize="+xfersize+",readpct="+readpct+",seekpct="+seekpct+"\n")
fw.write("rd=rd1,wd=wd1,iorate=max,elapsed="+elapsed+",interval="+interval+"\n")

if __name__ == '__main__':
gen_test_file("test-0")
sys.exit(0)
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
config.ini配置文件:注释,多种场景就在配置文件中加[config3]...

[root@ceph4 vdench]# cat config.ini
[vdbench]
block=sdc,sdd,sde,sdf,sdg,sdh,sdi,sdj,sdk,sdl,sdm,sdn,sdo,sdp,sdq,sdr,sds,sdt,sdu,sdv
ip=10.244.25.44,10.244.25.48,10.244.25.55
threads=1
iorate=2000
elapsed=300
interval=5
readpct=70
seekpct=100
xfersize=(1024k,20,4k,20,129k,20,16k,20,256k,20)


[root@ceph4 vdench]# cat config.ini.back
[vdbench]
block=vdb
ip=10.27.38.56
iorate=2000
elapsed=600
interval=5
threads=1

[config1]
readpct=100
seekpct=100
xfersize=(1024k,20,2049k,20,129k,20,256k,20,512k,20)

[config2]
readpct=0
seekpct=100
xfersize=(1024k,20,2049k,20,129k,20,256k,20,512k,20)
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
005 vdbench 批量脚本+执行+折现图
vdbench.py
#!/usr/bin/python
# -*- coding:utf8 -*-

import sys
import commands
import os
import ConfigParser
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

# 项目路径
rootDir = os.path.split(os.path.realpath(__file__))[0]
# config.ini文件路径
configFilePath = os.path.join(rootDir, 'config.ini')
config = ConfigParser.ConfigParser()
config.read(configFilePath)

def get_config_values(section, option):
"""
根据传入的section获取对应的value
:param section: ini配置文件中用[]标识的内容
:return:
"""
return config.get(section=section, option=option)

block = get_config_values('vdbench', 'block')
ip = get_config_values('vdbench', 'ip')
iorate = get_config_values('vdbench', 'iorate')
elapsed = get_config_values('vdbench', 'elapsed')
interval = get_config_values('vdbench', 'interval')
threads = get_config_values('vdbench', 'threads')

def gen_test_file(file_name,xfersize,readpct,seekpct):
with open(file_name, 'w') as fw:
fw.write("hd=default,vdbench=/opt/vdbench,user=root,shell=ssh"+"\n"+"\n")
for num1,IP in enumerate(ip.split(",")):
num =num1 + 1
fw.write("hd=hd"+str(num1)+",system="+IP+"\n")
fw.write("\n")
num2 = 0
for time in range(len(ip.split(","))):
for BLOCK in block.split(","):
num2 = num2+1
fw.write("sd=sd"+str(num2)+",host=hd"+str(time)+",lun=/dev/"+BLOCK+",openflags=o_direct,threads="+threads+"+"\n")
fw.write("\n")
fw.write("wd=wd1,sd=sd*,xfersize="+str(xfersize)+",readpct="+str(readpct)+",seekpct="+str(seekpct)+"\n")
fw.write("rd=rd1,wd=wd1,iorate=max,elapsed="+elapsed+",interval="+interval+"\n")

def png_show(path):
file = open(path+"map.txt") #打开文档
data = file.readlines() #读取文档数据
para_1 = [] #新建列表,用于保存第一列数据
para_2 = [] #新建列表,用于保存第二列数据
para_3 = []
para_4 = []
para_5 = []
para_6 = []
for num in data:
para_1.append(float(num.split(',')[0]))
para_2.append(float(num.split(',')[1]))
para_3.append(float(num.split(',')[2]))
para_4.append(float(num.split(',')[4]))
para_5.append(float(num.split(',')[5]))
para_6.append(float(num.split(',')[6]))

def figure_show(a,x,y):
plt.figure()
plt.title(a)
plt.plot(x, y)
plt.xlabel("second")
plt.ylabel(a)
plt.figtext(0.75, 0.45, a,
fontsize=40, color='gray',
ha='right', va='bottom', alpha=0.4)

plt.savefig(path+a+".png")

name = ["iops","MB","resp","read-resp","write-resp"]
y = [para_2, para_3, para_4, para_5, para_6]
for (i, j) in zip(name, y):
figure_show(i,para_1,j)

def main():
fn = 'test'
CONF=[]
for each in config.sections():
if 'config' in each:
CONF.append(each)
for num,cf in enumerate(CONF):
readpct = get_config_values(cf, 'readpct')
seekpct = get_config_values(cf, 'seekpct')
xfersize = get_config_values(cf, 'xfersize')
gen_test_file('./{}'.format(fn)+"-"+str(num),xfersize,readpct,seekpct)

for num,cf in enumerate(CONF):
PATH='output/' + format(fn)+"-"+str(num)+'/'
cmd='/opt/vdbench/vdbench -f {}'.format(fn) + "-" + str(num) + ' -o '+PATH
print(cmd)
print commands.getoutput(cmd)
com="grep -v \"[a-Z]\" "+PATH+"logfile.html|awk \'{$1=\"\";print $0}\'|sed \'s/^[ \t]*//\'|sed \'s/[ ][ ]*/,/g\'|sed \'/^\s*$/d\'|sed \'/*/d' >>" +PATH+"/map.txt"
os.system(com)
png_show(PATH)

if __name__ == '__main__':
main()
sys.exit(0)
config.ini配置文件:注释,多种场景就在配置文件中加[config3]...

[root@ceph4 vdench]# cat config.ini
[vdbench]
block=sdc,sdd,sde,sdf,sdg,sdh,sdi,sdj,sdk,sdl,sdm,sdn,sdo,sdp,sdq,sdr,sds,sdt,sdu,sdv
ip=10.244.25.44,10.244.25.48,10.244.25.55
threads=1
iorate=2000
elapsed=300
interval=5
readpct=70
seekpct=100
xfersize=(1024k,20,4k,20,129k,20,16k,20,256k,20)


[root@ceph4 vdench]# cat config.ini.back
[vdbench]
block=vdb
ip=10.27.38.56
iorate=2000
elapsed=600
interval=5
threads=1

[config1]
readpct=100
seekpct=100
xfersize=(1024k,20,2049k,20,129k,20,256k,20,512k,20)

[config2]
readpct=0
seekpct=100
xfersize=(1024k,20,2049k,20,129k,20,256k,20,512k,20)

ossfuse-vdbench测试

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
配置文件:
[root@sdfspstapp04 cases]# cat random_read_100_100_300-100th
hd=default,vdbench=/home/vdbench,user=root,shell=ssh
hd=hd1,system=10.244.124.90
hd=hd2,system=10.244.124.91
hd=hd3,system=10.244.124.92
hd=hd4,system=10.244.124.93

fsd=fsd1,anchor=/mnt/sdoss/read_1023a1,depth=2,width=100,files=300,size=128k
fsd=fsd2,anchor=/mnt/sdoss/read_1023a2,depth=2,width=100,files=300,size=128k
fsd=fsd3,anchor=/mnt/sdoss/read_1023a3,depth=2,width=100,files=300,size=128k
fsd=fsd4,anchor=/mnt/sdoss/read_1023a4,depth=2,width=100,files=300,size=128k

fwd=fwd1,fsd=fsd1,host=hd1,operation=read,xfersize=8k,fileio=random,fileselect=random,threads=100
fwd=fwd2,fsd=fsd2,host=hd2,operation=read,xfersize=8k,fileio=random,fileselect=random,threads=100
fwd=fwd3,fsd=fsd3,host=hd3,operation=read,xfersize=8k,fileio=random,fileselect=random,threads=100
fwd=fwd4,fsd=fsd4,host=hd4,operation=read,xfersize=8k,fileio=random,fileselect=random,threads=100

rd=rd1,fwd=fwd1,fwdrate=max,format=restart,elapesed=600,interval=5


测试时间:elapesed=600
vdbench测试原理:会先将目录文件建立好,在从文件中随机选出文件来进行读或者写,所以事先准备好的文件越多越好,概率问题


执行:
../vdbench -f ./random_read_100_100_300-100th -o ../output/res_random_read_100_100_300-100th_a2.log


实际操作:
1、先通过format=restart将文件和目录数据灌注好
2、将format=restart改为format=no,直接在灌注好的文件目录上进行测试:读写
3、yes是删除原来的数据重新建
赞赏一下吧~