利用sysbench测试磁盘IO:
10台机器并发测试,一台fabric控制server,控制端需要安装fabric,测试server安装sysbench,测试时生成15G的测试文件;测试案例如下:
fabric的远程管理,可以看一下上篇博文:
http://xujunxian.blog.51cto.com/8614409/1730780
测试执行:
1、创建11台ubuntu台虚拟机,1台安装fabric,10台安装sysbench,并配置好IP地址,fabric需要直接访问安装sysbench的机器
2、将脚本fabric.py 拷贝至fabric服务器中,并运行命令:
fab sysbench>fabric.log测试完成后根据生成日志填入测试表中(填写10台总io)
脚本如下:
vim fabfile.py
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
|
from fabric.api
import
run
from fabric.context_managers
import
env
from fabric.context_managers
import
cd
env
.hosts = [
'10.32.32.30'
,
'10.32.32.31'
,
'10.32.32.32'
,
'10.32.32.33'
,
'10.32.32.34'
,
'10.32.32.35'
,
'10.32.32.36'
,
'10.32.32.37'
,
'10.32.32.38'
,
'10.32.32.39'
]
env
.user =
'root'
env
.password =
'1qaz@WSX'
env
.parallel = True
def host_type():
run(
'uname -s && ls -alh'
)
def sysbench():
with
cd
(
'/home/'
):
run(
'echo block 512 threads=1 mode=rndrd'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=512 --init-rng=on --file-total-size=15G --file-test-mode=rndrd run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 512 threads=32 mode=rndrd'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=512 --init-rng=on --file-total-size=15G --file-test-mode=rndrd run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 4096 threads=1 mode=rndrd'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=4096 --init-rng=on --file-total-size=15G --file-test-mode=rndrd run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 4096 threads=32 mode=rndrd'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=4096 --init-rng=on --file-total-size=15G --file-test-mode=rndrd run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 65536 threads=1 mode=rndrd'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=65536 --init-rng=on --file-total-size=15G --file-test-mode=rndrd run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 65536 threads=32 mode=rndrd'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=65536 --init-rng=on --file-total-size=15G --file-test-mode=rndrd run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 512 threads=1 mode=rndrw'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=512 --init-rng=on --file-total-size=15G --file-test-mode=rndrw run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 512 threads=32 mode=rndrw'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=512 --init-rng=on --file-total-size=15G --file-test-mode=rndrw run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 4096 threads=1 mode=rndrw'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=4096 --init-rng=on --file-total-size=15G --file-test-mode=rndrw run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 4096 threads=32 mode=rndrw'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=4096 --init-rng=on --file-total-size=15G --file-test-mode=rndrw run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 65536 threads=1 mode=rndrd'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=65536 --init-rng=on --file-total-size=15G --file-test-mode=rndrw run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 65536 threads=32 mode=rndrd'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=65536 --init-rng=on --file-total-size=15G --file-test-mode=rndrw run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 512 threads=1 mode=rndrd flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=512 --init-rng=on --file-total-size=15G --file-test-mode=rndrd --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 512 threads=32 mode=rndrd flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=512 --init-rng=on --file-total-size=15G --file-test-mode=rndrd --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 4096 threads=1 mode=rndrd flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=4096 --init-rng=on --file-total-size=15G --file-test-mode=rndrd --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 4096 threads=32 mode=rndrd flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=4096 --init-rng=on --file-total-size=15G --file-test-mode=rndrd --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 65536 threads=1 mode=rndrd flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=65536 --init-rng=on --file-total-size=15G --file-test-mode=rndrd --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 65536 threads=32 mode=rndrd flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=65536 --init-rng=on --file-total-size=15G --file-test-mode=rndrd --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 512 threads=1 mode=rndrw flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=512 --init-rng=on --file-total-size=15G --file-test-mode=rndrw --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 512 threads=32 mode=rndrw flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=512 --init-rng=on --file-total-size=15G --file-test-mode=rndrw --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 4096 threads=1 mode=rndrw flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=4096 --init-rng=on --file-total-size=15G --file-test-mode=rndrw --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 4096 threads=32 mode=rndrw flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=4096 --init-rng=on --file-total-size=15G --file-test-mode=rndrw --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 565536 threads=1 mode=rndrw flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=1 --file-block-size=65536 --init-rng=on --file-total-size=15G --file-test-mode=rndrw --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
run(
'echo block 65536 threads=32 mode=rndrw flag=direct'
)
run(
'sysbench --test=fileio --file-total-size=15G prepare'
)
run(
'sysbench --max-time=300 --max-requests=0 --test=fileio --num-threads=32 --file-block-size=65536 --init-rng=on --file-total-size=15G --file-test-mode=rndrw --file-extra-flags=direct run'
)
run(
'sysbench --test=fileio --file-total-size=15G cleanup'
)
|
参数详解:
sysbench --max-time=300 测试时间5分钟,不用更改
--num-threads=1 测试进程,更需需要测试的项目进行更改
--file-block-size=512 块儿大小,需要根据测试需求更改
Rndrd 为随机读,rndrw为随机读写,根据需求测试
--file-extra-flags=direct 根据测试需求添加
--file-num=N 代表生成测试文件的数量,默认为128。
--file-block-size=N 测试时所使用文件块的大小,如果想磁盘针对innodb存储引擎进行测试,可以将其设置为16384,即innodb存储引擎页的大小。默认为16384。
--file-total-size=SIZE 创建测试文件的总大小,默认为2G大小。
--file-test-mode=STRING 文件测试模式,包含:seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)。
--file-io-mode=STRING 文件操作的模式,sync(同步),async(异步),fastmmap(快速mmap),slowmmap(慢速mmap),默认为sync同步模式。
--file-async-backlog=N 对应每个线程队列的异步操作数,默认为128。
--file-extra-flags=STRING 打开文件时的选项,这是与API相关的参数。
--file-fsync-freq=N 执行fsync()函数的频率。fsync主要是同步磁盘文件,因为可能有系统和磁盘缓冲的关系。 0代表不使用fsync函数。默认值为100。
--file-fsync-all=[on|off] 每执行完一次写操作,就执行一次fsync。默认为off。
--file-fsync-end=[on|off] 在测试结束时执行fsync函数。默认为on。
--file-fsync-mode=STRING文件同步函数的选择,同样是和API相关的参数,由于多个操作系统对于fdatasync支持不同,因此不建议使用fdatasync。默认为fsync。
--file-merged-requests=N 大多情况下,合并可能的IO的请求数,默认为0。
--file-rw-ratio=N 测试时的读写比例,默认时为1.5,即可3:2。
本文转自Jx战壕 51CTO博客,原文链接:http://blog.51cto.com/xujpxm/1732311,如需转载请自行联系原作者