這篇文章主要介紹了MySQL中壓測工具Sysbench1.0怎么用,具有一定借鑒價值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
創(chuàng)新互聯(lián)公司電話聯(lián)系:13518219792,為您提供成都網(wǎng)站建設網(wǎng)頁設計及定制高端網(wǎng)站建設服務,創(chuàng)新互聯(lián)公司網(wǎng)頁制作領域十載,包括茶樓設計等多個領域擁有多年設計經(jīng)驗,選擇創(chuàng)新互聯(lián)公司,為網(wǎng)站保駕護航。
一、簡介
Sysbench壓測工具常用版本有0.4(較舊),0.5(據(jù)說非官方正宗開源版),1.0(最新的官方開源版本),不同版本之間的系統(tǒng)壓測差異較小。但對數(shù)據(jù)庫的壓測參數(shù)、結果具有較大差異,這里針對sysbench壓測MYSQL數(shù)據(jù)庫做下安裝、使用介紹。
二、壓測環(huán)境
硬件環(huán)境:
測試機 | Dell PowerEdge R730xd |
CPU | Intel(R) Xeon(R) CPU E5-2620 v3 @ 2.40GHz (2物理CPU,每個6核心,每個核心2線程,總共24processor) |
內(nèi)存 | 128G |
RAID卡 | PERC H730P Mini Memory Size : 2048MB |
raid級別 | Raid-5 |
文件系統(tǒng) | xfs |
硬盤 | 4T SAS * 12 |
軟件環(huán)境:
操作系統(tǒng) | Red Hat Enterprise Linux Server release 6.5 (Santiago) |
內(nèi)核 | 2.6.32-431.el6.x86_64 |
MYSQL版本 | 5.7.17 |
壓測工具 | sysbench 1.0.3 |
三、MYSQL核心參數(shù)
四、壓測模型
測試工具 | sysbench |
測試記錄數(shù) | 1,000,000 |
測試模式 | complex |
run time(秒) | 300 |
最大請求數(shù) | 100,000 |
并發(fā)線程數(shù) | 1000 |
五、MYSQL壓測過程
以oltp_read_write.lua壓測為案例
1、sysbench2.0壓測工具安裝——請參照壓測工具之Sysbench(1_系統(tǒng)壓測)
2、sysbencholtp壓測數(shù)據(jù)準備
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、sysbencholtp壓測開始
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產(chǎn)生的壓測報告數(shù)據(jù)也與之前版本有較大差別
[ 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數(shù)量
write: 2000604 ##總update/insert/delete語句數(shù)量
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.) ##忽略的錯誤數(shù)
reconnects: 0 (0.00 per sec.)
General statistics:
totaltime: 300.3980s ##壓測總時間
total number of events: 499461 ##總事件數(shù)量,一般與transactions數(shù)值相同
Latency (ms):
min: 2.57
avg: 601.02 ##%95語句RT,平均響應時間,單位是毫秒,可通過–percentile=100調(diào)節(jié)百分比
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
備注:需要重點關注的數(shù)據(jù)有執(zhí)行總時間、TPS:如果使用-skip-trx=on,這項事務數(shù)恒為0,需要用total number of events 去除以總時間,得到tps(其實還可以分為讀tps和寫tps),QPS和RT(平均響應時間),以及系統(tǒng)壓測指標CPU、內(nèi)存、IO等。
3、sysbench oltp壓測數(shù)據(jù)清理
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、其他重要參數(shù)
--histogram[=on|off] ##是否開啟生成直方圖,默認是off
--percentile=N ##調(diào)整響應時間的百分比,默認是95
--events=N ##最大的request數(shù)值,默認是0,表示無最大事件限制,別名是--max-requests=N
--db-driver=STRING ##數(shù)據(jù)庫驅(qū)動mysql/oracle/pg
暫時簡單的做下新版本的測試使用,后續(xù)完善壓測腳本、壓測結果整理...
感謝你能夠認真閱讀完這篇文章,希望小編分享的“MySQL中壓測工具Sysbench1.0怎么用”這篇文章對大家有幫助,同時也希望大家多多支持創(chuàng)新互聯(lián),關注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關知識等著你來學習!