sysbench的安装和做性能测试

sysbench的安装和做性能测试
一、安装
# 下载源码包,按以下步骤安装
# https://launchpad.net/ubuntu/utopic/+source/sysbench 下载源码包
tar zxf sysbench-0.4.12.tar.gz 
cd sysbench-0.4.12 
# 配置。mysql的安装路径 /usr/local/mysql/
./configure --with-mysql-includes=/usr/local/mysql/include --with-mysql-libs=/usr/local/mysql/lib
# 编译
make
错误1:X--tag=CC: command not found
解决办法:vim libtool(当前目录下)
# An echo program that does not interpret backslashes.
#ECHO="echo"
替换为
echo="echo"
          http://blog.itpub.net/26250550/viewspace-1682634/
# 安装
make install

二、测试
每种测试模式的详细参数
    mode:fileio,cpu,memory,threads,mutex,oltp
    sysbench --test= help
    --num-threads=N,是每种测试都需要设置的

fileio
    sysbench --num-threads=N --test=fileio --file-test-mode=
        --num-threads=N,根据数据库的IO线程数(读写各4个,purge1个,主线程)+max_user_connections(不确定是否加这个,理论上应该不加)

        --file-test-mode=STRING       test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
            oltp使用rndrw; olap 使用seqrd; 日志:使用seqwr;
    sysbench --num-threads=10 --test=fileio --file-test-mode=rndrw prepare
    sysbench --num-threads=10 --test=fileio --file-test-mode=rndrw run
    sysbench --num-threads=10 --test=fileio --file-test-mode=rndrw cleanup
    

点击(此处)折叠或打开

  1. Operations performed: 6005 Read, 3998 Write, 12807 Other = 22810 Total
  2. Read 93.828Mb Written 62.469Mb Total transferred 156.3Mb (2.8269Mb/sec)
  3.   180.92 Requests/sec executed

  4. Test execution summary:
  5.     total time: 55.2882s
  6.     total number of events: 10003
  7.     total time taken by event execution: 116.1046
  8.     per-request statistics:
  9.          min: 0.01ms
  10.          avg: 11.61ms
  11.          max: 127.19ms
  12.          approx. 95 percentile: 45.21ms

  13. Threads fairness:
  14.     events (avg/stddev): 1000.3000/50.58
  15.     execution time (avg/stddev): 11.6105/0.22

cpu
    sysbench --num-threads=500 --test=cpu run
        --num-threads=N,根据max_user_connections

点击(此处)折叠或打开

  1. Test execution summary:
  2.     total time: 2.7773s
  3.     total number of events: 10000
  4.     total time taken by event execution: 929.5525
  5.     per-request statistics:
  6.          min: 1.10ms
  7.          avg: 92.96ms
  8.          max: 1990.11ms
  9.          approx. 95 percentile: 524.92ms

  10. Threads fairness:
  11.     events (avg/stddev): 20.0000/15.88
  12.     execution time (avg/stddev): 1.8591/0.52

memory
    sysbench --num-threads=500 --test=memory --memory-block-size=16K run
        --num-threads=N,根据max_user_connections
        --memory-block-size= 16K, 与页大小一致
        --memory-oper=write|read,测试不同模式下的速度
    

点击(此处)折叠或打开

  1. Operations performed: 6553600 (144538.32 ops/sec)

  2. 102400.00 MB transferred (2258.41 MB/sec)


  3. Test execution summary:
  4.     total time: 45.3416s
  5.     total number of events: 6553600
  6.     total time taken by event execution: 17959.0829
  7.     per-request statistics:
  8.          min: 0.00ms
  9.          avg: 2.74ms
  10.          max: 1360.60ms
  11.          approx. 95 percentile: 0.03ms

  12. Threads fairness:
  13.     events (avg/stddev): 13107.2000/394.74
  14.     execution time (avg/stddev): 35.9182/0.88

mutex
    sysbench --num-threads=500 --test=mutex run
        --num-threads=N,根据max_user_connections    

点击(此处)折叠或打开

  1. Test execution summary:
  2.     total time: 4.3611s
  3.     total number of events: 100
  4.     total time taken by event execution: 432.1235
  5.     per-request statistics:
  6.          min: 4148.02ms
  7.          avg: 4321.24ms
  8.          max: 4356.73ms
  9.          approx. 95 percentile: 4350.67ms

  10. Threads fairness:
  11.     events (avg/stddev): 1.0000/0.00
  12.     execution time (avg/stddev): 4.3212/0.03

threads

    sysbench --num-threads=500 --test=threads run    

点击(此处)折叠或打开

  1. Test execution summary:
  2.     total time: 3.3147s
  3.     total number of events: 10000
  4.     total time taken by event execution: 329.1616
  5.     per-request statistics:
  6.          min: 0.53ms
  7.          avg: 32.92ms
  8.          max: 228.56ms
  9.          approx. 95 percentile: 85.67ms

  10. Threads fairness:
  11.     events (avg/stddev): 100.0000/4.70
  12.     execution time (avg/stddev): 3.2916/0.01

oltp
    1:oltp: 500线程,innodb表,最大100W行数据

    sysbench --num-threads=500 --test=oltp --oltp-test-mode=complex --mysql-host=localhost --mysql-user=sbtest --mysql-password=sbtest --mysql-db=test_sb --oltp-table-size=1000000  prepare
        --num-threads=N,根据max_user_connections
        --oltp-test-mode=complex,使用混合测试
    sysbench --num-threads=500 --test=oltp --oltp-test-mode=complex --mysql-host=localhost --mysql-user=sbtest --mysql-password=sbtest --mysql-db=test_sb --oltp-table-size=1000000  run
    sysbench --num-threads=500 --test=oltp --oltp-test-mode=complex --mysql-host=localhost --mysql-user=sbtest --mysql-password=sbtest --mysql-db=test_sb --oltp-table-size=1000000  cleanup
    

点击(此处)折叠或打开

  1. OLTP test statistics:
  2. queries performed:
  3. read: 145194
  4. write: 50922
  5. other: 20374
  6. total: 216490
  7. transactions: 10003 (372.70 per sec.)
  8. deadlocks: 368 (13.71 per sec.)
  9. read/write requests: 196116 (7307.05 per sec.)
  10. other operations: 20374 (759.11 per sec.)
  11. Test execution summary:
  12. total time: 26.8393s
  13. total number of events: 10003
  14. total time taken by event execution: 2679.0895
  15. per-request statistics:
  16. min: 40.40ms
  17. avg: 267.83ms
  18. max: 1712.27ms
  19. approx. 95 percentile: 566.22ms
  20. Threads fairness:
  21. events (avg/stddev): 100.0300/4.68
  22. execution time (avg/stddev): 26.7909/0.03


请使用浏览器的分享功能分享到微信等