mysql sysbench 教程_mysql sysbench 使用方法!
mysql 壓力測試之sysbench
1.sysbench 的安裝
下載下來之后會有一個sysbench-0.4.10.tar.gz ?壓縮包.
解壓后生成目錄 sysbench-0.4.10
進入sysbench-0.4.10 這個目錄
[root@linuxvm01 home]# cd ?/home/sysbench-0.4.10
編譯安裝sysbench
[root@linuxvm01 sysbench-0.4.10]# ./configure --with-mysql-includes=/usr/include/mysql --with-mysql-libs=/usr/lib ?&& make && make install
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
TIP:
with-mysql-includes 指定上面確認的mysql-devel的路徑,
with-mysql-libs 是安裝mysql的路徑,
# ?當時這兩個參數沒弄明白編譯安裝的時候一直報錯,
安裝過程中出現的錯誤處理
(1).drv_mysql.c:32:19: error: mysql.h: No such file or directory
參數 with-mysql-includes ,with-mysql-libs 不準確
(2)./usr/bin/ld: cannot find -lmysqlclient_r
collect2: ld returned 1 exit status
make[2]: *** [sysbench] Error 1
make[2]: Leaving directory `/home/sysbench-0.4.10/sysbench'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/sysbench-0.4.10/sysbench'
make: *** [all-recursive] Error 1
安裝下:rpm -ivh ?MySQL-shared-5.6.22-1.el6.x86_64.rpm
2.sysbench 的使用
sysbench 可以測試的項目有
cpu的性能測試
內存性能測試
磁盤io吸能測試
oltp系統測試
最重要的還是 磁盤io吸能測試 和oltp 測試。
這里重點講解下磁盤io吸能測試 和oltp 測試。
=====磁盤io性能測試 ==============
IO測試分為三個階段, 文件生成,執行測試,清理測試文件
首先生成需要測試的文件
sysbench --test=fileio --num-threads=2 --file-num=16 --file-total-size=30G --file-test-mode=rndrw --file-rw-ratio=2 prepare
[root@linuxvm01 ~]# sysbench --test=fileio --num-threads=2 --file-num=16 --file-total-size=30G --file-test-mode=rndrw --file-rw-ratio=2 prepare
sysbench 0.4.10: ?multi-threaded system evaluation benchmark
16 files, 1966080Kb each, 30720Mb total
Creating files for the test...
然后執行測試
sysbench --test=fileio --num-threads=2 --file-num=16 --file-total-size=30G --file-test-mode=rndrw --file-rw-ratio=2 run
[root@linuxvm01 ~]# sysbench --test=fileio --num-threads=2 --file-num=16 --file-total-size=30G --file-test-mode=rndrw --file-rw-ratio=2 run
sysbench 0.4.10: ?multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 2
Extra file open flags: 0
16 files, 1.875Gb each
30Gb total file size
Block size 16Kb
Number of random requests for random IO: 10000
Read/Write ratio for combined random IO test: 2.00
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random r/w test
Threads started!
Done.
Operations performed: ?6667 Read, 3333 Write, 1600 Other = 11600 Total
Read 104.17Mb ?Written 52.078Mb ?Total transferred 156.25Mb ?(2.0936Mb/sec)
133.99 Requests/sec executed
Test execution summary:
total time: ? ? ? ? ? ? ? ? ? ? ? ? ?74.6328s
total number of events: ? ? ? ? ? ? ?10000
total time taken by event execution: 142.3936
per-request statistics:
min: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?0.01ms
avg: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 14.24ms
max: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?305.56ms
approx. ?95 percentile: ? ? ? ? ? ? ?37.48ms
Threads fairness:
events (avg/stddev): ? ? ? ? ? 5000.0000/12.00
execution time (avg/stddev): ? 71.1968/0.09
這個里面最重要的需要關注的吞吐量(2.0936Mb/sec) ,
每秒請求數( 133.99 Requests/sec executed)
還有95%的請求耗時( approx. ?95 percentile: ? ? ? ? ? ? ?37.48ms)
最后清理測試文件
sysbench --test=fileio --num-threads=2 --file-num=16 --file-total-size=30G --file-test-mode=rndrw --file-rw-ratio=2 cleanup
=====OLTP 系統性能測試 ==============
otlp性能測試分為兩階段.
1.準備階段
2.執行階段
--準備階段
[root@linuxvm01 ~]# sysbench --test=oltp --mysql-table-engine=innodb --oltp-table-size=4000000 --mysql-socket=/var/lib/mysql/mysql.sock --mysql-db=test ?--mysql-user=root ?--mysql-password=anyu@2014 prepare
sysbench 0.4.10: ?multi-threaded system evaluation benchmark
No DB drivers specified, using mysql
Creating table 'sbtest'...
Creating 4000000 records in table 'sbtest'...
-- 執行階段
[root@linuxvm01 ~]# sysbench --num-threads=8 --max-requests=4000000 --test=oltp --mysql-table-engine=innodb --oltp-table-size=4000000 --mysql-socket=/var/lib/mysql/mysql.sock --mysql-db=test --mysql-user=root ?--mysql-password=anyu@2014 run
sysbench 0.4.10: ?multi-threaded system evaluation benchmark
No DB drivers specified, using mysql
WARNING: Preparing of "BEGIN" is unsupported, using emulation
(last message repeated 7 times)
Running the test with following options:
Number of threads: 8
Doing OLTP test.
Running mixed OLTP test
Using Special distribution (12 iterations, ?1 pct of values are returned in 75 pct cases)
Using "BEGIN" for starting transactions
Using auto_inc on the id column
Maximum number of requests for OLTP test is limited to 4000000
Threads started!
Done.
OLTP test statistics:
queries performed:
read: ? ? ? ? ? ? ? ? ? ? ? ? ? ?56000000
write: ? ? ? ? ? ? ? ? ? ? ? ? ? 20000000
other: ? ? ? ? ? ? ? ? ? ? ? ? ? 8000000
total: ? ? ? ? ? ? ? ? ? ? ? ? ? 84000000
transactions: ? ? ? ? ? ? ? ? ? ? ? ?4000000 (125.37 per sec.)
deadlocks: ? ? ? ? ? ? ? ? ? ? ? ? ? 0 ? ? ?(0.00 per sec.)
read/write requests: ? ? ? ? ? ? ? ? 76000000 (2381.99 per sec.)
other operations: ? ? ? ? ? ? ? ? ? ?8000000 (250.74 per sec.)
Test execution summary:
total time: ? ? ? ? ? ? ? ? ? ? ? ? ?31906.1255s
total number of events: ? ? ? ? ? ? ?4000000
total time taken by event execution: 255224.4528
per-request statistics:
min: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?2.69ms
avg: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 63.81ms
max: ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 5557.09ms
approx. ?95 percentile: ? ? ? ? ? ? 178.90ms
Threads fairness:
events (avg/stddev): ? ? ? ? ? 500000.0000/2282.56
execution time (avg/stddev): ? 31903.0566/0.09
這段輸出中包含了
QPS(transactions: ? ? ? ? ? ? ? ? ? ? ? ?4000000 (125.37 per sec.)) ,
tps( transactions: ? ? ? ? ? ? ? ? ? ? ? ?4000000 (125.37 per sec.))
百分之95的請求耗時在178.90ms : approx. ?95 percentile: ? ? ? ? ? ? 178.90ms
參考鏈接:
總結
以上是生活随笔為你收集整理的mysql sysbench 教程_mysql sysbench 使用方法!的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 一种linux平台下算法库二进制文件加密
- 下一篇: python字符串阿拉伯数字与中文转换