2周測試后,導致以下結果
MySQL-OLTP測試結果:(50表。每個表1000廣域網數據,1000個線程)
TPS:MySQL在PCIe固態存儲上執行是在HDD上執行的5.63倍
writes:MySQL在PCIe固態存儲上執行是在HDD上執行的5.58倍
reads:MySQL在PCIe固態存儲上執行是在HDD上執行的5.55倍
Response_time:MySQL在PCIe固態存儲上執行比在HDD上執行響應時間快44.45倍
Errors:MySQL在PCIe固態存儲上執行是在HDD上執行錯誤率低83.5倍
隨機IO測試結論:
PCIe固態存儲隨機讀寫IO處理能力是HDD隨機讀寫IO處理能力的20倍
下面是具體測試過程
准備工作
操作系統:CentOS6.4 64位
D B:MySQL5.6.22 64位
硬 盤:PCIe(Shannon Direct-IO 1.6TB)、HDD
測試工具:sysbench0.5
監控工具:zabix
一、安裝sysbench 0.5
同一時候0.5相比0.4須要消耗很多其它的cpu資源。
下載sysbench源代碼包
原來官網 http://sysbench.sourceforge.net 已停用。眼下sysbench代碼托管在launchpad上https://launchpad.net/sysbench
更新和安裝依賴包
yum -y install gcc yum -y install libtool
安裝bzrclient
yum -y install bzr
在線獲取0.5的版本號,#下載到當前文件夾,文件名稱為: sysbench_0.5
bzr branch lp:sysbench cd sysbench_0.5/
執行命令:./autogen.sh,對環境進行清理
./autogen.sh
./configure --with-mysql-includes=/usr/local/mysqla/include/ --with-mysql-libs=/usr/local/mysqla/lib/
# with-mysql-includes 指定MySQL安裝文件夾
# with-mysql-libs 指定MySQL lib所在文件夾
make && make install
假設遇到下面錯誤
../libtool: line 841: X--tag=CC: command not found ../libtool: line 874: libtool: ignoring unknown tag : command not found ../libtool: line 841: X--mode=link: command not found ../libtool: line 1007: *** Warning: inferring the mode of operation is deprecated.: command not found ../libtool: line 1008: *** Future versions of Libtool will require --mode=MODE be specified.: command not found ../libtool: line 2234: X-g: command not found ../libtool: line 2234: X-O2: command not found ../libtool: line 1954: X-L/usr/local/mysqla/lib/: No such file or directory ../libtool: line 2403: Xsysbench: command not found ../libtool: line 2408: X: command not found ../libtool: line 2415: Xsysbench: command not found ../libtool: line 2550: X-lmysqlclient_r: command not found ../libtool: line 2550: X-lrt: command not found ../libtool: line 2550: X-lm: command not found ../libtool: line 2632: X-L/home/sysopt/src/sysbench-0.4.12/sysbench: No such file or directory ../libtool: line 2550: X-lmysqlclient_r: command not found ../libtool: line 2550: X-lrt: command not found ../libtool: line 2550: X-lm: command not found ../libtool: line 2632: X-L/home/sysopt/src/sysbench-0.4.12/sysbench: No such file or directory ../libtool: line 2550: X-lmysqlclient_r: command not found ../libtool: line 2550: X-lrt: command not found ../libtool: line 2550: X-lm: command not found
可能原因:
1、沒裝依賴包libtool
2、安裝的版本號不正確(libtool版本號過舊)
3、其他原因
解決方法:
1、安裝依賴包libtool
2、libtoo更新到新版本號
3、用autoreconf取代autogen.sh,方法例如以下:
autoreconf -i configure make make install
成功安裝后可通過help命令查看sysbench幫助
[root@localhost src]# sysbench --help Missing required command argument. Usage: sysbench [general-options]... --test=<test-name> [test-options]... command General options: --num-threads=N number of threads to use [1]#使用線程數量 --max-requests=N limit for total number of requests [10000]#請求數,默覺得10000 --max-time=N limit for total execution time in seconds [0]#執行時間。默覺得0表示表示不限制 --forced-shutdown=STRING amount of time to wait after --max-time before forcing shutdown [off] --thread-stack-size=SIZE size of stack per thread [64K] --tx-rate=N target transaction rate (tps) [0] --report-interval=N periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]#0.5的新增參數(默認值0,表示禁用該功能)在指定的時間間隔報告測試信息,<span style="font-size:12px;">不用等到執行結束時再得到反饋</span> --report-checkpoints=[LIST,...]dump full statistics and reset all counters at specified points in time. The argument is a list of comma-separated values representing the amount of time in seconds elapsed from start of test when report checkpoint(s) must be performed. Report checkpoints are off by default. [] --test=STRING test to run --debug=[on|off] print more debugging info [off] --validate=[on|off] perform validation checks where possible [off] --help=[on|off] print help and exit --version=[on|off] print version and exit [off] --rand-init=[on|off] initialize random number generator [off]#初始化時生成隨機的數據。默認關閉 --rand-type=STRING random numbers distribution {uniform,gaussian,special,pareto} [special] --rand-spec-iter=N number of iterations used for numbers generation [12] --rand-spec-pct=N percentage of values to be treated as 'special' (for special distribution) [1] --rand-spec-res=N percentage of 'special' values to use (for special distribution) [75] --rand-seed=N seed for random number generator, ignored when 0 [0] --rand-pareto-h=N parameter h for pareto distibution [0.2] Log options: --verbosity=N verbosity level {5 - debug, 0 - only critical messages} [3] --percentile=N percentile rank of query response times to count [95] Compiled-in tests:測試項目 fileio - File I/O test #磁盤IO測試 cpu - CPU performance test #CPU運算性能 memory - Memory functions speed test #內存分配及傳輸速度 threads - Threads subsystem performance test #POSIX線程性能 mutex - Mutex performance test #相互排斥性能測試 Commands: prepare run cleanup help version See 'sysbench --test=<name> help' for a list of options for each test.
二、測試
1.MySQL-OLTP測試
數據准備
[root@localhost sysbench_0.5]# sysbench --mysql-db=sbtest --num-threads=24 --mysql-engine-trx=yes --mysql-table-engine=innodb --rand-type=special --mysql-host=localhost --mysql-port=3307 --mysql-user=root --mysql-password= --mysql-socket=/data1/lib/mysql/mysql.sock --test=sysbench/tests/db/oltp.lua --oltp_tables_count=50 --oltp-table-size=10000000 --rand-init=on prepare
參數說明:
--mysql-db:指定在哪個數據庫創建測試表。默覺得sbtest庫,須要提前創建好
--num-threads:使用多線程創建多表,節省准備時間
--mysql-engine-trx=yes 支持事務
--mysql-table-engine:指定存儲引擎,如myisam。innodb,heap,ndbcluster,bdb,maria,falcon,pbxt 默認InnoDB
--test=tests/db/oltp.lua 表示調用 tests/db/oltp.lua 腳本進行 oltp 模式測試
--oltp_tables_count=10 表示會生成 10 個測試表
--oltp-table-size=1000000 表示每一個測試表填充數據量為 1000000
--db-driver:指定驅動,默覺得Mysql
--rand-init=on 表示每一個測試表都是用隨機數據來填充的
#使用1000個線程開始測試,讀寫模式。
模擬 對50個表並發OLTP測試,每一個表1000萬行記錄,持續壓測時間為 1小時
[root@localhost sysbench_0.5]# sysbench --mysql-engine-trx=yes --mysql-table-engine=innodb --mysql-host=localhost --mysql-port=3307 --mysql-user=root --mysql-password= --mysql-socket=/data1/lib/mysql/mysql.sock --test=sysbench/tests/db/oltp.lua --oltp_tables_count=50 --oltp-table-size=100000000 --num-threads=1000 --oltp-read-only=off --report-interval=10 --rand-type=uniform --max-time=3600 --max-requests=0 --percentile=95 run >>/data1/sysbench-rw.txt
參數說明
--oltp-read-only=off 表示不要進行僅僅讀測試,也就是會採用讀寫混合模式測試
--report-interval=10 表示每10秒輸出一次測試進度報告
--rand-type=uniform:數據分布模式,special表示存在熱點數據,uniform表示非熱點數據模式: uniform(固定),gaussian(高斯),special(特定的),pareto(帕累托)
--max-time=3600 表示最大運行時長為 3600秒
--max-requests=0 表示總請求數為 0,由於上面已經定義了總運行時長,所以總請求數能夠設定為 0;也能夠僅僅設定總請求數,不設定最大運行時長
--percentile=95 表示設定採樣比例。默認是 95%,即丟棄5%的長請求。在剩余的95%里取最大值
可選參數:
--oltp-point-selects:在一個事務里面Point select的數量,默覺得10
--oltp-range-size:range查詢的范圍大小。默認100。應該小於oltp-table-size
--oltp-simple-ranges:在一個事務里面簡單range查詢的數量,默認1
--oltp-sum-ranges:在一個事務里面SUM range查詢的數量,默認1
--oltp-order-ranges:在一個事務里面ORDER range查詢的數量。默認1
--oltp-distinct-ranges:在一個事務里面DISTINCT range查詢的數量,默認1
注意:我這里將測試中輸出信息存放到一個文本文件中。便於用監控展示成圖表形式,這樣更直觀
監控結果:
PCIe固態存儲-IO
HDD-IO
PCIe固態存儲-TPS
HDD-TPS
PCIe固態存儲-writes
HDD-Writes
PCIe固態存儲-reads
HDD-Reads
PCIe固態存儲-Response-time
HDD-Response_time
PCIe固態存儲-errors
HDD-Errors
結論:(監控參數同樣的情況下--oltp_tables_count=50 --oltp-table-size=100000000 --num-threads=1000 --oltp-read-only=off --rand-type=uniform )
TPS:MySQL在PCIe固態存儲上執行是在HDD上執行的5.63倍
writes:MySQL在PCIe固態存儲上執行是在HDD上執行的5.58倍
reads:MySQL在PCIe固態存儲上執行是在HDD上執行的5.55倍
Response_time:MySQL在PCIe固態存儲上執行比在HDD上執行響應時間快44.45倍
Errors:MySQL在PCIe固態存儲上執行是在HDD上執行錯誤率低83.5倍
2、隨機IO測試(這里就不再上圖了)
數據准備(創建70G文件)注意:文件大小須要大於內存大小
sysbench --test=fileio --file-total-size=70G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 prepare
測試階段
sysbench --test=fileio --file-total-size=70G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run
清楚測試數據
sysbench --test=fileio --file-total-size=70G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 clean
隨機讀寫混合
PCIe固態存儲
Operations performed: 1789098 reads, 1192732 writes, 3816704 Other= 6798534 Total
Read 27.299Gb Written 18.2Gb Total transferred 45.499Gb (155.3Mb/sec)
9939.43 Requests/sec executed
General statistics:
total time: 300.0001s
total number of events: 2981830
total time taken by event execution: 214.9376s
response time:
min: 0.00ms
avg: 0.07ms
max: 7.26ms
approx. 95 percentile: 0.23ms
Threads fairness:
events (avg/stddev): 2981830.0000/0.00
execution time (avg/stddev): 214.9376/0.00
HDD
Operations performed: 85851 reads, 57234 writes, 183040 Other =326125 Total
Read 1.31Gb Written 894.28Mb Totaltransferred 2.1833Gb (7.4523Mb/sec)
476.95 Requests/sec executed
General statistics:
total time: 300.0024s
total number of events: 143085
total time taken by event execution: 291.8164s
response time:
min: 0.01ms
avg: 2.04ms
max: 170.33ms
approx. 95 percentile: 5.22ms
Threads fairness:
events (avg/stddev): 143085.0000/0.00
execution time (avg/stddev): 291.8164/0.00
隨機寫
PCIe固態存儲
Operations performed: 0 reads, 10441500 writes, 13365074 Other =23806574 Total
Read 0b Written 159.32Gb Totaltransferred 159.32Gb (271.91Mb/sec)
17402.24 Requests/sec executed
General statistics:
total time: 600.0090s
total number of events: 10441500
total time taken by event execution: 168.8168s
response time:
min: 0.00ms
avg: 0.02ms
max: 0.71ms
approx. 95 percentile: 0.02ms
Threads fairness:
events (avg/stddev): 10441500.0000/0.00
execution time(avg/stddev): 168.8168/0.00
HDD
Operationsperformed: 0 reads, 427200 writes,546689 Other = 973889 Total
Read 0b Written 6.5186Gb Total transferred 6.5186Gb (11.125Mb/sec)
712.00 Requests/sec executed
Generalstatistics:
total time: 600.0002s
total number of events: 427200
total time taken by event execution:10.5053s
response time:
min: 0.01ms
avg: 0.02ms
max: 29.30ms
approx. 95 percentile: 0.03ms
Threadsfairness:
events (avg/stddev): 427200.0000/0.00
execution time (avg/stddev): 10.5053/0.00
隨機讀
PCIe固態存儲
Operationsperformed: 3898994 reads, 0 writes, 0Other = 3898994 Total
Read59.494Gb Written 0b Total transferred 59.494Gb (203.07Mb/sec)
12996.64Requests/sec executed
Generalstatistics:
total time: 300.0001s
total number of events: 3898994
total time taken by event execution:294.7603s
response time:
min: 0.00ms
avg: 0.08ms
max: 30.09ms
approx. 95 percentile: 0.24ms
Threadsfairness:
events (avg/stddev): 3898994.0000/0.00
execution time (avg/stddev): 294.7603/0.00
HDD
Operationsperformed: 131643 reads, 0 writes, 0Other = 131643 Total
Read2.0087Gb Written 0b Total transferred 2.0087Gb (6.8564Mb/sec)
438.81 Requests/sec executed
Generalstatistics:
total time: 300.0014s
total number of events: 131643
total time taken by event execution:299.7703s
response time:
min: 0.00ms
avg: 2.28ms
max: 121.94ms
approx. 95 percentile: 5.34ms
Threadsfairness:
events (avg/stddev): 131643.0000/0.00
execution time (avg/stddev): 299.7703/0.00
結論:
PCIe固態存儲隨機讀寫IO處理能力是HDD隨機讀寫IO處理能力的20倍
版權聲明:本文博客原創文章,博客,未經同意,不得轉載。