sysbench测试软件

sysbench是一款测试工具

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

http://sourceforge.net/projects/sysbench下载安装包.

[@more@]

我这里只对主机做一些测试

tar zxf sysbench-0.4.8.tar.gz
cd sysbench-0.4.8
./configure –without-mysql

make

make install

比如我的 MySQL 喜欢自己安装在 /usr/local/mysql 下,则按照以下方法编译:

/configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib && make && make install当然了,用上面的参数编译的话,就要确保您的 MySQL lib目录下有对应的 so 文档,假如没有,能够自己下载 devel share 包来安装。另外,假如想要让 sysbench 支持 pgsql/oracle 的话,就需要在编译的时候加上参数
--with-pgsql

--with-oracle
2个参数默认是关闭的,只有 MySQL 是默认支持的。

测试的时候注意thread数大于两倍CPU数,测试文件大小大于5倍内存大小。

拿两台机器,test18CPU16G内存)和test23CPU8G内存)来做测试

1、 cpu性能测试
sysbench --test=cpu --num-threads=32 --cpu-max-prime=90000 run
cpu
测试主要是进行素数的加法运算,在上面的例子中,指定了最大的素数为 90000

root :/root>#sysbench --test=cpu --num-threads=32 --cpu-max-prime=90000 run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 32

Doing CPU performance benchmark

Threads started!

Done.

Maximum prime number checked in CPU test: 90000

Test execution summary:

total time: 26.4945s

total number of events: 10000

total time taken by event execution: 837.0154

per-request statistics:

min: 0.0208s

avg: 0.0837s

max: 1.6919s

approx. 95 percentile: 0.3208s

Threads fairness:

events (avg/stddev): 312.5000/3.98

execution time (avg/stddev): 26.1567/0.25


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

thread-locks小于线程数除以2lock越少,处理时间越长。

test1: sysbench --test=threads --num-threads=512 --thread-yields=100 --thread-locks=2 run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 512

Doing thread subsystem performance test

Thread yields per test: 100 Locks used: 2

Threads started!

Done.

Test execution summary:

total time: 2.5360s

total number of events: 10000

total time taken by event execution: 1276.9943

per-request statistics:

min: 0.0003s

avg: 0.1277s

max: 0.6007s

approx. 95 percentile: 0.3051s

Threads fairness:

events (avg/stddev): 19.5312/3.36

execution time (avg/stddev): 2.4941/0.02
3
、磁盘IO性能测试
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw prepare
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw run
sysbench --test=fileio --num-threads=16 --file-total-size=3G --file-test-mode=rndrw cleanup
上述参数指定了最大创建16个线程,创建的文档总大小为3G,文档读写模式为随机读。

CD到空间足够的文件系统,执行命令等待创建

test1:/root>#sysbench --test=fileio --num-threads=64 --file-total-size=12G --file-test-mode=rndrw prepare

sysbench v0.4.8: multi-threaded system evaluation benchmark

128 files, 98304Kb each, 12288Mb total

Creating files for the test...

test1: /root>#sysbench --test=fileio --num-threads=64 --file-total-size=12G --file-test-mode=rndrw run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 64

Extra file open flags: 0

128 files, 96Mb each

12Gb 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: 5991 Read, 4009 Write, 12424 Other = 22424 Total

Read 93.609Mb Written 62.641Mb Total transferred 156.25Mb (64.986Mb/sec)

4159.07 Requests/sec executed

Test execution summary:

total time: 2.4044s

total number of events: 10000

total time taken by event execution: 23.6357

per-request statistics:

min: 0.0000s

avg: 0.0024s

max: 0.3453s

approx. 95 percentile: 0.0161s

Threads fairness:

events (avg/stddev): 156.2500/48.33

execution time (avg/stddev): 0.3693/0.15

test2: sysbench --test=fileio --num-threads=64 --file-total-size=12G --file-test-mode=rndrw run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 64

Extra file open flags: 0

128 files, 96Mb each

12Gb 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: 5996 Read, 4011 Write, 11032 Other = 21039 Total

Read 93.688Mb Written 62.672Mb Total transferred 156.36Mb (19.025Mb/sec)

1217.61 Requests/sec executed

Test execution summary:

total time: 8.2186s

total number of events: 10007

total time taken by event execution: 82.9911

per-request statistics:

min: 0.0000s

avg: 0.0083s

max: 0.7963s

approx. 95 percentile: 0.0140s

Threads fairness:

events (avg/stddev): 156.3594/39.62

execution time (avg/stddev): 1.2967/0.50

我们看到两台机器的速度差好多,一个64M/S,一个19M/S.第二台估计有问题,需要找找原因。测试完后记得删除数据,否则会占用空间。

sysbench --test=fileio --num-threads=64 --file-total-size=12G --file-test-mode=rndrw cleanup

4、内存测试

sysbench --test=memory --memory-block-size=8192 --memory-total-size=4G run上述参数指定了本次测试整个过程是在内存中传输 4G的数据量,每个 block 大小为 8K

test1:/root>#sysbench --test=memory --num-threads=32 --memory-block-size=8192 --memory-total-size=512G run

sysbench v0.4.8: multi-threaded system evaluation benchmark

Running the test with following options:

Number of threads: 32

Doing memory operations speed test

Memory block size: 8K

Memory transfer size: 524288M

Memory operations type: write

Memory scope type: global

Threads started!

WARNING: Operation time (0.000000) is less than minimal counted value, counting as 1.000000

WARNING: Percentile statistics will be inaccurate

Done.

Operations performed: 67108864 (404978.13 ops/sec)

524288.00 MB transferred (3163.89 MB/sec)

Test execution summary:

total time: 165.7098s

total number of events: 67108864

total time taken by event execution: 2255.6291

per-request statistics:

min: 0.0000s

avg: 0.0000s

max: 1.3688s

approx. 95 percentile: 0.0000s

Threads fairness:

events (avg/stddev): 2097152.0000/48708.11

execution time (avg/stddev): 70.4884/1.38

test2:

Test execution summary:

total time: 168.1723s

total number of events: 67108864

total time taken by event execution: 2317.9228

per-request statistics:

min: 0.0000s

avg: 0.0000s

max: 1.5573s

approx. 95 percentile: 0.0000s

Threads fairness:

events (avg/stddev): 2097152.0000/41302.17

execution time (avg/stddev): 72.4351/1.29

以下不是我测试的,为完整性,从下面网址拷过来的。

http://hi.baidu.com/tister/blog/item/1b0cc4f945d5005d242df263.html

5OLTP测试

1 、准备数据
# sysbench --debug=off --test=oltp --mysql-host=10.15.2.137 --mysql-user=test --mysql-password=test --oltp-table-size=1000000 --mysql-db=test --oltp-table-name=stest --num-threads=20 --max-requests=10000 --oltp-auto-inc=off --mysql-engine-trx=yes prepare

2
、测试
# sysbench --debug=off --test=oltp --mysql-host=10.15.2.137 --mysql-user=test --mysql-password=test --oltp-table-size=1000000 --mysql-db=test --oltp-table-name=stest --num-threads=20 --max-requests=10000 --oltp-auto-inc=off --mysql-engine-trx=yes run

3
、删除数据
# sysbench --debug=off --test=oltp --mysql-host=10.15.2.137 --mysql-user=test --mysql-password=test --oltp-table-size=1000000 --mysql-db=test --oltp-table-name=stest --num-threads=20 --max-requests=10000 --oltp-auto-inc=off --mysql-engine-trx=yes cleanup

指定了表最大记录数为 1000000,其他参数就很好理解了,主要是指定登录方式。测试 OLTP 时,能够自己先创建数据库 sbtest,或自己用参数 --mysql-db 来指定其他数据库。--mysql-table-engine 还能够指定为 innodb MySQL 支持的表存储引擎类型。

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/668365/viewspace-1014757/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/668365/viewspace-1014757/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值