安装:
yum -y install make m4 autoconf automake libtool pkgconfig libaio-devel
rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
之后安装bzr
yum install bzr
获取sysbench 文件
bzr branch lp:sysbench
export CC=cc
export CXX=c++
export CFLAGS="-m64 -I /u01/app/oracle/product/12.2.0.1/db_1/rdbms/public"
export CXXFLAGS="$CFLAGS"
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1/db_1
export LD_LIBRARY_PATH=/u01/app/oracle/product/12.2.0.1/db_1/lib
./configure --prefix=/usr/local/sysbench --with-oracle --libdir=/u01/app/oracle/product/12.2.0.1/db_1/lib --without-mysql
make ORA_LIBS=/u01/app/oracle/product/12.2.0.1/db_1/lib/libclntsh.so
make install
echo "export PATH=$PATH:/usr/local/sysbench/bin">>/etc/profile
source /etc/profile
一般语法
prepare :用于文件IO和数据库OLTP测试的数据准备阶段。
run :性能测试阶段
cleanup :移除测试过程中产生的数据
cpu性能测试
--test=cpu --指明要测试的是CPU
--cpu-max-prime --最大的素数
--max-requests=20 --最大的请求次数,
--max-time=20 --最长允许执行时间,这只是一个软阀值
sysbench --test=cpu --cpu-max-prime=20000 run
sysbench 0.5: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored
Primer numbers limit: 20000
Threads started!
General statistics:
total time: 29.2874s --总运行时间
total number of events: 10000 --循环的次数
total time taken by event execution: 29.2790s --循环的执行时间
response time:
min: 2.82ms --最小单次执行时间
avg: 2.93ms --平均单次执行时间
max: 3.83ms --最长单次执行时间
approx. 95 percentile: 3.18ms --除去最高的5%剩余的95%中最长的执行时间
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 29.2790/0.00
[root@oracle1 ~]# sysbench --test=cpu --cpu-max-prime=5000 --max-requests=20 run
sysbench 0.5: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored
Primer numbers limit: 5000
Threads started!
General statistics:
total time: 0.0099s
total number of events: 20
total time taken by event execution: 0.0098s
response time:
min: 0.44ms
avg: 0.49ms
max: 0.53ms
approx. 95 percentile: 0.53ms
Threads fairness:
events (avg/stddev): 20.0000/0.00
execution time (avg/stddev): 0.0098/0.00
--max-time=20
--最长允许执行时间,这只是一个软阀值,虽然设置为20,结果还是跑了25秒
--感觉类似于一个任务开始之前,看一下之前所执行的任务用了多久,如果没有超过max-time,则开启次任务,任务一旦开启不会自动终止,一直要等到跑完
[root@oracle1 ~]# sysbench --test=cpu --cpu-max-prime=5000000 --max-time=20 run
sysbench 0.5: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored
Primer numbers limit: 5000000
Threads started!
General statistics:
total time: 20.7888s
total number of events: 3
total time taken by event execution: 20.7886s
response time:
min: 6906.44ms
avg: 6929.54ms
max: 6955.42ms
approx. 95 percentile: 6954.54ms
Threads fairness:
events (avg/stddev): 3.0000/0.00
execution time (avg/stddev): 20.7886/0.00
THREADS性能测试
--test=threads --指明测试内容为tread
--num-threads=20 --创建多少个进程
--thread-yields=500 --每次请求的压力 官方文档是说 锁定-释放CPU-解锁 但是这个yelid没搞清楚是什么操作
--thread-locks= 222 --需要创建的mutex的数量
[root@oracle1 ~]# sysbench --test=threads --num-threads=20 --thread-yields=500 --thread-locks=2222 run
sysbench 0.5: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 20
Random number generator seed is 0 and will be ignored
Threads started!
General statistics:
total time: 0.5511s
total number of events: 10000
total time taken by event execution: 11.0062s
response time:
min: 0.11ms
avg: 1.10ms
max: 33.97ms
approx. 95 percentile: 3.79ms
Threads fairness:
events (avg/stddev): 500.0000/708.16
execution time (avg/stddev): 0.5503/0.00
MUTEX性能测试
--num-threads --进程的数量
--mutex-num --mutex的数量
--mutex-locks --每次请求的mutex lock的数量
--mutex-loops --申请lock之前执行ok那个循环的次数
[root@oracle1 ~]# sysbench --test=mutex --num-threads=12 --mutex-num=10240 --mutex-locks=1000000 --mutex-loops=50000000 run
sysbench 0.5: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 12
Random number generator seed is 0 and will be ignored
Threads started!
General statistics:
total time: 2.6958s
total number of events: 12
total time taken by event execution: 32.1176s
response time:
min: 2611.74ms
avg: 2676.47ms
max: 2695.62ms
approx. 95 percentile: 2694.17ms
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 2.6765/0.02
MEMORY性能测试
[root@oracle1 ~]# sysbench --test=memory help
sysbench 0.5: multi-threaded system evaluation benchmark
memory options:
--memory-block-size=SIZE size of memory block for test [1K] --内存块的大小
--memory-total-size=SIZE total size of data to transfer [100G] --操纵内存的总体数量
--memory-scope=STRING memory access scope {global,local} [global] --内存的访问范围
--memory-hugetlb=[on|off] allocate memory from HugeTLB pool [off] --是否从HUGEPAGE中分配内存
--memory-oper=STRING type of memory operations {read, write, none} [write] --内存操作方式读或者写
--memory-access-mode=STRING memory access mode {seq,rnd} [seq] --内存访问方式 顺序还是随机
[root@oracle1 ~]# sysbench --test=memory --memory-block-size=8k --memory-total-size=100G --memory-access-mode=seq run
sysbench 0.5: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored
Threads started!
Operations performed: 13107200 (1128103.89 ops/sec)
102400.00 MB transferred (8813.31 MB/sec)
General statistics:
total time: 11.6188s
total number of events: 13107200
total time taken by event execution: 9.6169s
response time:
min: 0.00ms
avg: 0.00ms
max: 0.12ms
approx. 95 percentile: 0.00ms
Threads fairness:
events (avg/stddev): 13107200.0000/0.00
execution time (avg/stddev): 9.6169/0.00
FILEIO性能测试
--test=fileio 测试类型为fileio
--file-num=256 测试文件数量
--file-block-size=8K 每个块大小
--file-total-size=2G 测试文件总大小
--file-test-mode=rndrw 测试模式
[root@oracle1 ~]# sysbench --test=fileio --file-num=256 --file-block-size=8K --file-total-size=2G --file-test-mode=rndrw prepare
sysbench 0.5: multi-threaded system evaluation benchmark
256 files, 8192Kb each, 2048Mb total
Creating files for the test...
Extra file open flags: 0
Creating file test_file.0
Creating file test_file.1
Creating file test_file.2
Creating file test_file.3
Creating file test_file.4
Creating file test_file.5
Creating file test_file.6
Creating file test_file.7
Creating file test_file.8
Creating file test_file.9
Creating file test_file.10
Creating file test_file.11
Creating file test_file.12
Creating file test_file.13
Creating file test_file.14
Creating file test_file.15
Creating file test_file.16
Creating file test_file.17
Creating file test_file.18
Creating file test_file.19
Creating file test_file.20
Creating file test_file.21
Creating file test_file.22
Creating file test_file.23
Creating file test_file.24
Creating file test_file.25
Creating file test_file.26
Creating file test_file.27
Creating file test_file.28
Creating file test_file.29
Creating file test_file.30
Creating file test_file.31
Creating file test_file.32
Creating file test_file.33
Creating file test_file.34
Creating file test_file.35
Creating file test_file.36
Creating file test_file.37
Creating file test_file.38
Creating file test_file.39
Creating file test_file.40
Creating file test_file.41
Creating file test_file.42
Creating file test_file.43
Creating file test_file.44
Creating file test_file.45
Creating file test_file.46
Creating file test_file.47
Creating file test_file.48
Creating file test_file.49
Creating file test_file.50
Creating file test_file.51
Creating file test_file.52
Creating file test_file.53
Creating file test_file.54
Creating file test_file.55
Creating file test_file.56
Creating file test_file.57
Creating file test_file.58
Creating file test_file.59
Creating file test_file.60
Creating file test_file.61
Creating file test_file.62
Creating file test_file.63
Creating file test_file.64
Creating file test_file.65
Creating file test_file.66
Creating file test_file.67
Creating file test_file.68
Creating file test_file.69
Creating file test_file.70
Creating file test_file.71
Creating file test_file.72
Creating file test_file.73
Creating file test_file.74
Creating file test_file.75
Creating file test_file.76
Creating file test_file.77
Creating file test_file.78
Creating file test_file.79
Creating file test_file.80
Creating file test_file.81
Creating file test_file.82
Creating file test_file.83
Creating file test_file.84
Creating file test_file.85
Creating file test_file.86
Creating file test_file.87
Creating file test_file.88
Creating file test_file.89
Creating file test_file.90
Creating file test_file.91
Creating file test_file.92
Creating file test_file.93
Creating file test_file.94
Creating file test_file.95
Creating file test_file.96
Creating file test_file.97
Creating file test_file.98
Creating file test_file.99
Creating file test_file.100
Creating file test_file.101
Creating file test_file.102
Creating file test_file.103
Creating file test_file.104
Creating file test_file.105
Creating file test_file.106
Creating file test_file.107
Creating file test_file.108
Creating file test_file.109
Creating file test_file.110
Creating file test_file.111
Creating file test_file.112
Creating file test_file.113
Creating file test_file.114
Creating file test_file.115
Creating file test_file.116
Creating file test_file.117
Creating file test_file.118
Creating file test_file.119
Creating file test_file.120
Creating file test_file.121
Creating file test_file.122
Creating file test_file.123
Creating file test_file.124
Creating file test_file.125
Creating file test_file.126
Creating file test_file.127
Creating file test_file.128
Creating file test_file.129
Creating file test_file.130
Creating file test_file.131
Creating file test_file.132
Creating file test_file.133
Creating file test_file.134
Creating file test_file.135
Creating file test_file.136
Creating file test_file.137
Creating file test_file.138
Creating file test_file.139
Creating file test_file.140
Creating file test_file.141
Creating file test_file.142
Creating file test_file.143
Creating file test_file.144
Creating file test_file.145
Creating file test_file.146
Creating file test_file.147
Creating file test_file.148
Creating file test_file.149
Creating file test_file.150
Creating file test_file.151
Creating file test_file.152
Creating file test_file.153
Creating file test_file.154
Creating file test_file.155
Creating file test_file.156
Creating file test_file.157
Creating file test_file.158
Creating file test_file.159
Creating file test_file.160
Creating file test_file.161
Creating file test_file.162
Creating file test_file.163
Creating file test_file.164
Creating file test_file.165
Creating file test_file.166
Creating file test_file.167
Creating file test_file.168
Creating file test_file.169
Creating file test_file.170
Creating file test_file.171
Creating file test_file.172
Creating file test_file.173
Creating file test_file.174
Creating file test_file.175
Creating file test_file.176
Creating file test_file.177
Creating file test_file.178
Creating file test_file.179
Creating file test_file.180
Creating file test_file.181
Creating file test_file.182
Creating file test_file.183
Creating file test_file.184
Creating file test_file.185
Creating file test_file.186
Creating file test_file.187
Creating file test_file.188
Creating file test_file.189
Creating file test_file.190
Creating file test_file.191
Creating file test_file.192
Creating file test_file.193
Creating file test_file.194
Creating file test_file.195
Creating file test_file.196
Creating file test_file.197
Creating file test_file.198
Creating file test_file.199
Creating file test_file.200
Creating file test_file.201
Creating file test_file.202
Creating file test_file.203
Creating file test_file.204
Creating file test_file.205
Creating file test_file.206
Creating file test_file.207
Creating file test_file.208
Creating file test_file.209
Creating file test_file.210
Creating file test_file.211
Creating file test_file.212
Creating file test_file.213
Creating file test_file.214
Creating file test_file.215
Creating file test_file.216
Creating file test_file.217
Creating file test_file.218
Creating file test_file.219
Creating file test_file.220
Creating file test_file.221
Creating file test_file.222
Creating file test_file.223
Creating file test_file.224
Creating file test_file.225
Creating file test_file.226
Creating file test_file.227
Creating file test_file.228
Creating file test_file.229
Creating file test_file.230
Creating file test_file.231
Creating file test_file.232
Creating file test_file.233
Creating file test_file.234
Creating file test_file.235
Creating file test_file.236
Creating file test_file.237
Creating file test_file.238
Creating file test_file.239
Creating file test_file.240
Creating file test_file.241
Creating file test_file.242
Creating file test_file.243
Creating file test_file.244
Creating file test_file.245
Creating file test_file.246
Creating file test_file.247
Creating file test_file.248
Creating file test_file.249
Creating file test_file.250
Creating file test_file.251
Creating file test_file.252
Creating file test_file.253
Creating file test_file.254
Creating file test_file.255
2147483648 bytes written in 15.87 seconds (129.06 MB/sec).
[root@oracle1 ~]#
[root@oracle1 ~]# sysbench --test=fileio --file-num=256 --file-block-size=8K --file-total-size=2G --file-test-mode=rndrw run
sysbench 0.5: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored
Extra file open flags: 0
256 files, 8Mb each
2Gb total file size
Block size 8Kb
Number of IO requests: 10000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Threads started!
Operations performed: 6000 reads, 4000 writes, 25600 Other = 35600 Total
Read 46.875Mb Written 31.25Mb Total transferred 78.125Mb (9.3936Mb/sec)
1202.38 Requests/sec executed
General statistics:
total time: 8.3168s --总运行时间
total number of events: 10000 --测试次数
total time taken by event execution: 0.2969s --其中纯花费在测试上的时间
response time:
min: 0.00ms --最小时间
avg: 0.03ms --平均时间
max: 4.49ms --最大时间
approx. 95 percentile: 0.16ms --去除最高的5%后的最大时间
Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 0.2969/0.00
[root@oracle1 ~]# sysbench --test=fileio --file-num=256 --file-block-size=8K --file-total-size=2G --file-test-mode=rndrw cleanup
sysbench 0.5: multi-threaded system evaluation benchmark
Removing test files...