ITPub博客

首页 > 数据库 > MySQL > sysbench 压力测试

sysbench 压力测试

原创 MySQL 作者:wwjfeng 时间:2018-04-24 20:37:20 0 删除 编辑

一.安装
./autogen.sh
./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
make
make install

ls -l /usr/local/mysql/lib/libmysqlclient.so.20*
ln -s /usr/local/mysql/lib/libmysqlclient.so.20 /usr/lib/
vi /etc/ld.so.conf
export LD_LIBRARY_PATH=/usr/local/mysql/lib
ldconfig

二.压力测试
1.查看帮助
sysbench --help
--mysql-host IP
--mysql-port 端口号
--mysql-db 希望链接的数据库
--mysql-user 用户名
--mysql-password 密码
--table_size 每张表初始化的数据数量
--tables 初始化表的数量
--threads 启动的线程(链接数据库的连接数,并发数)
--time 运行时间
--report-interval 运行期间日志,单位为秒

2.准备测试数据
cd /usr/local/share/sysbench
sysbench oltp_read_write.lua --mysql-host=109.115.12.40 --mysql-port=3306 --mysql-db=wwj --mysql-user=root --mysql-password=root --table_size=50000 --tables=10 --threads=50 --time=120 --report-interval=10 prepare

点击(此处)折叠或打开

  1. sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
  2. Initializing worker threads...
  3. Creating table 'sbtest6'...
  4. Creating table 'sbtest5'...
  5. Creating table 'sbtest2'...
  6. Creating table 'sbtest9'...
  7. Creating table 'sbtest3'...
  8. Creating table 'sbtest10'...
  9. Creating table 'sbtest4'...
  10. Creating table 'sbtest8'...
  11. Creating table 'sbtest1'...
  12. Creating table 'sbtest7'...
  13. Inserting 50000 records into 'sbtest3'
  14. Inserting 50000 records into 'sbtest4'
  15. Inserting 50000 records into 'sbtest6'
  16. Inserting 50000 records into 'sbtest8'
  17. Inserting 50000 records into 'sbtest10'
  18. Inserting 50000 records into 'sbtest5'
  19. Inserting 50000 records into 'sbtest2'
  20. Inserting 50000 records into 'sbtest1'
  21. Inserting 50000 records into 'sbtest7'
  22. Inserting 50000 records into 'sbtest9'
  23. Creating a secondary index on 'sbtest6'...
  24. Creating a secondary index on 'sbtest4'...
  25. Creating a secondary index on 'sbtest3'...
  26. Creating a secondary index on 'sbtest2'...
  27. Creating a secondary index on 'sbtest8'...
  28. Creating a secondary index on 'sbtest10'...
  29. Creating a secondary index on 'sbtest9'...
  30. Creating a secondary index on 'sbtest7'...
  31. Creating a secondary index on 'sbtest1'...
  32. Creating a secondary index on 'sbtest5'...

3.进行压力测试
sysbench oltp_read_write.lua --mysql-host=109.115.12.40 --mysql-port=3306 --mysql-db=wwj --mysql-user=root --mysql-password=root --table_size=50000 --tables=10 --threads=50 --time=120 --report-interval=10 run

点击(此处)折叠或打开

  1. sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)

  2. Running the test with following options:
  3. Number of threads: 50
  4. Report intermediate results every 10 second(s)
  5. Initializing random number generator from current time

  6. Initializing worker threads...

  7. Threads started!
  8. [ 10s ] thds: 50 tps: 155.35 qps: 3120.70 (r/w/o: 2183.67/621.42/315.61) lat (ms,95%): 657.93 err/s: 0.00 reconn/s: 0.00
  9. [ 20s ] thds: 50 tps: 177.91 qps: 3638.51 (r/w/o: 2552.04/730.54/355.92) lat (ms,95%): 458.96 err/s: 0.00 reconn/s: 0.00
  10. [ 30s ] thds: 50 tps: 183.40 qps: 3612.40 (r/w/o: 2530.63/714.98/366.79) lat (ms,95%): 397.39 err/s: 0.00 reconn/s: 0.00
  11. [ 40s ] thds: 50 tps: 178.81 qps: 3617.02 (r/w/o: 2530.69/728.92/357.41) lat (ms,95%): 450.77 err/s: 0.00 reconn/s: 0.00
  12. [ 50s ] thds: 50 tps: 186.90 qps: 3730.97 (r/w/o: 2620.78/736.19/374.00) lat (ms,95%): 376.49 err/s: 0.00 reconn/s: 0.00
  13. [ 60s ] thds: 50 tps: 175.20 qps: 3514.82 (r/w/o: 2456.41/708.00/350.40) lat (ms,95%): 493.24 err/s: 0.00 reconn/s: 0.00
  14. [ 70s ] thds: 50 tps: 181.20 qps: 3622.46 (r/w/o: 2533.97/726.19/362.30) lat (ms,95%): 450.77 err/s: 0.00 reconn/s: 0.00
  15. [ 80s ] thds: 50 tps: 182.80 qps: 3650.66 (r/w/o: 2553.14/732.21/365.31) lat (ms,95%): 411.96 err/s: 0.00 reconn/s: 0.00
  16. [ 90s ] thds: 50 tps: 174.50 qps: 3497.29 (r/w/o: 2452.29/695.60/349.40) lat (ms,95%): 458.96 err/s: 0.00 reconn/s: 0.00
  17. [ 100s ] thds: 50 tps: 176.60 qps: 3500.17 (r/w/o: 2449.15/697.81/353.21) lat (ms,95%): 484.44 err/s: 0.00 reconn/s: 0.00
  18. [ 110s ] thds: 50 tps: 183.27 qps: 3691.17 (r/w/o: 2590.33/734.29/366.55) lat (ms,95%): 427.07 err/s: 0.00 reconn/s: 0.00
  19. [ 120s ] thds: 50 tps: 192.22 qps: 3839.88 (r/w/o: 2688.36/767.18/384.34) lat (ms,95%): 356.70 err/s: 0.00 reconn/s: 0.00
  20. SQL statistics:
  21. queries performed:
  22. read: 301448 #读总数
  23. write: 86128。 #写总数
  24. other: 43064。 #其他操作
  25. total: 430640。 #总操作数
  26. transactions: 21532 (179.11 per sec.)。 #tps每秒事务数
  27. queries: 430640 (3582.15 per sec.)。
  28. ignored errors: 0 (0.00 per sec.)
  29. reconnects: 0 (0.00 per sec.)
  30. Throughput:
  31. events/s (eps): 179.1074。
  32. time elapsed: 120.2184s。
  33. total number of events: 21532

  34. Latency (ms):
  35. min: 22.17
  36. avg: 278.93
  37. max: 2276.44
  38. 95th percentile: 450.77
  39. sum: 6005874.20

  40. Threads fairness:
  41. events (avg/stddev): 430.6400/8.04
  42. execution time (avg/stddev): 120.1175/0.03


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

上一篇: mysql GTID
全部评论

注册时间:2010-03-27

  • 博文量
    147
  • 访问量
    120366