Sysbench压力测试工具简介和使用(一)

sysbench压力测试工具安装和参数介绍

一、sysbench压力测试工具简介:

sysbench是一个开源的、模块化的、跨平台的多线程性能测试工具,可以用来进行CPU、内存、磁盘I/O、线程、数据库的性能测试。目前支持的数据库有MySQL、Oracle和PostgreSQL。以下操作都将以支持MySQL数据库为例进行。

1.      sysbench工具安装:

默认支持<span "="">MySQL,如果需要测试<span "="">Oracle/PostgreSQL,则在<span "="">configure时需要加上<span "="">–with-oracle或者<span "="">–with-pgsql参数<span "="">.

<span "="">

1.1          安装环境

<span "="">CentOS release 6.3 (Final)

<span "="">MySQL 5.6.13

<span "="">MySQL_HOME=/usr/local/mysql/

<span "="">Sysbench 0.4.12

1.2          下载安装包

# wget http://sourceforge.net/projects/sysbench/sysbench-0.4.12.tar.gz

注释:现在由github托管 地址http://github.com/akopytov/sysbench

1.3 编译安装

#  tar –zxvf sysbench-0.4.12.tar.gz

进入解压缩包<span "="">sysbench-0.4.12,并执行脚本<span "="">autogen.sh

# cd sysbench-0.4.12

# ./autogen.sh

关键的三步:configure && make && make install

首先是./configure命令,sysbench默认是支持MySQL的benchmarking的,如果不加任何选项则要求保证MySQL的安装路径都是默认的标准路径,headfile位于/usr/include目录下,libraries位于/usr/lib/目录下。因为我的MySQL是源码编译安装的,安装路径是放在/usr/local/mysql下,所以这里要添加相应的选项命令:

# ./configure --prefix=/usr/local/sysbench --with-mysql=/usr/local/mysql \

--with-mysql-includes=/usr/local/mysql/include/mysql/ \

--with-mysql-libs=/usr/local/mysql/lib/mysql/

注意:这里在编译时要将路径写到最后的include/mysql及lib/mysql,如下所示:

–with-mysql-includes=/usr/local/mysql/include/mysql/

--with-mysql-libs=/usr/local/mysql/lib/mysql/

因为网上好多资料都没有提到这一层,在编译时总是编译不过去,这里浪费了好多精力。

接下来执行如下命令:

# make && make install

1.4           yum安装

如果觉得源码安装麻烦,也可以采用yum安装,操作如下:

# yum install -y sysbench

2.      sysbench支持的功能参数

首先,看看sysbench都支持哪些功能参数:

[[email protected] sysbench]# sysbench --help

Usage:

sysbench [general-options]... --test= [test-options]... command

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]

--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

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= help‘ for a list of options for each test.

Sysbench的测试主要包括以下几个方面:

1、磁盘io性能

2、cpu性能

3、内存分配及传输速度

4、POSIX线程性能

5、调度程序性能

6、数据库性能(OLTP基准测试).

2.1 测试fileio命令帮助:

[[email protected] ~]# sysbench --test=fileio help

sysbench 0.4.12:  multi-threaded system evaluation benchmark

fileio options:

--file-num=N                  number of files to create [128]

--file-block-size=N           block size to use in all IO operations [16384]

--file-total-size=SIZE        total size of files to create [2G]

--file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}

--file-io-mode=STRING         file operations mode {sync,async,fastmmap,slowmmap} [sync]

--file-async-backlog=N        number of asynchronous operatons to queue per thread [128]

--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]

--file-fsync-all=[on|off]     do fsync() after each write operation [off]

--file-fsync-end=[on|off]     do fsync() at the end of test [on]

--file-fsync-mode=STRING      which method to use for synchronization {fsync, fdatasync} [fsync]

--file-merged-requests=N      merge at most this number of IO requests if possible (0 - don‘t merge) [0]

--file-rw-ratio=N             reads/writes ratio for combined test [1.5]

参数详解:

--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。

2.2 测试cpu命令帮助:

[[email protected] ~]# sysbench --test=cpu help

sysbench 0.4.12:  multi-threaded system evaluation benchmark

cpu options:

--cpu-max-prime=N      upper limit for primes generator [10000]

 参数详解:

  --cpu-max-prime=N      用来选项指定最大的素数,具体参数可以根据CPU的性能来设置,默认为10000

2.3 测试memory命令帮助:

[[email protected] ~]# sysbench  --test=memory help

sysbench 0.4.12:  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]

--memory-oper=STRING        type of memory operations {read, write, none} [write]

--memory-access-mode=STRING memory access mode {seq,rnd} [seq]

参数详解:

--memory-block-size=SIZE      测试内存块的大小,默认为1K

--memory-total-size=SIZE       数据传输的总大小,默认为100G

--memory-scope=STRING       内存访问的范围,包括全局和本地范围,默认为global

--memory-hugetlb=[on|off]     是否从HugeTLB池分配内存的开关,默认为off

--memory-oper=STRING        内存操作的类型,包括read, write, none,默认为write

--memory-access-mode=STRING 内存访问模式,包括seq,rnd两种模式,默认为seq

2.4 测试threads命令帮助:

[[email protected] ~]# sysbench  --test=threads help

sysbench 0.4.12:  multi-threaded system evaluation benchmark

threads options:

--thread-yields=N      number of yields to do per request [1000]

--thread-locks=N       number of locks per thread [8]

参数详解: 

--thread-yields=N      指定每个请求的压力,默认为1000

--thread-locks=N       指定每个线程的锁数量,默认为8

2.5 测试mutex命令帮助:

[[email protected] ~]# sysbench  --test=mutex help

sysbench 0.4.12:  multi-threaded system evaluation benchmark

mutex options:

--mutex-num=N        total size of mutex array [4096]

--mutex-locks=N      number of mutex locks to do per thread [50000]

--mutex-loops=N      number of empty loops to do inside mutex lock [10000]

参数详解

--mutex-num=N    数组互斥的总大小。默认是4096

--mutex-locks=N    每个线程互斥锁的数量。默认是50000

--mutex-loops=N    内部互斥锁的空循环数量。默认是10000

2.6 测试oltp命令帮助:

[[email protected] ~]# sysbench --test=oltp help

sysbench 0.4.12:  multi-threaded system evaluation benchmark

oltp options:

--oltp-test-mode=STRING         test type to use {simple,complex,nontrx,sp} [complex]

--oltp-reconnect-mode=STRING    reconnect mode {session,transaction,query,random} [session]

--oltp-sp-name=STRING           name of store procedure to call in SP test mode []

--oltp-read-only=[on|off]       generate only ‘read‘ queries (do not modify database) [off]

--oltp-skip-trx=[on|off]        skip BEGIN/COMMIT statements [off]

--oltp-range-size=N             range size for range queries [100]

--oltp-point-selects=N          number of point selects [10]

--oltp-simple-ranges=N          number of simple ranges [1]

--oltp-sum-ranges=N             number of sum ranges [1]

--oltp-order-ranges=N           number of ordered ranges [1]

--oltp-distinct-ranges=N        number of distinct ranges [1]

--oltp-index-updates=N          number of index update [1]

--oltp-non-index-updates=N      number of non-index updates [1]

--oltp-nontrx-mode=STRING       mode for non-transactional test {select, update_key, update_nokey, insert, delete} [select]

--oltp-auto-inc=[on|off]        whether AUTO_INCREMENT (or equivalent) should be used on id column [on]

--oltp-connect-delay=N          time in microseconds to sleep after connection to database [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        name of test table [sbtest]

--oltp-table-size=N             number of records in test table [10000]

--oltp-dist-type=STRING         random numbers distribution {uniform,gaussian,special} [special]

--oltp-dist-iter=N              number of iterations used for numbers generation [12]

--oltp-dist-pct=N               percentage of values to be treated as ‘special‘ (for special distribution) [1]

--oltp-dist-res=N               percentage of ‘special‘ values to use (for special distribution) [75]

General database options:

--db-driver=STRING  specifies database driver to use (‘help‘ to get list of available drivers)

--db-ps-mode=STRING prepared statements usage mode {auto, disable} [auto]

Compiled-in database drivers:

mysql - MySQL driver

pgsql - PostgreSQL driver

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 []

pgsql options:

--pgsql-host=STRING     PostgreSQL server host [localhost]

--pgsql-port=N          PostgreSQL server port [5432]

--pgsql-user=STRING     PostgreSQL user [sbtest]

--pgsql-password=STRING PostgreSQL password []

--pgsql-db=STRING       PostgreSQL database name [sbtest]

参数详解:

  --oltp-test-mode=STRING    执行模式{simple,complex(advanced transactional),nontrx(non-transactional),sp}。默认是complex

  --oltp-reconnect-mode=STRING 重新连接模式{session(不使用重新连接。每个线程断开只在测试结束),transaction(在每次事务结束后重新连接),query(在每个SQL语句执行完重新连接),random(对于每个事务随机选择以上重新连接模式)}。默认是session

  --oltp-sp-name=STRING   存储过程的名称。默认为空

  --oltp-read-only=[on|off]  只读模式。Updatedeleteinsert语句不可执行。默认是off

  --oltp-skip-trx=[on|off]   省略begin/commit语句。默认是off

  --oltp-range-size=N      查询范围。默认是100

  --oltp-point-selects=N          number of point selects [10]

  --oltp-simple-ranges=N          number of simple ranges [1]

  --oltp-sum-ranges=N             number of sum ranges [1]

  --oltp-order-ranges=N           number of ordered ranges [1]

  --oltp-distinct-ranges=N        number of distinct ranges [1]

  --oltp-index-updates=N          number of index update [1]

  --oltp-non-index-updates=N      number of non-index updates [1]

  --oltp-nontrx-mode=STRING   查询类型对于非事务执行模式{select, update_key, update_nokey, insert, delete} [select]

  --oltp-auto-inc=[on|off]      AUTO_INCREMENT是否开启。默认是on

  --oltp-connect-delay=N     在多少微秒后连接数据库。默认是10000

  --oltp-user-delay-min=N    每个请求最短等待时间。单位是ms。默认是0

  --oltp-user-delay-max=N    每个请求最长等待时间。单位是ms。默认是0

  --oltp-table-name=STRING  测试时使用到的表名。默认是sbtest

  --oltp-table-size=N         测试表的记录数。默认是10000

  --oltp-dist-type=STRING    分布的随机数{uniform(均匀分布),Gaussian(高斯分布),special(空间分布)}。默认是special

  --oltp-dist-iter=N    产生数的迭代次数。默认是12

  --oltp-dist-pct=N    值的百分比被视为‘special‘ (for special distribution)。默认是1

  --oltp-dist-res=N    special’的百分比值。默认是75

3.      总结:

以上就是sysbench工具的安装配置及相关选项参数的介绍,可以根据自己的需要添加对应的参数进行压力测试即可。在下一篇文档中将会对上面的几种模式进行相应的测试。

时间: 2024-08-05 03:55:54

Sysbench压力测试工具简介和使用(一)的相关文章

sysbench压力测试工具简介

一.sysbench压力测试工具简介: sysbench是一个开源的.模块化的.跨平台的多线程性能测试工具,可以用来进行CPU.内存.磁盘I/O.线程.数据库的性能测试.目前支持的数据库有MySQL.Oracle和PostgreSQL.以下操作都将以支持MySQL数据库为例进行. 1.      sysbench工具安装: 默认支持MySQL,如果需要测试Oracle/PostgreSQL,则在configure时需要加上–with-oracle或者–with-pgsql参数. 1.1     

sysbench压力测试工具简介和使用(二)

2.1    测试数据库服务器的硬件配置信息如下: CPU:      24核心线程数,Intel(R) Xeon(R) CPU E5-2620 0 @ 2.00GHz MEM:    64G,8*8G=64G DISK:      15000转/秒 2.2    对磁盘IO性能的测试: 2.2.1 创建fileio文件 创建初始化fileio文件: [[email protected] sysbench]# sysbench --test=fileio --file-num=16 --file

压力测试工具tsung用法简介

tsung是用erlang开发的一款简单易用的压力测试工具,可以生成成千上万的用户模拟对服务器进行访问.目前对tsung的理解也仅限于会简单的应用,其内部结构没有深入研究过. 1.安装 tsung是用erlang编写的,所以首先安装erlang的运行环境.然后就是按照tsung的官网下载编译tsung.需要注意的是,生成测试报告需要gnuplot和perl的支持,其中perl需要安装Template扩展.具体安装过程请看相关手册或者google之. 2.配置文件 默认情况下,tsung会加载配置

DNS压力测试工具dnsperf简介

dnsperf是我最近写的一个开源的DNS压力测试工具,用户可以用它来对DNS服务器或者Local DNS做压力测试.dnsperf目前的实现是单进程模式,通过epoll非阻塞地处理网络事件. dnsperf的地址:https://github.com/cobblau/dnsperf 参数详解 Dnsperf 支持下面的这些命令行参数: -s     用来指定DNS服务器的IP地址,默认值是127.0.0.1-p     用来指定DNS服务器的端口,默认值是53-d     用来指定DNS消息的

Web压力测试工具 webbench

在运维工作中,压力测试是一项很重要的工作.比如在一个网站上线之前,能承受多大访问量.在大访问量情况下性能怎样,这些数据指标好坏将会直接影响用户体验.但是,在压力测试中存在一个共性,那就是压力测试的结果与实际负载结果不会完全相同,就算压力测试工作做的再好,也不能保证100%和线上性能指标相同.面对这些问题,我们只能尽量去想方设法去模拟.所以,压力测试非常有必要,有了这些数据,我们就能对自己做维护的平台做到心中有数 1.简介 webbench是知名的网站压力测试工具,它是由Lionbridge公司(

三种压力测试工具 http_load 和 apache ab 、 siege 压力测试(转)

在测试站点性能时找到个不错的说明式文章 From:http://blog.csdn.net/lyflower/archive/2010/09/09/5873544.aspx 到http://www.acme.com/software/http_load/ 下载http_load ,安装也很简单直接make;make instlall 就行. http_load 的标准的两个例子是: http_load -parallel 5 -fetches 1000 urls.txt http_load -r

sysbench-系统、数据库压力测试工具

sysbench是一款简单易用的压力测试工具,可以测试cpu,memory,fileio,mysql数据库; sysbench安装方法: 默认的epel源中的sysbench是0.4版本的,现在已经到1.x版本,本主采用1.x版本 github-->https://github.com/akopytov/sysbench centos安装方法:     #curl -s https://packagecloud.io/install/repositories/akopytov/sysbench/

Web压力测试工具 http_load

简介 http_load是基于linux.unix平台的一种性能测工具 它以并行复用的方式运行,用以测试web服务器的吞吐量与负载,测试web页面的性能 但是它不同于大多数压力测试工具,它可以以一个单一的进程运行,一般不会把客户机搞死 还可以测试HTTPS类的网站请求 总结特点以及缺点 特点: 基于命令行,简单.易于上手 小巧轻便,解压缩后既然还不到100kb 这款工具是开源,免费的 缺点: 仅适用于web页面的性能测试,不适用于访问数据库 测试结果分析有限 平台依赖Linux(没有Window

Web压力测试工具 Siege

1.简介 一款开源的压力测试工具,可以根据配置对一个WEB站点进行多用户的并发访问,记录每个用户所有请求过程的相应时间,并在一定数量的并发访问下重复进行 官网地址:www.joedog.org 官网下载地址:http://download.joedog.org/siege/ 2.安装 [[email protected] ~]# cd /usr/local/src/ [[email protected] src]# wget http://download.joedog.org/siege/si