一、安装Mysqlslap
二、参数说明
[root@mysql01 /]# mysqlslap --help
主要参数:
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 0.014 seconds
Minimum number of seconds to run all queries: 0.014 seconds
Maximum number of seconds to run all queries: 0.014 seconds
Number of clients running queries: 1
Average number of queries per client: 0
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 0.018 seconds
Minimum number of seconds to run all queries: 0.018 seconds
Maximum number of seconds to run all queries: 0.018 seconds
Number of clients running queries: 1
Average number of queries per client: 0
2.并在100的用户
[root@mysql01 /]# mysqlslap -a -c100 --engine=innodb -h 10.2.3.218 -p3306 -uroot -payilian
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 2.313 seconds
Minimum number of seconds to run all queries: 2.313 seconds
Maximum number of seconds to run all queries: 2.313 seconds
Number of clients running queries: 100
Average number of queries per client: 0
练习一:
单线程测试。测试做了什么。
>./bin/mysqlslap -a -uroot -p111111
多线程测试。使用--concurrency来模拟并发连接。
> ./bin/mysqlslap -a -c 100 -uroot -p111111
迭代测试。用于需要多次执行测试得到平均值。
> ./bin/mysqlslap -a -i 10 -uroot -p111111
练习二:
> ./bin/mysqlslap -auto-generate-sql-add-autoincrement -a -uroot -p111111
> ./bin/mysqlslap -a -auto-generate-sql-load-type=read -uroot -p111111
> ./bin/mysqlslap -a -auto-generate-secondary-indexes=3 -uroot -p111111
> ./bin/mysqlslap -a -auto-generate-sql-write-number=1000 -uroot -p111111
> ./bin/mysqlslap --create-schema world -q "select count(*) from City" -uroot -p111111
> ./bin/mysqlslap -a -e innodb -uroot -p111111
> ./bin/mysqlslap -a --number-of-queries=10 -uroot -p111111
练习三:
执行一次测试,分别50和100个并发,执行1000次总查询:
> ./bin/mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --debug-info -uroot -p111111
50和100个并发分别得到一次测试结果(Benchmark),并发数越多,执行完所有查询的时间越长。为了准确起见,可以多迭代测试几次:
> ./bin/mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --debug-info -uroot -p111111
测试同时不同的存储引擎的性能进行对比:
>./bin/mysqlslap -a --concurrency=50,100 --number-of-queries 1000 --iterations=5 --engine=myisam,innodb --debug-info -uroot -p111111
A.本次主要是在IBM3850,备注本次测试以远程主机10.2.3.218100个并发线程、测试10次,自动生成SQL测试脚本、读、写、更新混合测试、自增长字段、测试引擎为myisam innodb、共运行10次查询,输出cpu资源信息
[root@mysql01 /]# mysqlslap -a -c 100 -i 10 --engine=myisam,innodb -h 10.2.3.218 -p3306 -uroot -payilian
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 2.305 seconds
Minimum number of seconds to run all queries: 2.290 seconds
Maximum number of seconds to run all queries: 2.317 seconds
Number of clients running queries: 100
Average number of queries per client: 0
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 2.307 seconds
Minimum number of seconds to run all queries: 2.297 seconds
Maximum number of seconds to run all queries: 2.323 seconds
Number of clients running queries: 100
Average number of queries per client: 0
B.输出100个线程并发,5次迭代,1000个客户端同时进行,增加了--number-of-queries= 200 个
[root@mysql01 /]# mysqlslap -a -c 100 -i 5 --number-of-queries= 1000 --debug-info --engine=myisam,innodb -h 10.2.3.218 -p3306 -uroot -payilian
Benchmark
Running for engine myisam
Average number of seconds to run all queries: 2.314 seconds
Minimum number of seconds to run all queries: 2.301 seconds
Maximum number of seconds to run all queries: 2.334 seconds
Number of clients running queries: 100
Average number of queries per client: 0
Benchmark
Running for engine innodb
Average number of seconds to run all queries: 2.306 seconds
Minimum number of seconds to run all queries: 2.298 seconds
Maximum number of seconds to run all queries: 2.320 seconds
Number of clients running queries: 100
Average number of queries per client: 0
User time 1.03, System time 1.85
Maximum resident set size 13592, Integral resident set size 0
Non-physical pagefaults 21177, Physical pagefaults 0, Swaps 0
Blocks in 0 out 0, Messages in 0 out 0, Signals 0
Voluntary context switches 121332, Involuntary context switches 41