sysbench工具手把手安装配置及使用…

来源:互联网 发布:电影台词拼接软件 编辑:程序博客网 时间:2024/06/17 00:52

sysbench是一款测试工具
主要包括以下几种方式的测试:

1、cpu性能
2、磁盘io性能
3、调度程式性能
4、内存分配及传输速度
5、POSIX线程性能
6、数据库性能(OLTP基准测试)现在sysbench主要支持 MySQL,pgsql,oracle 这3种数据库

本文以实际的安装和简单的测试以做抛砖引玉,希望在泰岳的性能测试中发挥应有的作用。

 


一:安装mysql

先安装
MySQL-client-5.5.32-1.rhel5.i386.rpm
MySQL-server-5.5.32-1.rhel5.i386.rpm

下面三个用于性能测试用

MySQL-shared-5.5.32-1.rhel5.i386.rpm
MySQL-devel-5.5.32-1.rhel5.i386.rpm
MySQL-shared-compat-5.5.32-1.rhel5.i386.rpm

二:安装sysbench
   安装sysbench因为是源码需要编译及需要其他的包或工具,较为繁琐,现做具体介绍
1.下载sysbench sysbench-0.4.12.tar.gz,并上传到/usr/local目录下

[root@localhost local]# ls
bin                   etc      man                                         sbin
cmake-2.8.10.2        games    mysql-5.6.11.tar.gz                         share
cmake-2.8.10.2.tar.gz include  MySQL-client-5.5.32-1.rhel5.i386.rpm        src
config                lib      MySQL-devel-5.5.32-1.rhel5.i386.rpm         
config.log            libexec  MySQL-server-5.5.32-1.rhel5.i386.rpm        sysbench-0.4.12.tar.gz
config.status         libtool  MySQL-shared-5.5.32-1.rhel5.i386.rpm
doc                   Makefile MySQL-shared-compat-5.5.32-1.rhel5.i386.rpm
 
2.解压   tax -zxvfsysbench-0.4.12.tar.gz


[root@localhost local]# ls
bin                   etc      man                                         sbin
cmake-2.8.10.2        games    mysql-5.6.11.tar.gz                         share
cmake-2.8.10.2.tar.gz include  MySQL-client-5.5.32-1.rhel5.i386.rpm        src
config                lib      MySQL-devel-5.5.32-1.rhel5.i386.rpm         sysbench-0.4.12
config.log            libexec  MySQL-server-5.5.32-1.rhel5.i386.rpm        sysbench-0.4.12.tar.gz
config.status         libtool  MySQL-shared-5.5.32-1.rhel5.i386.rpm
doc                   Makefile MySQL-shared-compat-5.5.32-1.rhel5.i386.rpm

3.编译,安装

/usr/local/sysbench-0.4.12/configure--with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib&& make&& make install
....
test -z "/usr/local/share/doc/sysbench" || mkdir -p --"/usr/local/share/doc/sysbench"
 /usr/bin/install -c -m 644 'manual.html''/usr/local/share/doc/sysbench/manual.html'
make[3]: Leaving directory `/usr/local/sysbench-0.4.12/doc'
make[2]: Leaving directory `/usr/local/sysbench-0.4.12/doc'
make[1]: Leaving directory `/usr/local/sysbench-0.4.12/doc'
Making install in sysbench
make[1]: Entering directory`/usr/local/sysbench-0.4.12/sysbench'
Making install in drivers
make[2]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/drivers'
Making install in mysql
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/drivers/mysql'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/drivers/mysql'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/drivers/mysql'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/drivers/mysql'
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/drivers'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/drivers'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/drivers'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/drivers'
make[2]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/drivers'
Making install in tests
make[2]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests'
Making install in cpu
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/cpu'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/cpu'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/cpu'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/cpu'
Making install in fileio
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/fileio'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/fileio'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/fileio'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/fileio'
Making install in memory
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/memory'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/memory'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/memory'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/memory'
Making install in threads
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/threads'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/threads'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/threads'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/threads'
Making install in mutex
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/mutex'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/mutex'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/mutex'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/mutex'
Making install in oltp
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/oltp'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests/oltp'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/oltp'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests/oltp'
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests'
make[4]: Entering directory`/usr/local/sysbench-0.4.12/sysbench/tests'
make[4]: Nothing to be done for `install-exec-am'.
make[4]: Nothing to be done for `install-data-am'.
make[4]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests'
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests'
make[2]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench/tests'
Making install in .
make[2]: Entering directory`/usr/local/sysbench-0.4.12/sysbench'
make[3]: Entering directory`/usr/local/sysbench-0.4.12/sysbench'
test -z "/usr/local/bin" || mkdir -p -- "/usr/local/bin"
  /bin/sh ../libtool --mode=install/usr/bin/install -c 'sysbench' '/usr/local/bin/sysbench'
/usr/bin/install -c sysbench /usr/local/bin/sysbench
make[3]: Nothing to be done for `install-data-am'.
make[3]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench'
make[2]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench'
make[1]: Leaving directory`/usr/local/sysbench-0.4.12/sysbench'
make[1]: Entering directory `/usr/local/sysbench-0.4.12'
make[2]: Entering directory `/usr/local/sysbench-0.4.12'
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
make[2]: Leaving directory `/usr/local/sysbench-0.4.12'
make[1]: Leaving directory `/usr/local/sysbench-0.4.12'


三测试:

1.数据库oltp测试,这个需要创建数据库sbtest;以下见具体测试用例

[root@localhost local]# sysbench --num-threads=5--max-requests=1000 --test=oltp --mysql-table-engine=myisam--oltp-table-size=4000000 --mysql-socket=/var/lib/mysql/mysql.sock--mysql-db=sbtest --mysql-user=root--mysql-host=127.0.0.1  --mysql-password=rootrun
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 5

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

OLTP test statistics:
    queriesperformed:
       read:                           14000
       write:                          5000
       other:                          2000
       total:                          21000
   transactions:                       1000   (51.63 per sec.)
   deadlocks:                              (0.00 per sec.)
    read/writerequests:                19000  (981.00 per sec.)
    otheroperations:                   2000   (103.26 per sec.)

Test execution summary:
    totaltime:                         19.3679s
    total numberofevents:             1000
    total timetaken by event execution: 94.0158
    per-requeststatistics:
        min:                                14.71ms
        avg:                                94.02ms
        max:                              5708.77ms
        approx.  95percentile:            113.91ms

Threads fairness:
    events(avg/stddev):          200.0000/72.46
    executiontime (avg/stddev):  18.8032/0.26

[root@localhost local]# sysbench --num-threads=5--max-requests=5000 --test=oltp --mysql-table-engine=myisam--oltp-table-size=4000000 --mysql-socket=/var/lib/mysql/mysql.sock--mysql-db=sbtest --mysql-user=root--mysql-host=127.0.0.1  --mysql-password=rootrun
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

No DB drivers specified, using mysql
Running the test with following options:
Number of threads: 5

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

OLTP test statistics:
    queriesperformed:
       read:                           70000
       write:                          25000
       other:                          10000
       total:                          105000
   transactions:                       5000   (46.05 per sec.)
   deadlocks:                              (0.00 per sec.)
    read/writerequests:                95000  (874.91 per sec.)
    otheroperations:                   10000  (92.10 per sec.)

Test execution summary:
    totaltime:                         108.5830s
    total numberofevents:             5000
    total timetaken by event execution: 542.5105
    per-requeststatistics:
        min:                                17.93ms
        avg:                               108.50ms
        max:                              7212.44ms
        approx.  95percentile:            146.43ms

Threads fairness:
    events(avg/stddev):          1000.0000/96.35
    executiontime (avg/stddev):  108.5021/0.03


2.cpu测试
cpu测试主要是进行素数的加法运算,在上面的例子中,指定了最大的素数为20000,自己可以根据机器cpu的性能来适当调整数值。
sysbench --test=cpu --cpu-max-prime=200 run

[root@localhost ~]# sysbench --test=cpu --cpu-max-prime=200run
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 200


Test execution summary:
    totaltime:                         0.5087s
    total numberofevents:             10000
    total timetaken by event execution: 0.4448
    per-requeststatistics:
        min:                                 0.03ms
        avg:                                 0.04ms
        max:                                20.45ms
        approx.  95percentile:              0.02ms

Threads fairness:
    events(avg/stddev):          10000.0000/0.00
    executiontime (avg/stddev):  0.4448/0.00

[root@localhost ~]# sysbench --test=cpu --cpu-max-prime=2000run
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 2000


Test execution summary:
    totaltime:                         3.3867s
    total numberofevents:             10000
    total timetaken by event execution: 3.3185
    per-requeststatistics:
        min:                                 0.14ms
        avg:                                 0.33ms
        max:                                14.34ms
        approx.  95percentile:              0.36ms

Threads fairness:
    events(avg/stddev):          10000.0000/0.00
    executiontime (avg/stddev):  3.3185/0.00

[root@localhost ~]# sysbench --test=cpu --cpu-max-prime=20000run
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 20000


Test execution summary:
    totaltime:                         61.4178s
    total numberofevents:             10000
    total timetaken by event execution: 61.3427
    per-requeststatistics:
        min:                                 1.13ms
        avg:                                 6.13ms
        max:                                56.49ms
        approx.  95percentile:              7.96ms

Threads fairness:
    events(avg/stddev):          10000.0000/0.00
    executiontime (avg/stddev):  61.3427/0.00

3、线程测试
sysbench --test=threads --num-threads=16 --thread-yields=100--thread-locks=2 run

[root@localhost ~]# sysbench --test=cpu --cpu-max-prime=20000run
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

Running the test with following options:
Number of threads: 1

Doing CPU performance benchmark

Threads started!
Done.

Maximum prime number checked in CPU test: 20000


Test execution summary:
    totaltime:                         61.4178s
    total numberofevents:             10000
    total timetaken by event execution: 61.3427
    per-requeststatistics:
        min:                                 1.13ms
        avg:                                 6.13ms
        max:                                56.49ms
        approx.  95percentile:              7.96ms

Threads fairness:
    events(avg/stddev):          10000.0000/0.00
    executiontime (avg/stddev):  61.3427/0.00

[root@localhost ~]# sysbench --test=threads --num-threads=16--thread-yields=100 --thread-locks=2 run
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

Running the test with following options:
Number of threads: 16

Doing thread subsystem performance test
Thread yields per test: 100 Locks used: 2
Threads started!
Done.


Test execution summary:
    totaltime:                         83.0173s
    total numberofevents:             10000
    total timetaken by event execution: 1327.3256
    per-requeststatistics:
        min:                                13.21ms
        avg:                               132.73ms
        max:                              7176.51ms
        approx.  95percentile:            835.83ms

Threads fairness:
    events(avg/stddev):          625.0000/109.40
    executiontime (avg/stddev):  82.9578/0.03

[root@localhost ~]#

4、磁盘IO性能测试
sysbench --test=fileio --num-threads=5 --file-total-size=100M--file-test-mode=rndrw prepare
sysbench --test=fileio --num-threads=5 --file-total-size=100M--file-test-mode=rndrw run
sysbench --test=fileio --num-threads=5 --file-total-size=100M--file-test-mode=rndrw  cleanup

[root@localhost ~]# sysbench --test=fileio --num-threads=5--file-total-size=100M --file-test-mode=rndrw run
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

Running the test with following options:
Number of threads: 5

Extra file open flags: 0
128 files, 800Kb each
100Mb total file size
Block size 16Kb
Number of random requests for random IO: 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!
Done.

Operations performed:  5999 Read, 4001 Write,12800 Other = 22800 Total
Read 93.734Mb  Written 62.516Mb Total transferred 156.25Mb  (12.456Mb/sec)
  797.20 Requests/sec executed

Test execution summary:
    totaltime:                         12.5439s
    total numberofevents:             10000
    total timetaken by event execution: 4.0691
    per-requeststatistics:
        min:                                 0.03ms
        avg:                                 0.41ms
        max:                               207.37ms
        approx.  95percentile:              0.08ms

Threads fairness:
    events(avg/stddev):          2000.0000/247.35
    executiontime (avg/stddev):  0.8138/0.22

root@localhost ~]# sysbench--test=fileio --num-threads=5 --file-total-size=100M--file-test-mode=rndrw  cleanup
sysbench 0.4.12:  multi-threaded system evaluationbenchmark

Removing test files...
[root@localhost ~]#

上述参数指定了最大创建5个线程,创建的文件总大小为100M,文件读写模式为随机读。

4、内存测试
sysbench --test=memory --memory-block-size=8k--memory-total-size=100M run

上述参数指定了本次测试整个过程是在内存中传输 100M 的数据量,每个 block 大小为 8K。


四:实际过程中可能会遇到一些问题:

问题2. 出现configure: error: no acceptable C compiler found in$PATH
解决办法:安装gcc,命令为:yum install gcc。

问题2:出现../libtool: line 5172: : command not found
解决办法   运行[root@localhostsysbench-0.4.12]# ./autogen.sh

问题3:source directory already configured, make distclean的错误解决.
解决办法:在sysbench目录运行 make distclean

问题4:configure时候出现 i686-pc-linux' notrecognized提示               
     在运行./configure 时如果出现下面的提示信息:
     checking build system
     type... Invalid configuration `i686-pc-linux-': machine`i686-pc-linux' not
     recognized
     configure: error:
     /bin/sh ./config.sub i686-pc-linux- failed
解决办法:就使用./configure --build=i686-pc-linux-gnu来设置

 

 

0 0
原创粉丝点击