壓測工具之Sysbench1.0(2_MySQL壓測)

yepkeepmoving發表於2017-03-12
一、簡介
Sysbench壓測工具常用版本有0.4(較舊),0.5(據說非官方正宗開源版),1.0(最新的官方開源版本),不同版本之間的系統壓測差異較小。但對資料庫的壓測引數、結果具有較大差異,這裡針對sysbench壓測MYSQL資料庫做下安裝、使用介紹。
二、壓測環境
硬體環境:

測試機

Dell PowerEdge R730xd

CPU

Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz (2物理CPU,每個6核心,每個核心2執行緒,總共24processor)

記憶體

128G

RAID

PERC H730P Mini

Memory Size  : 2048MB

raid級別

Raid-5

檔案系統

xfs

硬碟

4T SAS * 12

軟體環境:

作業系統

Red Hat Enterprise Linux Server release 6.5 (Santiago)

核心

2.6.32-431.el6.x86_64

MYSQL版本

5.7.17

壓測工具

sysbench 1.0.3

三、MYSQL核心引數

四、壓測模型

測試工具

sysbench

測試記錄數

1,000,000

測試模式

complex

run time()

300

最大請求數

100,000

併發執行緒數

1000

五、MYSQL壓測過程
oltp_read_write.lua壓測為案例

1、sysbench1.0壓測工具安裝——請參照壓測工具之Sysbench(1_系統壓測
2、sysbench oltp壓測資料準備
sysbench /usr/local/sysbench/share/sysbench/oltp_read_write.lua --mysql-host=10.1.0.10 --mysql-port=3306 --mysql-user=dbuser --mysql-password=abc.1234 --mysql-db=dbtest --tables=10 --table-size=1000000 --report-interval=10 --threads=1000 --time=300 prepare

點選(此處)摺疊或開啟

  1. [root@DB_TEST sysbench]# sysbench /usr/local/sysbench/share/sysbench/oltp_read_write.lua --mysql-host=10.1.0.10 --mysql-port=3306 --mysql-user=dbuser --mysql-password=abc.1234 --mysql-db=dbtest --tables=10 --table-size=1000000 --report-interval=10 --threads=1000 --time=300 prepare
  2. sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)

  3. Initializing worker threads...

  4. Creating table 'sbtest7'...Creating table 'sbtest6'...

  5. Creating table 'sbtest2'...
  6. Creating table 'sbtest10'...
  7. Creating table 'sbtest8'...
  8. Creating table 'sbtest1'...
  9. Creating table 'sbtest4'...
  10. Creating table 'sbtest3'...
  11. Creating table 'sbtest5'...
  12. Creating table 'sbtest9'...
  13. Inserting 1000000 records into 'sbtest3'
  14. Inserting 1000000 records into 'sbtest8'
  15. Inserting 1000000 records into 'sbtest2'
  16. Inserting 1000000 records into 'sbtest6'
  17. Inserting 1000000 records into 'sbtest10'
  18. Inserting 1000000 records into 'sbtest7'
  19. Inserting 1000000 records into 'sbtest1'
  20. Inserting 1000000 records into 'sbtest5'
  21. Inserting 1000000 records into 'sbtest9'
  22. Inserting 1000000 records into 'sbtest4'
  23. Creating a secondary index on 'sbtest1'...
  24. Creating a secondary index on 'sbtest7'...
  25. Creating a secondary index on 'sbtest5'...
  26. Creating a secondary index on 'sbtest3'...
  27. Creating a secondary index on 'sbtest4'...
  28. Creating a secondary index on 'sbtest9'...
  29. Creating a secondary index on 'sbtest6'...
  30. Creating a secondary index on 'sbtest10'...
  31. Creating a secondary index on 'sbtest2'...
  32. Creating a secondary index on 'sbtest8'...
2、sysbench oltp壓測開始
sysbench /usr/local/sysbench/share/sysbench/oltp_read_write.lua     --mysql-host=10.1.0.10 --mysql-port=3306 --mysql-user=dbuser --mysql-password=abc.1234     --mysql-db=dbtest --tables=10 --table-size=1000000     --report-interval=10     --threads=1000 --time=300   run

點選(此處)摺疊或開啟

  1. [root@DB_TEST sysbench]# sysbench /usr/local/sysbench/share/sysbench/oltp_read_write.lua --mysql-host=10.1.0.10 --mysql-port=3306 --mysql-user=dbuser --mysql-password=abc.1234 --mysql-db=dbtest --tables=10 --table-size=1000000 --report-interval=10 --threads=1000 --time=300 run
  2. sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)

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


  7. Initializing worker threads...

  8. Threads started!
  9. ##下面每隔10S產生的壓測報告資料也與之前版本有較大差別
  10. [ 10s ] thds: 1000 tps: 1290.73 qps: 27199.93 (r/w/o: 19259.14/5258.29/2682.51) lat (ms,95%): 2680.11 err/s: 1.30 reconn/s: 0.00
  11. [ 20s ] thds: 1000 tps: 1291.33 qps: 25644.68 (r/w/o: 17913.30/5146.02/2585.36) lat (ms,95%): 2120.76 err/s: 2.70 reconn/s: 0.00
  12. [ 30s ] thds: 1000 tps: 1749.09 qps: 34514.35 (r/w/o: 24078.49/6932.57/3503.28) lat (ms,95%): 1258.08 err/s: 5.10 reconn/s: 0.00
  13. ...
  14. ...
  15. [ 280s ] thds: 1000 tps: 1608.70 qps: 32380.81 (r/w/o: 22645.91/6509.20/3225.70) lat (ms,95%): 2680.11 err/s: 8.30 reconn/s: 0.00
  16. [ 290s ] thds: 1000 tps: 1441.71 qps: 28987.87 (r/w/o: 20274.92/5823.03/2889.92) lat (ms,95%): 1803.47 err/s: 6.50 reconn/s: 0.00
  17. [ 300s ] thds: 1000 tps: 1794.92 qps: 36050.03 (r/w/o: 25318.80/7126.59/3604.64) lat (ms,95%): 3639.94 err/s: 14.80 reconn/s: 0.00
  18. SQL statistics:
  19.     queries performed:
  20.         read: 7030618                          ##總select數量
  21.         write: 2000604                         ##總update/insert/delete語句數量
  22.         other: 1001648                         ##包含commit/unlock tables以及其他mutex語句
  23.         total: 10032870
  24.     transactions: 499461 (1662.65 per sec.)    ##TPS
  25.     queries: 10032870 (33398.37 per sec.)      ##QPS
  26.     ignored errors: 2726 (9.07 per sec.)       ##忽略的錯誤數
  27.     reconnects: 0 (0.00 per sec.)

  28. General statistics:
  29.     total time: 300.3980s                      ##壓測總時間
  30.     total number of events: 499461             ##總事件數量,一般與transactions數值相同

  31. Latency (ms):
  32.          min: 2.57
  33.          avg: 601.02                           ##%95語句RT,平均響應時間,單位是毫秒,可透過–percentile=100調節百分比
  34.          max: 13302.01
  35.          95th percentile: 1739.68             
  36.          sum: 300186288.55

  37. Threads fairness:
  38.     events (avg/stddev): 499.4610/27.20
  39.     execution time (avg/stddev): 300.1863/0.07
備註:需要重點關注的資料有執行總時間、TPS:如果使用-skip-trx=on,這項事務數恆為0,需要用total number of events 去除以總時間,得到tps(其實還可以分為讀tps和寫tps),QPS和RT(平均響應時間),以及系統壓測指標CPU、記憶體、IO等。
3、sysbench oltp壓測資料清理
sysbench /usr/local/sysbench/share/sysbench/oltp_read_write.lua --mysql-host=10.1.0.10 --mysql-port=3306 --mysql-user=dbuser --mysql-password=abc.1234 --mysql-db=dbtest --tables=10 --table-size=1000000 --report-interval=10 --threads=1000 --time=300 cleanup

點選(此處)摺疊或開啟

  1. [root@DB_TEST sysbench]# sysbench /usr/local/sysbench/share/sysbench/oltp_read_write.lua --mysql-host=10.1.0.10 --mysql-port=3306 --mysql-user=dbuser --mysql-password=abc.1234 --mysql-db=dbtest --tables=10 --table-size=1000000 --report-interval=10 --threads=1000 --time=300 cleanup
  2. sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)

  3. Dropping table 'sbtest1'...
  4. Dropping table 'sbtest2'...
  5. Dropping table 'sbtest3'...
  6. Dropping table 'sbtest4'...
  7. Dropping table 'sbtest5'...
  8. Dropping table 'sbtest6'...
  9. Dropping table 'sbtest7'...
  10. Dropping table 'sbtest8'...
  11. Dropping table 'sbtest9'...
  12. Dropping table 'sbtest10'...
六、MYSQL壓測附錄
1、壓測lua指令碼
bulk_insert.lua
oltp_common.lua
oltp_delete.lua
oltp_insert.lua
oltp_point_select.lua
oltp_read_only.lua
oltp_read_write.lua
oltp_update_index.lua
oltp_update_non_index.lua
oltp_write_only.lua
select_random_points.lua
select_random_ranges.lua
2、他重要引數
--histogram[=on|off]  ##是否開啟生成直方圖,預設是off
--percentile=N           ##調整響應時間的百分比,預設是95
--events=N               ##最大的request數值,預設是0,表示無最大事件限制,別名是--max-requests=N
--db-driver=STRING    ##資料庫驅動mysql/oracle/pg
暫時簡單的做下新版本的測試使用,後續完善壓測指令碼、壓測結果整理...

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27067062/viewspace-2135183/,如需轉載,請註明出處,否則將追究法律責任。

相關文章