sysbench是一款壓力測試工具,可以測試系統(tǒng)的硬件性能,也可以用來對數(shù)據(jù)庫進(jìn)行基準(zhǔn)測試。

安裝方式:https://github.com/akopytov/sysbench/blob/master/README.md#general-command-line-options
此處安裝的是sysbench 1.0.6版本,和網(wǎng)上大部分的0.4,0.5版本的命令不太一樣。
sysbench支持三種測試方案:
1、使用自帶的測試模塊,如對cpu,I/O,memory等的測試。
2、使用自帶的lua腳本進(jìn)行測試,如果使用快速安裝的方式,默認(rèn)的腳本路徑為:/usr/share/sysbench
3、使用自定義的lua腳本。
獲取幫助信息:
如果對相關(guān)模塊或者腳本的參數(shù)不明確的,可以使用 sysbench testname help來查看,testname含模塊名稱和腳本名稱。
sysbench經(jīng)典測試命令:
prepare: 創(chuàng)建測試數(shù)據(jù)或者相關(guān)的測試文件,為測試做準(zhǔn)備工作。如數(shù)據(jù)庫的測試數(shù)據(jù)準(zhǔn)備等。
run: 開始執(zhí)行測試。
cleanup: 移除測試數(shù)據(jù)
help: 幫助命令
測試CPU性能
sysbench cpu --cpu-max-prime=10000 run #顯示測試結(jié)果 General statistics: total time: 10.0003s total number of events: 8692 Latency (ms): min: 1.12 avg: 1.15 max: 2.98 95th percentile: 1.25 sum: 9996.64 Threads fairness: events (avg/stddev): 8692.0000/0.00 execution time (avg/stddev): 9.9966/0.00I/O測試
準(zhǔn)備測試數(shù)據(jù):
sysbench fileio --file-total-size=40G prepare運(yùn)行順序?qū)懭霚y試:
sysbench fileio --file-total-size=40G --file-test-mode=seqwr run #測試結(jié)果 File operations: reads/s: 0.00 writes/s: 3916.87 fsyncs/s: 5001.01 Throughput: read, MiB/s: 0.00 written, MiB/s: 61.20 General statistics: total time: 10.0055s total number of events: 89250 Latency (ms): min: 0.01 avg: 0.11 max: 28.02 95th percentile: 0.12 sum: 9937.24 Threads fairness: events (avg/stddev): 89250.0000/0.00 execution time (avg/stddev): 9.9372/0.00運(yùn)行順序重寫測試:
sysbench fileio --file-total-size=40G --file-test-mode=seqrewr run #測試結(jié)果: File operations: reads/s: 0.00 writes/s: 4018.65 fsyncs/s: 5131.38 Throughput: read, MiB/s: 0.00 written, MiB/s: 62.79 General statistics: total time: 10.0003s total number of events: 91531 Latency (ms): min: 0.00 avg: 0.11 max: 31.45 95th percentile: 0.10 sum: 9933.80 Threads fairness: events (avg/stddev): 91531.0000/0.00 execution time (avg/stddev): 9.9338/0.00混合隨機(jī)讀/寫:(如果執(zhí)行出錯,需要重新prepare數(shù)據(jù))
sysbench fileio --file-total-size=40G --file-test-mode=rndrw --max-time=100 --max-requests=0 run #測試結(jié)果: File operations: reads/s: 338.98 writes/s: 225.99 fsyncs/s: 722.23 Throughput: read, MiB/s: 5.30 written, MiB/s: 3.53 General statistics: total time: 100.0007s total number of events: 128727 Latency (ms): min: 0.00 avg: 0.78 max: 43.01 95th percentile: 2.97 sum: 99785.92 Threads fairness: events (avg/stddev): 128727.0000/0.00 execution time (avg/stddev): 99.7859/0.00清除測試數(shù)據(jù):
sysbench fileio --file-total-size=40G cleanupOLTP基準(zhǔn)測試
OLTP基準(zhǔn)測試模擬了一個簡單的事務(wù)處理系統(tǒng)的工作負(fù)載。若要對數(shù)據(jù)庫性能進(jìn)行測試就要使用OLTP相關(guān)的腳本。
在/usr/share/sysbench/目錄下有相關(guān)的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對于未知的測試參數(shù),可以通過 sysbench scripts-name help 來查看。
創(chuàng)建測試數(shù)據(jù):
sysbench oltp_common --table-size=1000000 --db-driver=mysql \ --mysql-db=test --mysql-user=root --mysql-password=123456 prepare Creating table 'sbtest1'... Inserting 1000000 records into 'sbtest1' Creating a secondary index on 'sbtest1'...執(zhí)行run命令進(jìn)行測試:(只讀)
sysbench oltp_read_only --table-size=1000000 --db-driver=mysql \ --mysql-db=test --mysql-user=root --mysql-password=123456 --time=60 --max-requests=0 --threads=8 run #測試結(jié)果 Running the test with following options: Number of threads: 8 Initializing random number generator from current time Initializing worker threads... Threads started! SQL statistics: queries performed: read: 1679174 write: 0 other: 239882 total: 1919056 transactions: 119941 (1998.81 per sec.) queries: 1919056 (31980.95 per sec.) ignored errors: 0 (0.00 per sec.) reconnects: 0 (0.00 per sec.) General statistics: total time: 60.0047s total number of events: 119941 Latency (ms): min: 0.32 avg: 4.00 max: 56.17 95th percentile: 8.13 sum: 479830.78 Threads fairness: events (avg/stddev): 14992.6250/116.75 execution time (avg/stddev): 59.9788/0.00除了使用read_only測試,我們還可以測試數(shù)據(jù)庫的寫性能:
sysbench oltp_write_only --table-size=1000000 --db-driver=mysql \ --mysql-db=test --mysql-user=root --mysql-password=123456 --time=60 --max-requests=0 --threads=8 run #測試結(jié)果 SQL statistics: queries performed: read: 0 write: 83764 other: 41882 total: 125646 transactions: 20941 (348.93 per sec.) queries: 125646 (2093.56 per sec.) ignored errors: 0 (0.00 per sec.) reconnects: 0 (0.00 per sec.) General statistics: total time: 60.0120s total number of events: 20941 Latency (ms): min: 4.92 avg: 22.92 max: 5518.27 95th percentile: 69.29 sum: 479968.99 Threads fairness: events (avg/stddev): 2617.6250/17.87 execution time (avg/stddev): 59.9961/0.00上面的結(jié)果中包含了很多的信息,其中重點(diǎn)需要我們關(guān)注的信息是:
1、總的事務(wù)數(shù) (total number of events)
2、每秒事務(wù)數(shù)
3、時間統(tǒng)計信息(最小,平均,大響應(yīng)時間,以及95%百分比響應(yīng)時間)
4、線程公平性統(tǒng)計信息,表示負(fù)載的公平性。(thread-fairness)
清理測試數(shù)據(jù):
sysbench oltp_read_only --table-size=1000000 --db-driver=mysql \ --mysql-db=test --mysql-user=root --mysql-password=123456 cleanup另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務(wù)可用性高、性價比高”等特點(diǎn)與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場景需求。
分享標(biāo)題:sysbench對數(shù)據(jù)庫進(jìn)行壓力測試-創(chuàng)新互聯(lián)
網(wǎng)頁地址:http://chinadenli.net/article28/gsijp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供微信公眾號、動態(tài)網(wǎng)站、移動網(wǎng)站建設(shè)、網(wǎng)站制作、全網(wǎng)營銷推廣、網(wǎng)頁設(shè)計公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)