SysBench压力测试

来源:互联网 发布:java实现解压缩zip 编辑:程序博客网 时间:2024/05/02 02:48
sysbench mysql
2011-06-09 09:01:56

SysBench压力测试

December 15th, 2010

SysBench安装

下载SysBench

[root@localhost opt]# wget http://downloads.sourceforge.net/project/sysbench/sysbench/0.4.12/sysbench-0.4.12.tar.gz

安装SysBench

[root@localhost opt]# tar zxvf sysbench-0.4.12.tar.gz[root@localhost sysbench-0.4.12]# ./configure --prefix=/opt/sysbench \--with-mysql-includes=/mysql/include/mysql \--with-mysql-libs=/mysql/lib/mysql
[root@localhost sysbench-0.4.12]#make && make install

出现以下错误:

../libtool: line 835: X--tag=CC: command not found../libtool: line 868: libtool: ignoring unknown tag : command not found../libtool: line 835: X--mode=link: command not found../libtool: line 1001: *** Warning: inferring the mode of operation is deprecated.: command not found../libtool: line 1002: *** Future versions of Libtool will require --mode=MODE be specified.: command not found../libtool: line 2228: X-D_THREAD_SAFE: command not found../libtool: line 2228: X-g: command not found../libtool: line 2228: X-O2: command not found../libtool: line 1948: X-L/usr/local/mysql/lib: No such file or directory../libtool: line 2397: Xsysbench: command not found

解决办法: 修改configure.ac文件,注释掉 AC_PROG_LIBTOOL,添加上 AC_PROG_RANLIB

[root@localhost sysbench-0.4.12]# vi configure.ac
#AC_PROG_LIBTOOLAC_PROG_RANLIB

再执行

[root@localhost sysbench-0.4.12]# ./autogen.sh

重新安装,一切OK

[root@localhost sysbench-0.4.12]# ./configure --prefix=/opt/sysbench --with-mysql-includes=/mysql/include/mysql --with-mysql-libs=/mysql/lib/mysql
[root@localhost sysbench-0.4.12]# make && make install

SysBench压力测试

1、cpu测试

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

2、线程测试

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

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

4、内存测试

sysbench  --test=memory --num-threads=16 --memory-block-size=8192 --memory-total-size=4G run

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

5、Mutex测试

sysbench --test=mutex --num-threads=16 --mutex-num=1024 --mutex-locks=10000 --mutex-loops=5000 run

6、OLTP测试

sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-user=chaos --mysql-host=127.0.0.1 --mysql-socket=/mysql/mysql.sock   --mysql-password=123456 --db-driver=mysql preparesysbench --mysql-db=sbtest --max-requests=0 --test=oltp --mysql-engine-trx=yes --mysql-table-engine=innodb --oltp-table-size=1000000 --db-ps-mode=disable  --mysql-user=chaos --mysql-host=127.0.0.1 --mysql-socket=/mysql/mysql.sock   --mysql-password=123456 --num-threads=16 --max-time=600 runsysbench --mysql-db=sbtest --max-requests=0 --test=oltp --mysql-engine-trx=yes --mysql-table-engine=innodb --oltp-table-size=1000000 --db-ps-mode=disable  --mysql-user=chaos --mysql-host=127.0.0.1 --mysql-socket=/mysql/mysql.sock   --mysql-password=123456 --num-threads=16 --max-time=600 --oltp-read-only runsysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-user=chaos --mysql-host=127.0.0.1 --mysql-socket=/mysql/mysql.sock   --mysql-password=123456 --db-driver=mysql cleanup

测试 OLTP 时,要自己先创建数据库 sbtest否则提示找不到数据库,也可以用参数 --mysql-db 来指定使用其他数据库 。

[root@localhost bin]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-host=127.0.0.1 --mysql-user=chaos --mysql-password=123456 --mysql-socket=/mysql/mysql.sock preparesysbench 0.4.12:  multi-threaded system evaluation benchmarkNo DB drivers specified, using mysqlFATAL: unable to connect to MySQL server, aborting...FATAL: error 1049: Unknown database 'sbtest'FATAL: failed to connect to database server!

测试结果

CPU性能测试:

[root@localhost bin]# ./sysbench --test=cpu --cpu-max-prime=20000 runsysbench 0.4.12:  multi-threaded system evaluation benchmarkRunning the test with following options:Number of threads: 1Doing CPU performance benchmarkThreads started!Done.Maximum prime number checked in CPU test: 20000Test execution summary:    total time:                          45.8865s    total number of events:              10000    total time taken by event execution: 45.8828    per-request statistics:         min:                                  4.58ms         avg:                                  4.59ms         max:                                  4.68ms         approx.  95 percentile:               4.59msThreads fairness:    events (avg/stddev):           10000.0000/0.00    execution time (avg/stddev):   45.8828/0.00

线程测试:

[root@localhost bin]# ./sysbench --test=threads --num-threads=64 --thread-yields=100 --thread-locks=2 runsysbench 0.4.12:  multi-threaded system evaluation benchmarkRunning the test with following options:Number of threads: 64Doing thread subsystem performance testThread yields per test: 100 Locks used: 2Threads started!Done.Test execution summary:    total time:                          2.0729s    total number of events:              10000    total time taken by event execution: 132.4626    per-request statistics:         min:                                  0.04ms         avg:                                 13.25ms         max:                                116.38ms         approx.  95 percentile:              50.31msThreads fairness:    events (avg/stddev):           156.2500/16.77    execution time (avg/stddev):   2.0697/0.00

IO性能测试:

[root@localhost bin]# ./sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw preparesysbench 0.4.12:  multi-threaded system evaluation benchmark128 files, 24576Kb each, 3072Mb totalCreating files for the test...[root@localhost bin]# ./sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw runsysbench 0.4.12:  multi-threaded system evaluation benchmarkRunning the test with following options:Number of threads: 16Extra file open flags: 0128 files, 24Mb each3Gb total file sizeBlock size 16KbNumber of random requests for random IO: 10000Read/Write ratio for combined random IO test: 1.50Periodic FSYNC enabled, calling fsync() each 100 requests.Calling fsync() at the end of test, Enabled.Using synchronous I/O modeDoing random r/w testThreads started!Done.Operations performed:  5996 Read, 4004 Write, 12803 Other = 22803 TotalRead 93.688Mb  Written 62.562Mb  Total transferred 156.25Mb  (9.8301Mb/sec)  629.13 Requests/sec executedTest execution summary:    total time:                          15.8951s    total number of events:              10000    total time taken by event execution: 14.4041    per-request statistics:         min:                                  0.01ms         avg:                                  1.44ms         max:                                270.11ms         approx.  95 percentile:               0.02msThreads fairness:    events (avg/stddev):           625.0000/129.93    execution time (avg/stddev):   0.9003/0.24[root@localhost bin]# ./sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanupsysbench 0.4.12:  multi-threaded system evaluation benchmarkRemoving test files...

内存测试:

[root@localhost bin]# ./sysbench --test=memory --num-threads=16 --memory-block-size=8192 --memory-total-size=4G runsysbench 0.4.12:  multi-threaded system evaluation benchmarkRunning the test with following options:Number of threads: 16Doing memory operations speed testMemory block size: 8KMemory transfer size: 4096MMemory operations type: writeMemory scope type: globalThreads started!Done.Operations performed: 524288 (648554.23 ops/sec)4096.00 MB transferred (5066.83 MB/sec)Test execution summary:    total time:                          0.8084s    total number of events:              524288    total time taken by event execution: 7.2785    per-request statistics:         min:                                  0.00ms         avg:                                  0.01ms         max:                                  4.33ms         approx.  95 percentile:               0.01msThreads fairness:    events (avg/stddev):           32768.0000/4387.59    execution time (avg/stddev):   0.4549/0.02

Mutex测试:

[root@localhost bin]# ./sysbench --test=mutex --num-threads=16 --mutex-num=1024 --mutex-locks=10000 --mutex-loops=5000 runsysbench 0.4.12:  multi-threaded system evaluation benchmarkRunning the test with following options:Number of threads: 16Doing mutex performance testThreads started!Done.Test execution summary:    total time:                          0.1577s    total number of events:              16    total time taken by event execution: 2.1000    per-request statistics:         min:                                 73.13ms         avg:                                131.25ms         max:                                145.63ms         approx.  95 percentile:             145.56msThreads fairness:    events (avg/stddev):           1.0000/0.00    execution time (avg/stddev):   0.1313/0.02

数据库测试:

[root@localhost bin]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-user=chaos --mysql-host=127.0.0.1 --mysql-socket=/mysql/mysql.sock   --mysql-password=123456 --db-driver=mysql preparesysbench 0.4.12:  multi-threaded system evaluation benchmarkCreating table 'sbtest'...Creating 1000000 records in table 'sbtest'...[root@localhost bin]# ./sysbench --mysql-db=sbtest --max-requests=0 --test=oltp --mysql-engine-trx=yes --mysql-table-engine=innodb --oltp-table-size=1000000 --db-ps-mode=disable  --mysql-user=chaos --mysql-host=127.0.0.1 --mysql-socket=/mysql/mysql.sock   --mysql-password=123456 --num-threads=16 --max-time=600 runsysbench 0.4.12:  multi-threaded system evaluation benchmarkNo DB drivers specified, using mysqlRunning the test with following options:Number of threads: 16Doing OLTP test.Running mixed OLTP testUsing Special distribution (12 iterations,  1 pct of values are returned in 75 pct cases)Using "BEGIN" for starting transactionsUsing auto_inc on the id columnThreads started!Time limit exceeded, exiting...(last message repeated 15 times)Done.OLTP test statistics:    queries performed:        read:                            298466        write:                           106595        other:                           42638        total:                           447699    transactions:                        21319  (35.51 per sec.)    deadlocks:                           0      (0.00 per sec.)    read/write requests:                 405061 (674.64 per sec.)    other operations:                    42638  (71.01 per sec.)Test execution summary:    total time:                          600.4126s    total number of events:              21319    total time taken by event execution: 9602.9898    per-request statistics:         min:                                 47.43ms         avg:                                450.44ms         max:                                897.43ms         approx.  95 percentile:             518.83msThreads fairness:    events (avg/stddev):           1332.4375/2.09    execution time (avg/stddev):   600.1869/0.12[root@localhost bin]# ./sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=1000000 --mysql-user=chaos --mysql-host=127.0.0.1 --mysql-socket=/mysql/mysql.sock   --mysql-password=123456 --db-driver=mysql cleanupsysbench 0.4.12:  multi-threaded system evaluation benchmarkDropping table 'sbtest'...Done.
原创粉丝点击