sysbench 测试mysql性能

=====

#1
sysbench --test=oltp --oltp-table-size=10000 --mysql-db=test --mysql-user=root --mysql-password=123456
--mysql-socket=/data/mysql/3306/mysql.sock --db-driver=mysql prepare

#2
sysbench --test=oltp --oltp-table-size=10000 --mysql-db=test --mysql-user=root --mysql-password=123456
--mysql-socket=/data/mysql/3306/mysql.sock --db-driver=mysql
--max-time=720 --max-requests=0 --num-threads=16 --oltp-test-mode=complex run

#3
sysbench --test=oltp --oltp-table-size=10000 --mysql-db=test --mysql-user=root --mysql-password=123456
--mysql-socket=/data/mysql/3306/mysql.sock --db-driver=mysql
--max-time=720 --max-requests=0 --num-threads=16 --oltp-test-mode=complex cleanup

===========

1.安装sysbench

yum install sysbench

2.测试前准备

sysbench --test=oltp --oltp-table-size=80000000

--db-driver=mysql

--mysql-socket=/var/lib/mysql/mysql.sock

--mysql-user=root  

--mysql-password='root'

--mysql-db=test

prepare

在test数据库中创建sbtest表,并插入80000000数据,表引擎为InnoDB

3.测试

把上面的语句最后一行改为run即可

sysbench --test=oltp --oltp-table-size=80000000

--db-driver=mysql

--mysql-socket=/var/lib/mysql/mysql.sock

--mysql-user=root  

--mysql-password='root'

--mysql-db=test

run

4.结果

sysbench 0.4.12: multi-threaded system evaluation benchmark

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

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 10000
Threads started!
Done.

OLTP test statistics:
queries performed:
read: 140000
write: 50000
other: 20000
total: 210000
transactions: 10000 (27.14 per sec.) #每秒处理的事务数
deadlocks: 0 (0.00 per sec.)
read/write requests: 190000 (515.69 per sec.) #每秒处理的读写请求
other operations: 20000 (54.28 per sec.)

Test execution summary:
total time: 368.4417s
total number of events: 10000
total time taken by event execution: 368.3644
per-request statistics:
min: 3.72ms
avg: 36.84ms
max: 326.52ms
approx. 95 percentile: 76.04ms

Threads fairness:
events (avg/stddev): 10000.0000/0.00
execution time (avg/stddev): 368.3644/0.00

5.清理数据

sysbench --test=oltp --oltp-table-size=80000000

--db-driver=mysql

--mysql-socket=/var/lib/mysql/mysql.sock

--mysql-user=root  

--mysql-password='root'

--mysql-db=test

cleanup

原文地址:https://www.cnblogs.com/moss_tan_jun/p/6594769.html