12装置以及测试,sysbench基础测试工具安装

介绍

sysbench是二个模块化、跨平台、十2线程基准测试工具,主要用来测试分歧系统参数下的数据库负载情状,本文首要介绍0.四本子的使用。sysbench首要用于以下质量测试:

  • 文件I/O性能
  • 调度
  • 内部存款和储蓄器分配和传导
  • POSIX线程
  • 数据库

 

sysbench 压力测试,sysbench

sysbench是贰个模块化的、跨平台、二十八线程基准测试工具,首要用以评估测试种种不相同连串参数下的数据库负载景况。
它主要包罗以下两种办法的测试:
1、cpu性能
2、磁盘io性能
三、调整程序质量
4、内部存款和储蓄器分配及传输速度
五、POSIX线程品质
陆、数据库质量(OLTP基准测试)
脚下sysbench主要支撑 MySQL,pgsql,oracle 那三种数据库。

sysbench是贰个模块化的、跨平台、二10三十二线程基准测试工具,首要用于评估测试各样区别系统参数下的数据库负载情形。它根本不外乎以下三种艺术的测试:

安装

一.设置插件

yum install libtool -y

2.安装

./configure  --prefix=/usr/local/sysbench-0.4.12 --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
make 
make install
cp  -r sysbench/tests  /usr/local/sysbench-0.4.12
ln -s /usr/local/sysbench-0.4.12/bin/sysbench /usr/local/sysbench-0.4.12/sysbench

修改情状变量,在意况变量中进入

export LD_LIBRARY_PATH=/usr/local/mysql/lib

留神:即便设置目录中从不configure那么必要实践以下操作:

chmod +x autogen.sh

./autogen.sh

万1想要让 sysbench 协助 oracle /pgsql
的话,就必要在编写翻译的时候增多参数
–with-oracle

或者

–with-pgsql

介绍

sysbench是叁个模块化、跨平台、二十八线程基准测试工具,重要用来测试不一样系统参数下的数据库负载情况,本文首要介绍0.4本子的采取。sysbench主要用于以下品质测试:

  • 文件I/O性能
  • 调度
  • 内部存储器分配和传导
  • POSIX线程
  • 数据库

 

一、sysbench安装

    1、cpu性能

相似语法 

prepare:用于文书IO和数据库OLTP测试的多寡希图阶段。

run:质量测试阶段

cleanup:移除测试进程中生出的数额

help:突显援救信息,获取–test帮衬可以动用–test=name –help

安装

1.装置插件

yum install libtool -y

2.安装

./configure  --prefix=/usr/local/sysbench-0.4.12 --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
make 
make install
cp  -r sysbench/tests  /usr/local/sysbench-0.4.12
ln -s /usr/local/sysbench-0.4.12/bin/sysbench /usr/local/sysbench-0.4.12/sysbench

修改境遇变量,在意况变量中进入

export LD_LIBRARY_PATH=/usr/local/mysql/lib

留神:要是设置目录中平昔不configure那么要求实行以下操作:

chmod +x autogen.sh

./autogen.sh

要是想要让 sysbench 扶助 oracle /pgsql
的话,就要求在编写翻译的时候加多参数
–with-oracle

或者

–with-pgsql

首先,在
http://imysql.com/wp-content/uploads/2014/09/sysbench-0.4.12-1.1.tgz
下载源码包。下载解压后进入安装。

    2、磁盘io性能

通用命令选项

那部分限令参数的通用的,不管–test测试什么内容都得以利用这么些通用的授命。能够推行sysbench
–help领会各参数的切实表明

General options:
  --num-threads=N             number of threads to use [1]
  --max-requests=N            limit for total number of requests [10000]
  --max-time=N                limit for total execution time in seconds [0]
  --forced-shutdown=STRING    amount of time to wait after --max-time before forcing shutdown [off]
  --thread-stack-size=SIZE    size of stack per thread [32K]
  --init-rng=[on|off]         initialize random number generator [off]
  --seed-rng=N                seed for random number generator, ignored when 0 [0]
  --tx-rate=N                 target transaction rate (tps) [0]
  --tx-jitter=N               target transaction variation, in microseconds [0]
  --report-interval=N         periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
  --report-checkpoints=[LIST,...]dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
  --test=STRING               test to run
  --debug=[on|off]            print more debugging info [off]
  --validate=[on|off]         perform validation checks where possible [off]
  --help=[on|off]             print help and exit
  --version=[on|off]          print version and exit

Log options:
  --verbosity=N      verbosity level {5 - debug, 0 - only critical messages} [4]

  --percentile=N      percentile rank of query response times to count [95]

Compiled-in tests:
  fileio - File I/O test
  cpu - CPU performance test
  memory - Memory functions speed test
  threads - Threads subsystem performance test
  mutex - Mutex performance test
  oltp - OLTP test

Commands: prepare run cleanup help version

See 'sysbench --test=<name> help' for a list of options for each test.

根本的参数有

–num-threads、

–max-requests、

–test

以下多少个参数也常常会采用:

–max-time 最大的测试时间长度

–debug(开启debug可以展现更详细的每种线程的推市场价格况)

诚如语法 

prepare:用于文书IO和数目库OLTP测试的数据希图阶段。

run:品质测试阶段

cleanup:移除测试进度中发出的数额

help:展现扶助音讯,获取–test辅助能够应用–test=name –help

[root@localhost src]# tar zxvf sysbench-0.4.12-1.1.tgz
[root@localhost src]# cd sysbench-0.4.12-1.1
[root@localhost sysbench-0.4.12-1.1]# ls
autogen.sh configure.ac install-sh missing README-WIN.txt
ChangeLog COPYING m4 mkinstalldirs sysbench
config doc Makefile.am README TODO
解压后意识,并从未布署文件configure

    3、调解程序质量

CPU测试

对CPU的习性测试经常有:壹.
经过算质数;二测算圆周率等;sysbench使用的正是透过质数相加的测试。对CPU测试直接运维run就能够

./sysbench --num-threads=12 --max-requests=10000 --debug=on --test=cpu --cpu-max-prime=20000 run

上面包车型大巴测试是:13个线程实施10000条请求,每一个请求推行质数相加到两千0

997755.com澳门葡京 1

通用命令选项

997755.com澳门葡京,这部分发令参数的通用的,不管–test测试什么内容都足以行使这几个通用的吩咐。能够实行sysbench
–help精晓各参数的实际表达

General options:
  --num-threads=N             number of threads to use [1]
  --max-requests=N            limit for total number of requests [10000]
  --max-time=N                limit for total execution time in seconds [0]
  --forced-shutdown=STRING    amount of time to wait after --max-time before forcing shutdown [off]
  --thread-stack-size=SIZE    size of stack per thread [32K]
  --init-rng=[on|off]         initialize random number generator [off]
  --seed-rng=N                seed for random number generator, ignored when 0 [0]
  --tx-rate=N                 target transaction rate (tps) [0]
  --tx-jitter=N               target transaction variation, in microseconds [0]
  --report-interval=N         periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
  --report-checkpoints=[LIST,...]dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. []
  --test=STRING               test to run
  --debug=[on|off]            print more debugging info [off]
  --validate=[on|off]         perform validation checks where possible [off]
  --help=[on|off]             print help and exit
  --version=[on|off]          print version and exit

Log options:
  --verbosity=N      verbosity level {5 - debug, 0 - only critical messages} [4]

  --percentile=N      percentile rank of query response times to count [95]

Compiled-in tests:
  fileio - File I/O test
  cpu - CPU performance test
  memory - Memory functions speed test
  threads - Threads subsystem performance test
  mutex - Mutex performance test
  oltp - OLTP test

Commands: prepare run cleanup help version

See 'sysbench --test=<name> help' for a list of options for each test.

关键的参数有

–num-threads、

–max-requests、

–test

以下多少个参数也每每会使用:

–max-time 最大的测试时间长度

–debug(开启debug可以体现更详尽的各类线程的履市场价格况)

此地必要一直运转sysbench提供的脚本autogen.sh,运维脚本autogen.sh此前,须要通过yum安装碰到

12装置以及测试,sysbench基础测试工具安装。    4、内部存款和储蓄器分配及传输速度

thread测试

测试线程调节的品质,用于高负载下的线程品质测试。

  –thread-yields=N     
各样请求实行“lock/yield/unlock”循环的次数,暗许一千

  –thread-locks=N       各种线程的互斥锁,默许七个

./sysbench --num-threads=12 --max-requests=10000  --test=threads --thread-yields=100 --thread-locks=2 run

997755.com澳门葡京 2

CPU测试

对CPU的属性测试平时有:一.
因而算质数;二测算圆周率等;sysbench使用的就是通过质数相加的测试。对CPU测试直接运维run就可以

./sysbench --num-threads=12 --max-requests=10000 --debug=on --test=cpu --cpu-max-prime=20000 run

地点的测试是:10个线程施行两万条请求,每一个请求实践质数相加到三千0

997755.com澳门葡京 3

[root@localhost sysbench-0.4.12-1.1]# yum install m4 autoconf
automake libtool
[root@localhost sysbench-0.4.12-1.1]#
./autogen.sh
退换文书配置文件之后,进入配置阶段,假如您的mysql是正统设置的话,能够直接运转,实行安装。

    5、POSIX线程质量

memory测试

内存分配测试,重假若针对差别的块大小进行内部存款和储蓄器的连天读写也许私下读写测试。

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]
  --memory-oper=STRING        type of memory operations {read, write, none} [write]
  --memory-access-mode=STRING memory access mode {seq,rnd} [seq]

一.八k每一个分配

./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=8K --memory-total-size=100G --memory-access-mode=seq run

997755.com澳门葡京 4997755.com澳门葡京 5

[root@localhost sysbench-0.4.12]# ./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=8K --memory-total-size=100G --memory-access-mode=seq run
sysbench 0.4.12.10:  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


Doing memory operations speed test
Memory block size: 8K

Memory transfer size: 102400M

Memory operations type: write
Memory scope type: global
Threads started!
Done.

Operations performed: 13107200 (993893.95 ops/sec)

102400.00 MB transferred (7764.80 MB/sec)


General statistics:
    total time:                          13.1877s
    total number of events:              13107200
    total time taken by event execution: 91.9173
    response time:
         min:                                  0.00ms
         avg:                                  0.01ms
         max:                                  0.93ms
         approx.  95 percentile:               0.02ms

Threads fairness:
    events (avg/stddev):           1092266.6667/4629.30
    execution time (avg/stddev):   7.6598/0.02

View Code

报告:时间13S,7.7G/S

二.八k随机分配

./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=8K --memory-total-size=100G --memory-access-mode=rnd run

997755.com澳门葡京 6997755.com澳门葡京 7

[root@localhost sysbench-0.4.12]# ./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=8K --memory-total-size=100G --memory-access-mode=rnd run
sysbench 0.4.12.10:  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


Doing memory operations speed test
Memory block size: 8K

Memory transfer size: 102400M

Memory operations type: write
Memory scope type: global
Threads started!
Done.

Operations performed: 13107200 (1036066.63 ops/sec)

102400.00 MB transferred (8094.27 MB/sec)


General statistics:
    total time:                          12.6509s
    total number of events:              13107200
    total time taken by event execution: 71.5377
    response time:
         min:                                  0.00ms
         avg:                                  0.01ms
         max:                                  0.90ms
         approx.  95 percentile:               0.02ms

Threads fairness:
    events (avg/stddev):           1092266.6667/19850.15
    execution time (avg/stddev):   5.9615/0.02

View Code

报告:12.6S,8G/s

三.1陆K逐项分配

./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=16K --memory-total-size=100G --memory-access-mode=seq run

997755.com澳门葡京 8997755.com澳门葡京 9

[root@localhost sysbench-0.4.12]# ./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=16K --memory-total-size=100G --memory-access-mode=seq run
sysbench 0.4.12.10:  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


Doing memory operations speed test
Memory block size: 16K

Memory transfer size: 102400M

Memory operations type: write
Memory scope type: global
Threads started!
Done.

Operations performed: 6553600 (832528.85 ops/sec)

102400.00 MB transferred (13008.26 MB/sec)


General statistics:
    total time:                          7.8719s
    total number of events:              6553600
    total time taken by event execution: 63.7133
    response time:
         min:                                  0.00ms
         avg:                                  0.01ms
         max:                                  0.90ms
         approx.  95 percentile:               0.02ms

Threads fairness:
    events (avg/stddev):           546133.3333/1321.35
    execution time (avg/stddev):   5.3094/0.01

View Code

报告:7S,13G/S

四.16K随机分配

./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=16K --memory-total-size=100G --memory-access-mode=rnd run

997755.com澳门葡京 10997755.com澳门葡京 11

[root@localhost sysbench-0.4.12]# ./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=16K --memory-total-size=100G --memory-access-mode=rnd run
sysbench 0.4.12.10:  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


Doing memory operations speed test
Memory block size: 16K

Memory transfer size: 102400M

Memory operations type: write
Memory scope type: global
Threads started!
Done.

Operations performed: 6553600 (1018696.38 ops/sec)

102400.00 MB transferred (15917.13 MB/sec)


General statistics:
    total time:                          6.4333s
    total number of events:              6553600
    total time taken by event execution: 36.1789
    response time:
         min:                                  0.00ms
         avg:                                  0.01ms
         max:                                  0.88ms
         approx.  95 percentile:               0.02ms

Threads fairness:
    events (avg/stddev):           546133.3333/5577.58
    execution time (avg/stddev):   3.0149/0.01

[root@localhost sysbench-0.4.12]# 

View Code

报告:6.4S,15G/s

计算:对于分红一样大小的内部存款和储蓄器,块月大分配的速率越快,随机分配比顺序分配的进程要快

thread测试

测试线程调整的本性,用于高负载下的线程品质测试。

  –thread-yields=N     
每种请求实践“lock/yield/unlock”循环的次数,默许一千

  –thread-locks=N       各个线程的互斥锁,私下认可8个

./sysbench --num-threads=12 --max-requests=10000  --test=threads --thread-yields=100 --thread-locks=2 run

997755.com澳门葡京 12

[root@localhost sysbench-0.4.12-1.1]# ./configure
[root@localhost sysbench-0.4.12-1.1]# make && make install
只要不是mysql不是行业内部设置的话,必要在计划文件中钦命

    陆、数据库品质(OLTP基准测试

文件io测试

./sysbench –test=fileio help

文件IO的测试首要用于测试IO的负载质量。首要的测试选项为–file-test-mode。还有多少个能够关切的参数蕴涵–file-block-size、–file-io-mode、–file-fsync-freq
、–file-rw-ratio

--file-num=N                   创建测试文件的数量,默认128个
  --file-block-size=N          block size大小,默认16K
  --file-total-size=SIZE       所有文件的总大小,默认2G
  --file-test-mode=STRING      测试类型 {seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)}
  --file-io-mode=STRING         I/O模式,需要系统支持默认sync[sync(同步IO),async(异步IO),mmap()]
  --file-async-backlog=N        每个线程的异步操作队列数,默认128个,需要--file-io-mode=async;
  --file-extra-flags=STRING     additional flags to use on opening files {sync,dsync,direct} []
  --file-fsync-freq=N           当请求数达到多少时执行fsync()刷新,默认100,0代表过程中不执行fsync()
  --file-fsync-all=[on|off]     执行每一个写操作后执行fsync()刷新操作,默认关闭off
  --file-fsync-end=[on|off]     测试结束执行fsync()操作,默认开启on
  --file-fsync-mode=STRING      同步刷新方法,默认fsync {fsync, fdatasync} 
  --file-merged-requests=N      合并指定数量的IO请求,0代表不合并,默认0
  --file-rw-ratio=N            读写比例,默认1.5/1

./sysbench --num-threads=12 --max-requests=10000  --test=fileio --file-total-size=3G --file-test-mode=rndrw prepare
./sysbench --num-threads=12 --max-requests=10000  --test=fileio --file-total-size=3G --file-test-mode=rndrw run
./sysbench --num-threads=12 --max-requests=10000  --test=fileio --file-total-size=3G --file-test-mode=rndrw clean

997755.com澳门葡京 13

留意:要是要对照两台服务器的io性能,须要跑同壹的线程。

memory测试

内部存储器分配测试,首假诺针对性分歧的块大小进行内存的连天读写只怕专擅读写测试。

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]
  --memory-oper=STRING        type of memory operations {read, write, none} [write]
  --memory-access-mode=STRING memory access mode {seq,rnd} [seq]

1.8k顺序分配

./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=8K --memory-total-size=100G --memory-access-mode=seq run

997755.com澳门葡京 14[[email protected]
sysbench-0.4.12]# ./sysbench –num-threads=12 –max-requests=10000
–test=memory –memory-block-size=8K –memory-total-size=100G
–memory-access-mode=seq run sysbench 0.4.12.10: 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 Doing
memory operations speed test Memory block size: 8K Memory transfer size:
102400M Memory operations type: write Memory scope type: global Threads
started! Done. Operations performed: 13107200 (993893.95 ops/sec)
102400.00 MB transferred (7764.80 MB/sec) General statistics: total
time: 13.1877s total number of events: 13107200 total time taken by
event execution: 91.9173 response time: min: 0.00ms avg: 0.01ms max:
0.93ms approx. 95 percentile: 0.02ms Threads fairness: events
(avg/stddev): 1092266.6667/4629.30 execution time (avg/stddev):
7.6598/0.02 View Code

报告:时间13S,7.7G/S

二.八k随机分配

./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=8K --memory-total-size=100G --memory-access-mode=rnd run

997755.com澳门葡京 15[[email protected]
sysbench-0.4.12]# ./sysbench –num-threads=12 –max-requests=10000
–test=memory –memory-block-size=8K –memory-total-size=100G
–memory-access-mode=rnd run sysbench 0.4.12.10: 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 Doing
memory operations speed test Memory block size: 8K Memory transfer size:
102400M Memory operations type: write Memory scope type: global Threads
started! Done. Operations performed: 13107200 (1036066.63 ops/sec)
102400.00 MB transferred (8094.27 MB/sec) General statistics: total
time: 12.6509s total number of events: 13107200 total time taken by
event execution: 71.5377 response time: min: 0.00ms avg: 0.01ms max:
0.90ms approx. 95 percentile: 0.02ms Threads fairness: events
(avg/stddev): 1092266.6667/19850.15 execution time (avg/stddev):
5.9615/0.02 View Code

报告:12.6S,8G/s

3.1六K每种分配

./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=16K --memory-total-size=100G --memory-access-mode=seq run

997755.com澳门葡京 16[[email protected]
sysbench-0.4.12]# ./sysbench –num-threads=12 –max-requests=10000
–test=memory –memory-block-size=16K –memory-total-size=100G
–memory-access-mode=seq run sysbench 0.4.12.10: 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 Doing
memory operations speed test Memory block size: 16K Memory transfer
size: 102400M Memory operations type: write Memory scope type: global
Threads started! Done. Operations performed: 6553600 (832528.85 ops/sec)
102400.00 MB transferred (13008.26 MB/sec) General statistics: total
time: 7.8719s total number of events: 6553600 total time taken by event
execution: 63.7133 response time: min: 0.00ms avg: 0.01ms max: 0.90ms
approx. 95 percentile: 0.02ms Threads fairness: events (avg/stddev):
546133.3333/1321.35 execution time (avg/stddev): 5.3094/0.01 View Code

报告:7S,13G/S

四.1六K随机分配

./sysbench --num-threads=12 --max-requests=10000 --test=memory --memory-block-size=16K --memory-total-size=100G --memory-access-mode=rnd run

997755.com澳门葡京 17[[email protected]
sysbench-0.4.12]# ./sysbench –num-threads=12 –max-requests=10000
–test=memory –memory-block-size=16K –memory-total-size=100G
–memory-access-mode=rnd run sysbench 0.4.12.10: 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 Doing
memory operations speed test Memory block size: 16K Memory transfer
size: 102400M Memory operations type: write Memory scope type: global
Threads started! Done. Operations performed: 6553600 (1018696.38
ops/sec) 102400.00 MB transferred (15917.13 MB/sec) General statistics:
total time: 6.4333s total number of events: 6553600 total time taken by
event execution: 36.1789 response time: min: 0.00ms avg: 0.01ms max:
0.88ms approx. 95 percentile: 0.02ms Threads fairness: events
(avg/stddev): 546133.3333/5577.58 execution time (avg/stddev):
3.0149/0.01
[[email protected]
sysbench-0.4.12]# View Code

报告:6.4S,15G/s

总计:对于分红一样大小的内部存款和储蓄器,块月大分配的速率越快,随机分配比顺序分配的快慢要快

./configure –with-mysql-includes=/usr/local/mysql/include
–with-mysql-libs=/usr/local/mysql/lib –with-mysql
里面参数:–with-mysql-includes的地址是mysql.h所在的目录,能够透过find /
-name mysql.h实行检索

    近期sysbench重要支撑
MySQL,pgsql,Oracle
那三种数据库。

互斥锁测试

互斥锁测试模拟全部线程在一仍其旧时刻并发运维

./sysbench  --num-threads=12  --test=mutex --mutex-num=1024 --mutex-locks=10000 --mutex-loops=10000 run

[root@localhost sysbench-0.4.12]# ./sysbench  --num-threads=12  --test=mutex --mutex-num=1024 --mutex-locks=10000 --mutex-loops=10000 run
sysbench 0.4.12.10:  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


Doing mutex performance test
Threads started!
Done.


General statistics:
    total time:                          0.0869s
    total number of events:              12
    total time taken by event execution: 1.0301
    response time:
         min:                                 83.86ms
         avg:                                 85.84ms
         max:                                 86.88ms
         approx.  95 percentile:              86.78ms

Threads fairness:
    events (avg/stddev):           1.0000/0.00
    execution time (avg/stddev):   0.0858/0.00

文件io测试

./sysbench –test=fileio help

文件IO的测试主要用于测试IO的载重质量。主要的测试选项为–file-test-mode。还有多少个能够关心的参数包涵–file-block-size、–file-io-mode、–file-fsync-freq
、–file-rw-ratio

--file-num=N                   创建测试文件的数量,默认128个
  --file-block-size=N          block size大小,默认16K
  --file-total-size=SIZE       所有文件的总大小,默认2G
  --file-test-mode=STRING      测试类型 {seqwr(顺序写), seqrewr(顺序读写), seqrd(顺序读), rndrd(随机读), rndwr(随机写), rndrw(随机读写)}
  --file-io-mode=STRING         I/O模式,需要系统支持默认sync[sync(同步IO),async(异步IO),mmap()]
  --file-async-backlog=N        每个线程的异步操作队列数,默认128个,需要--file-io-mode=async;
  --file-extra-flags=STRING     additional flags to use on opening files {sync,dsync,direct} []
  --file-fsync-freq=N           当请求数达到多少时执行fsync()刷新,默认100,0代表过程中不执行fsync()
  --file-fsync-all=[on|off]     执行每一个写操作后执行fsync()刷新操作,默认关闭off
  --file-fsync-end=[on|off]     测试结束执行fsync()操作,默认开启on
  --file-fsync-mode=STRING      同步刷新方法,默认fsync {fsync, fdatasync} 
  --file-merged-requests=N      合并指定数量的IO请求,0代表不合并,默认0
  --file-rw-ratio=N            读写比例,默认1.5/1

./sysbench --num-threads=12 --max-requests=10000  --test=fileio --file-total-size=3G --file-test-mode=rndrw prepare
./sysbench --num-threads=12 --max-requests=10000  --test=fileio --file-total-size=3G --file-test-mode=rndrw run
./sysbench --num-threads=12 --max-requests=10000  --test=fileio --file-total-size=3G --file-test-mode=rndrw clean

997755.com澳门葡京 18

上海教室中的第三有的的归纳内容反映了当下系统的io质量大致:38M/S

留神:借使要对照两台服务器的io质量,须要跑同一的线程。

–with-mysql-libs的地址是libmysqlclient.so所在的目录,能够经过find /
-name libmysqlclient.so进行搜寻

正文只是在linux CentOS
的 MySQL情形下安装sysbench0.4.1二

oltp测试

oltp是针对性数据库的尺度测试,比如每趟对数据库实行优化后推行基准测试来测试不一致的布署的tps。可以因此以下命令领会它的有关参数:

./sysbench –test=oltp help

--oltp-test-mode=STRING                    测试类型:simple(简单select测试),complex(事务测试),nontrx(非事务测试),sp(存储过程) ;默认complex
  --oltp-reconnect-mode=STRING             连接类型:session(每个线程到测试结束不重新连接),transaction(执行每个事务重新连接),query(每一个查询重新连接),random(随机);默认 [session]
  --oltp-sp-name=STRING                    指定执行测试的存储过程名
  --oltp-read-only=[on|off]                仅执行select测试,默认关闭
  --oltp-avoid-deadlocks=[on|off]          更新过程中忽略死锁,默认[off]
  --oltp-skip-trx=[on|off]                 语句以bigin/commit开始结尾,默认[off]
  --oltp-range-size=N                      范围查询的范围大小,默认 [100],例如begin 100 and 200
  --oltp-point-selects=N                   单个事务中select查询的数量,默认 [10]
  --oltp-use-in-statement=N                每个查询中主键查找(in 10个值)的数量,默认 [0]
  --oltp-simple-ranges=N                   单个事务中执行范围查询的数量(SELECT c  FROM sbtest WHERE id BETWEEN  N AND  M),默认[1]
  --oltp-sum-ranges=N                      单个事务中执行范围sum查询的数量,默认 [1]
  --oltp-order-ranges=N                    单个事务中执行范围order by查询的数量,默认[1]
  --oltp-distinct-ranges=N                 单个事务中执行范围distinct查询的数量,默认[1]
  --oltp-index-updates=N                   单个事务中执行索引更新的操作的数量,默认[1]
  --oltp-non-index-updates=N               单个事务中执行非索引更新操作的数量,默认[1]
  --oltp-nontrx-mode=STRING                指定单独非事务测试类型进行测试,默认select {select, update_key, update_nokey, insert, delete} [select]
  --oltp-auto-inc=[on|off]                 id列默认自增,默认[on]
  --oltp-connect-delay=N                   指定每一次重新连接延时的时长,默认1秒 [10000]
  --oltp-user-delay-min=N                  minimum time in microseconds to sleep after each request [0]
  --oltp-user-delay-max=N                  maximum time in microseconds to sleep after each request [0]
  --oltp-table-name=STRING                 指定测试的表名,默认[sbtest]
  --oltp-table-size=N                      指定表的记录大小,默认[10000]
  --oltp-dist-type=STRING                  随机数分布状态。uniform(均匀分布)、gauss(高斯分布)、special(特殊分布),默认 [special]
  --oltp-dist-iter=N                       number of iterations used for numbers generation [12]
  --oltp-dist-pct=N                        启用百分比特殊分布,默认 [1]
  --oltp-dist-res=N                        special 百分比[75]
  --oltp-point-select-mysql-handler=[on|off] Use MySQL HANDLER for point select [off]
  --oltp-point-select-all-cols=[on|off]    select查询测试时select所有列,默认[off]
  --oltp-secondary=[on|off]                索引不是主键索引而是二级索引,默认[off]
  --oltp-num-partitions=N                  指定表分区的数量,默认 [0]
  --oltp-num-tables=N                      指定测试表的数量,默认[1]
General database options:
  --db-driver=STRING  指定测试数据库类型,默认mysql
  --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]

mysql options:
  --mysql-host=[LIST,...]       MySQL server host [localhost]
  --mysql-port=N                MySQL server port [3306]
  --mysql-socket=STRING         MySQL socket
  --mysql-user=STRING           MySQL user [sbtest]
  --mysql-password=STRING       MySQL password []
  --mysql-db=STRING             MySQL database name [sbtest]
  --mysql-table-engine=STRING   storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb]
  --mysql-engine-trx=STRING     whether storage engine used is transactional or not {yes,no,auto} [auto]
  --mysql-ssl=[on|off]          use SSL connections, if available in the client library [off]
  --myisam-max-rows=N           max-rows parameter for MyISAM tables [1000000]
  --mysql-create-options=STRING additional options passed to CREATE TABLE []

oltp测试首要会有以下相关参数的测试,,别的有关参数暗中同意即可,有须求也能够自定义:

--mysql-engine-trx=STRING     指定不同的存储引擎测试。
--oltp-test-mode=STRING       测试类型:simple(简单select测试),complex(事务测试),nontrx(非事务测试),sp(存储过程) ;默认complex
--oltp-sp-name=STRING         指定存储过程进行语句测试
--oltp-table-size=N           指定表的记录大小,默认[10000]
--oltp-num-tables=N           指定测试表的数量,默认[1]

内需先创造好测试数据库sbtest。

一.事务测试,测试11个线程实践三万条请求,十个表,各样表大小100W

./sysbench --num-threads=12 --max-requests=100000  --test=oltp --mysql-user=root --mysql-password=root --oltp-test-mode=complex --mysql-db=sbtest --oltp-table-size=1000000 --oltp-num-tables=10 prepare

./sysbench --num-threads=12 --max-requests=100000  --test=oltp --mysql-user=root --mysql-password=root --oltp-test-mode=complex --mysql-db=sbtest --oltp-table-size=1000000 --oltp-num-tables=10 run

./sysbench --num-threads=12 --max-requests=100000  --test=oltp --mysql-user=root --mysql-password=root --oltp-test-mode=complex --mysql-db=sbtest --oltp-table-size=1000000 --oltp-num-tables=10 cleanup

[root@localhost sysbench-0.4.12]# ./sysbench --num-threads=12 --max-requests=100000  --test=oltp --mysql-user=root --mysql-password=root --oltp-test-mode=complex --mysql-db=sbtest --oltp-table-size=1000000 --oltp-num-tables=10 run
sysbench 0.4.12.10:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 12
Random number generator seed is 0 and will be ignored


Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 100000
Using 10 test tables
Threads started!
Done.

OLTP test statistics:
    queries performed:
        read:                            1400910
        write:                           500325
        other:                           200130
        total:                           2101365
    transactions:                        100065 (791.94 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 1901235 (15046.89 per sec.)
    other operations:                    200130 (1583.88 per sec.)

General statistics:
    total time:                          126.3540s
    total number of events:              100065
    total time taken by event execution: 1513.9202
    response time:
         min:                                  5.82ms
         avg:                                 15.13ms
         max:                               2352.66ms
         approx.  95 percentile:              18.00ms

Threads fairness:
    events (avg/stddev):           8338.7500/207.

告知:试行业前测试开支1二陆S,TPS:791/S,奥迪Q5Q:15046/S,九伍%的伸手开销18皮秒

政工测试,每种职业包含如下语句:

  Point queries:
SELECT c FROM sbtest WHERE id= N
  Range queries:
SELECT c FROM sbtest WHERE id BETWEEN  N AND  M
  Range SUM() queries:
SELECT SUM(K) FROM sbtest WHERE id BETWEEN  N and  M
  Range ORDER BY queries:
SELECT c FROM sbtest WHERE id between  N and  M ORDER BY c
  Range DISTINCT queries:
SELECT DISTINCT c FROM sbtest WHERE id BETWEEN  N and  M ORDER BY
c
  UPDATEs on index column:
UPDATE sbtest SET k=k+1 WHERE id= N
  UPDATEs on non-index column:
UPDATE sbtest SET c= N WHERE id= M
  DELETE queries:
DELETE FROM sbtest WHERE id= N
  INSERT queries:
INSERT INTO sbtest VALUES ( ...

 非事务测试,推行语句如下

  Point queries:
SELECT pad FROM sbtest WHERE id= N
  UPDATEs on index column:
UPDATE sbtest SET k=k+1 WHERE id= N
  UPDATEs on non-index column:
UPDATE sbtest SET c= N WHERE id= M
  DELETE queries:
DELETE FROM sbtest WHERE id= N
  The generated row IDs are unique over each test run, so no row
is deleted twice.
  INSERT queries:
INSERT INTO sbtest (k, c, pad) VALUES( N ,  M ,  S )

互斥锁测试

互斥锁测试模拟全数线程在同等时刻并发运维

./sysbench  --num-threads=12  --test=mutex --mutex-num=1024 --mutex-locks=10000 --mutex-loops=10000 run

[[email protected] sysbench-0.4.12]# ./sysbench  --num-threads=12  --test=mutex --mutex-num=1024 --mutex-locks=10000 --mutex-loops=10000 run
sysbench 0.4.12.10:  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


Doing mutex performance test
Threads started!
Done.


General statistics:
    total time:                          0.0869s
    total number of events:              12
    total time taken by event execution: 1.0301
    response time:
         min:                                 83.86ms
         avg:                                 85.84ms
         max:                                 86.88ms
         approx.  95 percentile:              86.78ms

Threads fairness:
    events (avg/stddev):           1.0000/0.00
    execution time (avg/stddev):   0.0858/0.00

铺排达成以往就能够一贯make && make install。

安装

总结

 sysbench是采用最广泛的尺度压测工具,功效也很齐全报告也丰盛的详尽。

 

 

 

备注:

    作者:pursuer.chen

    博客:http://www.cnblogs.com/chenmh

本站点所有随笔都是原创,欢迎大家转载;但转载时必须注明文章来源,且在文章开头明显处给明链接。

《欢迎交流讨论》

oltp测试

oltp是指向数据库的规范测试,举例每一趟对数据库举办优化后实施尺度测试来测试不一致的配备的tps。能够因此以下命令通晓它的关于参数:

./sysbench –test=oltp help

--oltp-test-mode=STRING                    测试类型:simple(简单select测试),complex(事务测试),nontrx(非事务测试),sp(存储过程) ;默认complex
  --oltp-reconnect-mode=STRING             连接类型:session(每个线程到测试结束不重新连接),transaction(执行每个事务重新连接),query(每一个查询重新连接),random(随机);默认 [session]
  --oltp-sp-name=STRING                    指定执行测试的存储过程名
  --oltp-read-only=[on|off]                仅执行select测试,默认关闭
  --oltp-avoid-deadlocks=[on|off]          更新过程中忽略死锁,默认[off]
  --oltp-skip-trx=[on|off]                 语句以bigin/commit开始结尾,默认[off]
  --oltp-range-size=N                      范围查询的范围大小,默认 [100],例如begin 100 and 200
  --oltp-point-selects=N                   单个事务中select查询的数量,默认 [10]
  --oltp-use-in-statement=N                每个查询中主键查找(in 10个值)的数量,默认 [0]
  --oltp-simple-ranges=N                   单个事务中执行范围查询的数量(SELECT c  FROM sbtest WHERE id BETWEEN  N AND  M),默认[1]
  --oltp-sum-ranges=N                      单个事务中执行范围sum查询的数量,默认 [1]
  --oltp-order-ranges=N                    单个事务中执行范围order by查询的数量,默认[1]
  --oltp-distinct-ranges=N                 单个事务中执行范围distinct查询的数量,默认[1]
  --oltp-index-updates=N                   单个事务中执行索引更新的操作的数量,默认[1]
  --oltp-non-index-updates=N               单个事务中执行非索引更新操作的数量,默认[1]
  --oltp-nontrx-mode=STRING                指定单独非事务测试类型进行测试,默认select {select, update_key, update_nokey, insert, delete} [select]
  --oltp-auto-inc=[on|off]                 id列默认自增,默认[on]
  --oltp-connect-delay=N                   指定每一次重新连接延时的时长,默认1秒 [10000]
  --oltp-user-delay-min=N                  minimum time in microseconds to sleep after each request [0]
  --oltp-user-delay-max=N                  maximum time in microseconds to sleep after each request [0]
  --oltp-table-name=STRING                 指定测试的表名,默认[sbtest]
  --oltp-table-size=N                      指定表的记录大小,默认[10000]
  --oltp-dist-type=STRING                  随机数分布状态。uniform(均匀分布)、gauss(高斯分布)、special(特殊分布),默认 [special]
  --oltp-dist-iter=N                       number of iterations used for numbers generation [12]
  --oltp-dist-pct=N                        启用百分比特殊分布,默认 [1]
  --oltp-dist-res=N                        special 百分比[75]
  --oltp-point-select-mysql-handler=[on|off] Use MySQL HANDLER for point select [off]
  --oltp-point-select-all-cols=[on|off]    select查询测试时select所有列,默认[off]
  --oltp-secondary=[on|off]                索引不是主键索引而是二级索引,默认[off]
  --oltp-num-partitions=N                  指定表分区的数量,默认 [0]
  --oltp-num-tables=N                      指定测试表的数量,默认[1]
General database options:
  --db-driver=STRING  指定测试数据库类型,默认mysql
  --db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]

mysql options:
  --mysql-host=[LIST,...]       MySQL server host [localhost]
  --mysql-port=N                MySQL server port [3306]
  --mysql-socket=STRING         MySQL socket
  --mysql-user=STRING           MySQL user [sbtest]
  --mysql-password=STRING       MySQL password []
  --mysql-db=STRING             MySQL database name [sbtest]
  --mysql-table-engine=STRING   storage engine to use for the test table {myisam,innodb,bdb,heap,ndbcluster,federated} [innodb]
  --mysql-engine-trx=STRING     whether storage engine used is transactional or not {yes,no,auto} [auto]
  --mysql-ssl=[on|off]          use SSL connections, if available in the client library [off]
  --myisam-max-rows=N           max-rows parameter for MyISAM tables [1000000]
  --mysql-create-options=STRING additional options passed to CREATE TABLE []

oltp测试重要会有以下相关参数的测试,,其它相关参数暗中同意就可以,有需要也足以自定义:

--mysql-engine-trx=STRING     指定不同的存储引擎测试。
--oltp-test-mode=STRING       测试类型:simple(简单select测试),complex(事务测试),nontrx(非事务测试),sp(存储过程) ;默认complex
--oltp-sp-name=STRING         指定存储过程进行语句测试
--oltp-table-size=N           指定表的记录大小,默认[10000]
--oltp-num-tables=N           指定测试表的数量,默认[1]

供给先创建好测试数据库sbtest。

一.事情测试,测试10个线程推行1万条请求,13个表,各个表大小十0W

./sysbench --num-threads=12 --max-requests=100000  --test=oltp --mysql-user=root --mysql-password=root --oltp-test-mode=complex --mysql-db=sbtest --oltp-table-size=1000000 --oltp-num-tables=10 prepare

./sysbench --num-threads=12 --max-requests=100000  --test=oltp --mysql-user=root --mysql-password=root --oltp-test-mode=complex --mysql-db=sbtest --oltp-table-size=1000000 --oltp-num-tables=10 run

./sysbench --num-threads=12 --max-requests=100000  --test=oltp --mysql-user=root --mysql-password=root --oltp-test-mode=complex --mysql-db=sbtest --oltp-table-size=1000000 --oltp-num-tables=10 cleanup

[[email protected] sysbench-0.4.12]# ./sysbench --num-threads=12 --max-requests=100000  --test=oltp --mysql-user=root --mysql-password=root --oltp-test-mode=complex --mysql-db=sbtest --oltp-table-size=1000000 --oltp-num-tables=10 run
sysbench 0.4.12.10:  multi-threaded system evaluation benchmark

No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 12
Random number generator seed is 0 and will be ignored


Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 100000
Using 10 test tables
Threads started!
Done.

OLTP test statistics:
    queries performed:
        read:                            1400910
        write:                           500325
        other:                           200130
        total:                           2101365
    transactions:                        100065 (791.94 per sec.)
    deadlocks:                           0      (0.00 per sec.)
    read/write requests:                 1901235 (15046.89 per sec.)
    other operations:                    200130 (1583.88 per sec.)

General statistics:
    total time:                          126.3540s
    total number of events:              100065
    total time taken by event execution: 1513.9202
    response time:
         min:                                  5.82ms
         avg:                                 15.13ms
         max:                               2352.66ms
         approx.  95 percentile:              18.00ms

Threads fairness:
    events (avg/stddev):           8338.7500/207.

报告:推行业前测试花费1贰陆S,TPS:791/S,HummerH二Q:15046/S,9五%的呼吁费用18飞秒

政工测试,各种专门的学业包罗如下语句:

  Point queries:
SELECT c FROM sbtest WHERE id= N
  Range queries:
SELECT c FROM sbtest WHERE id BETWEEN  N AND  M
  Range SUM() queries:
SELECT SUM(K) FROM sbtest WHERE id BETWEEN  N and  M
  Range ORDER BY queries:
SELECT c FROM sbtest WHERE id between  N and  M ORDER BY c
  Range DISTINCT queries:
SELECT DISTINCT c FROM sbtest WHERE id BETWEEN  N and  M ORDER BY
c
  UPDATEs on index column:
UPDATE sbtest SET k=k+1 WHERE id= N
  UPDATEs on non-index column:
UPDATE sbtest SET c= N WHERE id= M
  DELETE queries:
DELETE FROM sbtest WHERE id= N
  INSERT queries:
INSERT INTO sbtest VALUES ( ...

 非事务测试,推行语句如下

  Point queries:
SELECT pad FROM sbtest WHERE id= N
  UPDATEs on index column:
UPDATE sbtest SET k=k+1 WHERE id= N
  UPDATEs on non-index column:
UPDATE sbtest SET c= N WHERE id= M
  DELETE queries:
DELETE FROM sbtest WHERE id= N
  The generated row IDs are unique over each test run, so no row
is deleted twice.
  INSERT queries:
INSERT INTO sbtest (k, c, pad) VALUES( N ,  M ,  S )

安装进程中,错误总计:

在设置sysbench以前,系统必须先要安装好MySQL。本文中MySQL是系统自带的,若是系统绝非安装MySQL,能够使用如下命令安装:

总结

 sysbench是运用最常见的规范压测工具,功用也很齐全报告也丰硕的详尽。

 

 

 

备注:

    作者:pursuer.chen

    博客:http://www.cnblogs.com/chenmh

本站点所有随笔都是原创,欢迎大家转载;但转载时必须注明文章来源,且在文章开头明显处给明链接。

《欢迎交流讨论》

压力测试,sysbench 介绍
sysbench是3个模块化、跨平台、四线程基准测试工具,重要用来测试不一样系统参数下的数据库负载意况,本文…

荒谬提示一:

    Yum install mysql*

[root@localhost sysbench-0.4.12-1.1]#
./autogen.sh
automake 1.10.x (aclocal) wasn’t found, exiting
通过yum安装automake

1、软件包下载

[root@localhost sysbench-0.4.12-1.1]# yum -y install automake
荒唐提醒二:

      

[root@localhost sysbench-0.4.12-1.1]#
./autogen.sh
libtoolize 1.4+ wasn’t found, exiting
通过yun安装libtool即可

2、解压

[root@localhost sysbench-0.4.12-1.1]# yum -y install libtool
在运行sysbench的时候,遇到:error while loading shared libraries:
libmysqlclient.so.18: cannot open shared object file: No such file or
directory

   Tar –zxvf sysbench-0.4.12.tar.gz

那评释sysbench不能够找到mysql的库文件,那很也许是条件变量LD_LIBRARY_PATH未有设置,设置后就能够消除该难题:
执行bash代码:export LD_LIBRARY_PATH=/usr/local/mysql/lib
能够权且的改换境遇变量,终端断开之后,就能够丢失
也能够在/etc/profile中增加export
LD_LIBRARY_PATH=/usr/local/mysql/lib,永世的改换,那样修改须要重启机器就能够恒久生效。

3、安装

安装达成以往,开头做标准测试。

  进入sysbench-0.4.12

二、sysbench使用

  Cd sysbench-0.4.12

sysbench常用参数详解:

在标准安装此前务供给运维autogen.sh文件,不然会产出libtool不能够实施等连锁错误。实行如下命令:

[root@localhost src]# sysbench
General options: #通用选项
–num-threads=N number of threads to use [1]#线程数,默认是1
–max-requests=N limit for total number of requests
[10000]#呼吁限制,私下认可是10000,0意味着不限定
–max-time=N limit for total execution time in seconds
[0]#最大实施时间,暗中认可是0,表示不限定
–forced-shutdown=STRING amount of time to wait after –max-time before
forcing shutdown [off]#过期强制中止,暗中认可关闭
–thread-stack-size=SIZE size of stack per thread
[64K]#各类线程的仓库大小,默许是64K
–tx-rate=N target transaction rate (tps)
[0]#品尝像数据库发送的事体数tps
–report-interval=N periodically report intermediate statistics with a
specified interval in seconds. 0 disables intermediate reports
[0]#意味着N秒输出三回测试进程报告,0象征关闭测试进程报告输出,仅输出最后的告知结果,暗许值为0。
–report-checkpoints=[LIST,…]dump full statistics and reset all
counters at specified points in time. The argument is a list of
comma-separated values representing the amount of time in seconds
elapsed from start of test when report checkpoint(s) must be performed.
Report checkpoints are off by default. []
–test=STRING test to run #测试的花色
–debug=[on|off] print more debugging info
[off]#debug形式输出,暗中认可值为off。
–validate=[on|off] perform validation checks where possible
[off]#在恐怕的情况下施行验证检查,默许为off。
–help=[on|off] print help and exit#输出help信息,默认为off。
–version=[on|off] print version and exit
[off]#输出版本音讯,默以为off。
–rand-init=[on|off] initialize random number generator
[off]#初步化迭代器
–rand-type=STRING random numbers distribution
{uniform,gaussian,special,pareto} [special]

 chmod  +x autogen.sh

表示随机类型的方式,共有四种格局:uniform(固定),gaussian(高斯)�,special(特定),pareto(帕雷特),暗中同意值为:special。

–rand-spec-iter=N number of iterations used for numbers generation
[12]#
–rand-spec-pct=N percentage of values to be treated as ‘special’ (for
special distribution) [1]
–rand-spec-res=N percentage of ‘special’ values to use (for special
distribution) [75]
–rand-seed=N seed for random number generator, ignored when 0 [0]
–rand-pareto-h=N parameter h for pareto distibution [0.2]
sysbench基准测试cpu,先查看帮忙文书档案

[root@localhost db]# sysbench –test=cpu help
sysbench 0.5: multi-threaded system evaluation benchmark

cpu options:
–cpu-max-prime=N upper limit for primes generator
[10000]#素数生成上限,私下认可是一千0
sysbench对CPU的本性测试正是经过素数相加的测试。

[root@localhost db]# sysbench –num-threads=10 –max-requests=1000
–test=cpu –cpu-max-prime=20000 run
#12个线程,实行1000个请求,每一个请求加到两千0
推行结果:

[root@localhost db]# sysbench –num-threads=10 –max-requests=1000
–test=cpu –cpu-max-prime=20000 run
sysbench 0.5: multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 10 #线程数
Random number generator seed is 0 and will be ignored
Primer numbers limit: 20000 #素数生成上限
Threads started!

General statistics:
total time: 3.9331s #总耗时
total number of events: 1000 #作业总的数量
total time taken by event execution: 39.1176s #事件施行所消费的总时间
response time: #响应时间
min: 16.69ms #最小
avg: 39.12ms #平均
max: 76.07ms #最大
approx. 95 percentile: 51.44ms #95%上述的响应时间

Threads fairness:
events (avg/stddev): 100.0000/0.00
execution time (avg/stddev): 3.9118/0.01
cpu品质测试:计算范围内素数相加时间越短越好

sysbench基准测试文件io,先查看扶助文档

[root@localhost src]# sysbench –test=fileio help #查阅扶助
sysbench 0.5: multi-threaded system evaluation benchmark
#八线程系统评测基准
fileio options:
–file-num=N number of files to create [128]
#创设的文本数量,暗中认可是128
–file-block-size=N block size to use in all IO operations
[16384]#测试文件块的大大小小,暗中认可是163八4bite
–file-total-size=SIZE total size of files to create
[2G]#始建的文件的总大小,私下认可是二G
–file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr,
rndrw}#读写形式
seqwr, 顺序写 seqrewr, 顺序读写 seqrd, 顺序读 rndrd, 随机读 rndwr,
随机写 rndrw,随机读写
–file-io-mode=STRING file operations mode {sync,async,mmap} [sync]#
文件操作情势,同步,异步
–file-extra-flags=STRING additional flags to use on opening files
{sync,dsync,direct} []#选用额外的注脚来开垦文件,默以为空
–file-fsync-freq=N do fsync() after this number of requests (0 – don’t
use fsync()) [100]#试行fsync的频率,0代表不采用fsync,默许是100
fsync:同步内部存款和储蓄器中的数码到硬盘
–file-fsync-all=[on|off] do fsync() after each write operation
[off]#每实行完一个操作就试行一回fsync,暗中认可关闭
–file-fsync-end=[on|off] do fsync() at the end of test
[on]#在测试甘休的时候才执行 fsync
–file-fsync-mode=STRING which method to use for synchronization {fsync,
fdatasync} [fsync]#选择哪一类方法来一同,fsync恐怕fdatasync
–file-merged-requests=N merge at most this number of IO requests if
possible (0 – don’t merge)
[0]#比方得以统1最多的io请求数,0不合并,暗中同意是0
–file-rw-ratio=N reads/writes ratio for combined test
[1.5]#测试时候的读写比例私下认可是一.5
文件io的测试步骤是:希图测试文件,运维测试文件,删除测试文件

通过sysbench生成测试文件prepare:

[root@localhost sysbench_test]# sysbench –num-threads=12
–max-requests=10000 –test=fileio –file-total-size=10G
–file-test-mode=rndrw prepare
运行run

[root@localhost sysbench_test]# sysbench –num-threads=12
–max-requests=10000 –test=fileio –file-total-size=10G
–file-test-mode=rndrw run
去除测试文件

[root@localhost sysbench_test]# sysbench –num-threads=12
–max-requests=10000 –test=fileio –file-total-size=10G
–file-test-mode=rndrw cleanup
结果分析

[root@localhost sysbench_test]# sysbench –num-threads=12
–max-requests=10000 –test=fileio –file-total-size=10G
–file-test-mode=rndrw 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
Extra file open flags: 0
128 files, 80Mb each
10Gb total file size #文本的总大小
Block size 16Kb
Number of IO requests: 10000
Read/Write ratio for combined random IO test: 1.50 #io读写比例
Periodic FSYNC enabled, calling fsync() each 100 requests.
#每917个请求实行fsync()
Calling fsync() at the end of test, Enabled.
#测试完了的时候实践三次fsync()
Using synchronous I/O mode
Doing random r/w test

Threads started!

Operations performed:
5999 reads,
4001 writes, 12800 Other = 22800 Total
Read 93.734Mb
Written 62.516Mb

Total transferred
156.25Mb (288.61Mb/sec)#吞吐量
18471.19 Requests/sec executed#每秒请求数

General statistics:
total time: 0.5414s#时间
total number of events: 10000#时间数额
total time taken by event execution: 3.9134s#实施时间的日子
response time:
min: 0.00ms#最短
avg: 0.39ms#平均
max: 29.75ms#最长
approx. 95 percentile: 1.68ms #95%以上事件响应事件
Threads fairness:
events (avg/stddev): 833.3333/70.29
execution time (avg/stddev): 0.3261/0.03
io品质目标有:每分钟请求数、吞吐量、九伍%之上事件响应时间。不一样景观下io
tps越大越好

sysbench基准测试oltp,0.5版本之后oltp的参数没找到,在网络找了壹份参数详解过来

–oltp-test-mode=STGL450ING
测试项目:simple(轻便select测试),complex(事务测试),nontrx(非事务测试),sp(存款和储蓄进度)
;暗中同意complex
–oltp-reconnect-mode=STHummerH二ING
连接类型:session(每一个线程到测试甘休不另行连接),transaction(推行各类事情重新连接),query(每3个查询重新连接),random(随机);暗许
[session]
–oltp-sp-name=STSportageING 钦点实施测试的仓库储存进程名
–oltp-read-only=[on|off] 仅推行select测试,暗中同意关闭
–oltp-avoid-deadlocks=[on|off] 更新进程中忽略死锁,暗中认可[off]
–oltp-skip-trx=[on|off] 语句以bigin/commit伊始终极,默许[off]
–oltp-range-size=N 范围查询的限制大小,暗中认可 [100],例如begin 100 and
200
–oltp-point-selects=N 单个事务中select查询的数据,默许 [10]
–oltp-use-in-statement=N 每种查询中主键查找(in 十个值)的多少,私下认可
[0]
–oltp-simple-ranges=N 单个事务中实施范围查询的数额(SELECT c FROM sbtest
WHERE id BETWEEN N AND M),暗许[1]
–oltp-sum-ranges=N 单个事务中施行范围sum查询的数码,暗中同意 [1]
–oltp-order-ranges=N 单个事务中实施范围order by查询的数量,私下认可[1]
–oltp-distinct-ranges=N
单个事务中实施范围distinct查询的数据,私下认可[1]
–oltp-index-updates=N 单个事务中进行索引更新的操作的多寡,暗中认可[1]
–oltp-non-index-updates=N
单个事务中实践非索引更新操作的多少,暗中同意[1]
–oltp-nontrx-mode=ST中华VING 内定单独非事务测试项目实行测试,默许select
{select, update_key, update_nokey, insert, delete} [select]
–oltp-auto-inc=[on|off] id列私下认可自增,暗许[on]
–oltp-connect-delay=N 内定每3次重复连接延时的时间长度,暗许1秒 [10000]
–oltp-user-delay-min=N minimum time in microseconds to sleep after each
request [0]
–oltp-user-delay-max=N maximum time in microseconds to sleep after each
request [0]
–oltp-table-name=STHummerH二ING 钦命测试的表名,暗中认可[sbtest]
–oltp-table-size=N 钦赐表的记录大小,暗许[10000]
–oltp-dist-type=ST福特ExplorerING
随机数分布景况。uniform(均匀分布)、gauss(高斯遍及)、special(特殊布满),默许
[special]
–oltp-dist-iter=N number of iterations used for numbers generation
[12]
–oltp-dist-pct=N 启用百分比破例分布,暗中同意 [1]
–oltp-dist-res=N special 百分比[75]
–oltp-point-select-mysql-handler=[on|off] Use MySQL HANDLER for point
select [off]
–oltp-point-select-all-cols=[on|off]
select查询测试时select全数列,暗中认可[off]
–oltp-secondary=[on|off] 索引不是主键索引而是二级索引,私下认可[off]
–oltp-num-partitions=N 钦点表分区的数码,私下认可 [0]
–oltp-num-tables=N 钦赐测试表的数据,暗中认可[1]
General database options:
–db-driver=STHummerH贰ING 内定测试数据库类型,私下认可mysql
–db-ps-mode=STRING prepared statements usage mode {auto, disable}
[auto]

mysql options:
–mysql-host=[LIST,…] MySQL server host [localhost]
–mysql-port=N MySQL server port [3306]
–mysql-socket=STRING MySQL socket
–mysql-user=STRING MySQL user [sbtest]
–mysql-password=STRING MySQL password []
–mysql-db=STRING MySQL database name [sbtest]
–mysql-table-engine=STRING storage engine to use for the test table
{myisam,innodb,bdb,heap,ndbcluster,federated} [innodb]
–mysql-engine-trx=STRING whether storage engine used is transactional
or not {yes,no,auto} [auto]
–mysql-ssl=[on|off] use SSL connections, if available in the client
library [off]
–myisam-max-rows=N max-rows parameter for MyISAM tables [1000000]
–mysql-create-options=STRING additional options passed to CREATE TABLE
[]
在0.伍本子的mysql测试的时候,用到oltp.lua脚本,在解压的安装包中能够找到

[root@localhost db]# pwd
/usr/local/src/sysbench-0.4.12-1.1/sysbench/tests/db
[root@localhost db]# ls
common.lua insert.lua Makefile.am oltp.lua parallel_prepare.lua
select_random_points.lua update_index.lua
delete.lua Makefile Makefile.in oltp_simple.lua select.lua
select_random_ranges.lua update_non_index.lua
操作步骤:图谋数据,运营测试,删除数据

[root@localhost db]# sysbench –test=./oltp.lua
–oltp-table-size=2000000 –mysql-host=localhost –mysql-user=root
–mysql-password=111111 prepare
[root@localhost db]# sysbench –test=./oltp.lua
–oltp-table-size=2000000 –mysql-host=localhost –mysql-user=root
–mysql-password=111111 run
[root@localhost db]# sysbench –test=./oltp.lua
–oltp-table-size=2000000 –mysql-host=localhost –mysql-user=root
–mysql-password=111111 cleanup
结果分析:

Running the test with following options:
Number of threads: 1
Random number generator seed is 0 and will be ignored

Threads started!

OLTP test statistics:
queries performed:
read: 140000 #读总数
write: 40000 #写总数
other: 20000 #其余总的数量(除select insert delete
update之外的,举例commit)
total: 200000 #全部总和
transactions: 10000 (137.75 per sec.) #总事务数(每秒事务数)
deadlocks: 0 (0.00 per sec.)#产生死锁总的数量
read/write requests: 180000 (2479.53 per sec.)#读写总的数量(每秒读此书)
other operations: 20000 (275.50 per
sec.)#别的操作次数(每秒其余操作次数)

General statistics:
total time: 72.5943s #总耗费时间间
total number of events: 10000 #总事务数
total time taken by event execution: 72.5352s
#具备工作耗费时间相加(不思索并行因素)
response time:#一呼百应时间
min: 3.16ms #最短
avg: 7.25ms#平均
max: 1103.70ms#最长
approx. 95 percentile: 13.28ms#玖五%的响应时间

Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 72.5352/0.00
oltp测试结果要求参考的数目有:
response time avg:
平均响应时间。(前面包车型客车玖5%的高低能够经过–percentile=玖捌的主意去退换)
transactions: 正确的乃是那一项前边的TPS
。但如若采纳了-oltp-skip-trx=on,这项事务数恒为0,要求用total number of
events 去除以总时间,得到tps(其实还是能够分为读tps和写tps)
read/write requests: 用它除以总时间,得到吞吐量QPS

sysbench基本测试内部存款和储蓄器

内部存款和储蓄器分配测试,首如若针对性区别的块大小进行内部存款和储蓄器的连天读写可能私行读写测试

内部存款和储蓄器测试参数详解:

[root@localhost db]# 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]#内部存款和储蓄器块大小,私下认可是一k
–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]
–memory-oper=STRING type of memory operations {read, write, none}
[write]
–memory-access-mode=STRING memory access mode {seq,rnd} [seq]
#测试形式,随机读依然各类
运作脚本

sysbench –num-threads=12 –max-requests=10000 –test=memory
–memory-block-size=8K –memory-total-size=100G –memory-access-mode=seq
run #顺序读 8k
sysbench –num-threads=12 –max-requests=10000 –test=memory
–memory-block-size=8K –memory-total-size=100G –memory-access-mode=rnd
run #随机读 8k
内部存款和储蓄器:以不相同块大小传输一定数量的多寡吞吐量大小越大越好

三、衡量结果正式:
cpu品质测试:找范围内最大素数时间越短越好
线程调治:线程并发实施,循环响应时域信号量开销的小运越少越好
互斥锁:并发线程同时申请互斥锁循环一定次数开支的日子越少越好
内部存款和储蓄器:以区别块大小传输一定数量的数量吞吐量大小越大越好
IO:差别景色下IO TPS越大越好
小说首发网站:http://www.17codes.com/archives/58?from=jianshu

 ./autogen.sh

上边起始正儿8经安装安装

  因为此地mysql是标准的智能包安装(rpm),sysbench的安装就相比较轻便

./configure

 Make

 Make install
若mysql是源码安装的话,编写翻译时按如下格局张开

/configure –with-mysql-includes=/usr/local/mysql/include
–with-mysql-libs=/usr/local/mysql/lib && make && make install

此地/usr/local/mysql/include是mysql的装置路线

    此外,如若想要让 sysbench 补助 pgsql/oracle
的话,就必要在编写翻译的时候增加参数

    –with-pgsql

    或者

    –with-oracle

    那二个参数暗中同意是关闭的,唯有 MySQL 是私下认可辅助的
贰、编写翻译成功以往,将在起来测试各类质量了,测试的章程官方网址网址上也提到一些,但关系到
OLTP 测试的一对却不够标准。在此间本人大概提一下:

    一、cpu品质测试 

    sysbench –test=cpu –cpu-max-prime=20000 run

    cpu测试首如果进展素数的加法运算,在上头的例子中,钦点了最大的素数为
两千0,本身能够依靠机器cpu的性质来适合调节数值。 

 贰、线程测试 

    sysbench –test=threads –num-threads=64 –thread-yields=100
–thread-locks=2 run 

3、磁盘IO品质测试 

    sysbench –test=fileio –num-threads=16 –file-total-size=3G
–file-test-mode=rndrw preparesysbench –test=fileio –num-threads=16
–file-total-size=3G –file-test-mode=rndrw runsysbench –test=fileio
–num-threads=16 –file-total-size=3G –file-test-mode=rndrw cleanup

       
上述参数钦赐了最大创设17个线程,创制的公文化总同盟大小为三G,文件读写格局为随机读。 

 四、内部存款和储蓄器测试 

    sysbench –test=memory –memory-block-size=8k –memory-total-size=4G
run

    上述参数内定了本次测试整个经过是在内部存款和储蓄器中传输 四G 的数据量,每种 block
大小为 8K。

5、OLTP测试

    sysbench –test=oltp –mysql-table-engine=myisam
–oltp-table-size=1000000 –mysql-socket=/tmp/mysql.sock
–mysql-user=test –mysql-host=localhost –mysql-password=test prepare

    上述参数钦定了这一次测试的表存储引擎类型为
myisam,这里须求专注的是,官网上的参数有1处有误,即
–mysql-table-engine,官方网站上写的是
–mysql-table-type,那么些应该是绝非立即更新导致的。其余,钦定了表最大记录数为
1000000,别的参数就很好了然了,主固然点名登陆形式。测试 OLTP
时,能够友善先创设数据库 sbtest,只怕自身用参数 –mysql-db
来内定别的数据库。–mysql-table-engine 还足以内定为 innodb 等 MySQL
帮助的表存款和储蓄引擎类型

997755.com澳门葡京 19

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

*
*
Website