sysbench對MySQL的壓測,使用sysbench壓測磁盤io
阿新 • • 發佈:2019-01-08
onf possible inf bubuko 最新版本 number 現在 nbsp tis
QPS - query per second
TPS - transaction per second 不是特別關註,每個業務場景中事務標準是不一樣的
Ⅰ、sysbench測試框架
Ⅱ、常用測試腳本
[root@VM_42_63_centos lua]# pwd
/usr/local/src/sysbench-master/src/lua
[root@VM_42_63_centos lua]# ll *.lua
-rwxr-xr-x 1 root root 1446 Jun 27 02:35 bulk_insert.lua
-rw-r--r-- 1 root root 1307 Jun 27 02:35 empty-test.lua
-rw-r--r-- 1 root root 14468 Jun 27 02:35 oltp_common.lua
-rwxr-xr-x 1 root root 1290 Jun 27 02:35 oltp_delete.lua
-rwxr-xr-x 1 root root 2415 Jun 27 02:35 oltp_insert.lua
-rwxr-xr-x 1 root root 1265 Jun 27 02:35 oltp_point_select.lua
-rwxr-xr-x 1 root root 1649 Jun 27 02:35 oltp_read_only.lua
-rwxr-xr-x 1 root root 1824 Jun 27 02:35 oltp_read_write.lua
-rwxr-xr-x 1 root root 1118 Jun 27 02:35 oltp_update_index.lua
-rwxr-xr-x 1 root root 1127 Jun 27 02:35 oltp_update_non_index.lua
-rwxr-xr-x 1 root root 1440 Jun 27 02:35 oltp_write_only.lua
-rw-r--r-- 1 root root 1631 Jun 27 02:35 prime-test.lua
-rwxr-xr-x 1 root root 1933 Jun 27 02:35 select_random_points.lua
-rwxr-xr-x 1 root root 2132 Jun 27 02:35 select_random_ranges.lua
Ⅲ、開搞
這個老版本好像有參數設置熱數據的量什麽的,現在最新版本不知道咋搞,就先將就直接弄吧,不管了
準備數據
[root@VM_42_63_centos lua]# sysbench --mysql-host=127.0.0.1 --mysql-port=3307 --mysql-db=sbtest --tables=10 --table-size=10000 --mysql-user=root --mysql-password=123 oltp_update_index.lua prepare
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
Creating table ‘sbtest1‘...
Inserting 10000 records into ‘sbtest1‘
Creating a secondary index on ‘sbtest1‘...
Creating table ‘sbtest2‘...
Inserting 10000 records into ‘sbtest2‘
Creating a secondary index on ‘sbtest2‘...
Creating table ‘sbtest3‘...
Inserting 10000 records into ‘sbtest3‘
Creating a secondary index on ‘sbtest3‘...
...
開始測試
[root@VM_42_63_centos lua]# sysbench oltp_update_index.lua --mysql-host=127.0.0.1 --mysql-port=3307 --mysql-user=root --mysql-password=123 --threads=10 --time=120 --report-interval=10 run
sysbench 1.1.0 (using bundled LuaJIT 2.1.0-beta3)
Running the test with following options:
Number of threads: 10
Report intermediate results every 10 second(s)
Initializing random number generator from current time
Initializing worker threads...
Threads started!
[ 10s ] thds: 10 tps: 804.14 qps: 804.14 (r/w/o: 0.00/804.14/0.00) lat (ms,95%): 36.89 err/s: 0.00 reconn/s: 0.00
[ 20s ] thds: 10 tps: 647.70 qps: 647.70 (r/w/o: 0.00/647.70/0.00) lat (ms,95%): 35.59 err/s: 0.00 reconn/s: 0.00
[ 30s ] thds: 10 tps: 2220.50 qps: 2220.50 (r/w/o: 0.00/2220.50/0.00) lat (ms,95%): 18.28 err/s: 0.00 reconn/s: 0.00
[ 40s ] thds: 10 tps: 4566.59 qps: 4566.59 (r/w/o: 0.00/4566.59/0.00) lat (ms,95%): 2.71 err/s: 0.00 reconn/s: 0.00
[ 50s ] thds: 10 tps: 4194.30 qps: 4194.30 (r/w/o: 0.00/4194.30/0.00) lat (ms,95%): 7.30 err/s: 0.00 reconn/s: 0.00
[ 60s ] thds: 10 tps: 4717.91 qps: 4717.91 (r/w/o: 0.00/4717.91/0.00) lat (ms,95%): 2.76 err/s: 0.00 reconn/s: 0.00
...
看結果,這裏就不解釋了,比較簡單,隨便看看就好
SQL statistics: