您好,登錄后才能下訂單哦!
這篇文章主要介紹了MySQL中壓測工具Sysbench1.0怎么用,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
一、簡介
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、sysbench2.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
點擊(此處)折疊或打開
[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
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Initializing worker threads...
Creating table 'sbtest7'...Creating table 'sbtest6'...
Creating table 'sbtest2'...
Creating table 'sbtest10'...
Creating table 'sbtest8'...
Creating table 'sbtest1'...
Creating table 'sbtest4'...
Creating table 'sbtest3'...
Creating table 'sbtest5'...
Creating table 'sbtest9'...
Inserting 1000000 records into 'sbtest3'
Inserting 1000000 records into 'sbtest8'
Inserting 1000000 records into 'sbtest2'
Inserting 1000000 records into 'sbtest6'
Inserting 1000000 records into 'sbtest10'
Inserting 1000000 records into 'sbtest7'
Inserting 1000000 records into 'sbtest1'
Inserting 1000000 records into 'sbtest5'
Inserting 1000000 records into 'sbtest9'
Inserting 1000000 records into 'sbtest4'
Creating a secondary index on 'sbtest1'...
Creating a secondary index on 'sbtest7'...
Creating a secondary index on 'sbtest5'...
Creating a secondary index on 'sbtest3'...
Creating a secondary index on 'sbtest4'...
Creating a secondary index on 'sbtest9'...
Creating a secondary index on 'sbtest6'...
Creating a secondary index on 'sbtest10'...
Creating a secondary index on 'sbtest2'...
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
點擊(此處)折疊或打開
[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
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 1000
Report intermediate results every 10 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
##下面每隔10S產生的壓測報告數據也與之前版本有較大差別
[ 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
[ 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
[ 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
...
...
[ 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
[ 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
[ 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
SQL statistics:
queries performed:
read: 7030618 ##總select數量
write: 2000604 ##總update/insert/delete語句數量
other: 1001648 ##包含commit/unlock tables以及其他mutex語句
total: 10032870
transactions: 499461 (1662.65 per sec.) ##TPS
queries: 10032870 (33398.37 per sec.) ##QPS
ignored errors: 2726 (9.07 per sec.) ##忽略的錯誤數
reconnects: 0 (0.00 per sec.)
General statistics:
total time: 300.3980s ##壓測總時間
total number of events: 499461 ##總事件數量,一般與transactions數值相同
Latency (ms):
min: 2.57
avg: 601.02 ##%95語句RT,平均響應時間,單位是毫秒,可通過–percentile=100調節百分比
max: 13302.01
95th percentile: 1739.68
sum: 300186288.55
Threads fairness:
events (avg/stddev): 499.4610/27.20
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
點擊(此處)折疊或打開
[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
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Dropping table 'sbtest1'...
Dropping table 'sbtest2'...
Dropping table 'sbtest3'...
Dropping table 'sbtest4'...
Dropping table 'sbtest5'...
Dropping table 'sbtest6'...
Dropping table 'sbtest7'...
Dropping table 'sbtest8'...
Dropping table 'sbtest9'...
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
暫時簡單的做下新版本的測試使用,后續完善壓測腳本、壓測結果整理...
感謝你能夠認真閱讀完這篇文章,希望小編分享的“MySQL中壓測工具Sysbench1.0怎么用”這篇文章對大家有幫助,同時也希望大家多多支持億速云,關注億速云行業資訊頻道,更多相關知識等著你來學習!
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。