一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務器之家:專注于服務器技術及軟件下載分享
分類導航

Mysql|Sql Server|Oracle|Redis|MongoDB|PostgreSQL|Sqlite|DB2|mariadb|Access|數據庫技術|

服務器之家 - 數據庫 - Mysql - 通過sysbench工具實現MySQL數據庫的性能測試的方法

通過sysbench工具實現MySQL數據庫的性能測試的方法

2020-11-26 20:09東山絮柳仔 Mysql

sysbench是一款壓力測試工具,可以測試系統的硬件性能,也可以用來對數據庫進行基準測試。這篇文章主要介紹了通過sysbench工具實現MySQL數據庫的性能測試 ,需要的朋友可以參考下

1.背景

 sysbench是一款壓力測試工具,可以測試系統的硬件性能,也可以用來對數據庫進行基準測試。sysbench 支持的測試有cpu運算性能測試、內存分配及傳輸速度測試、磁盤io性能測試、posix線程性能測試、互斥性測試測試、數據庫性能測試(oltp基準測試)。目前支持的數據庫主要是mysql數據庫和pg數據庫。

在新服務器上線時,建議對服務器的性能做一次測試,最好與既往的同類型的服務器的性能測試報表做一個橫線比較,發現潛在問題。及新機器上線前,對服務器做一次體檢。

對數據庫而言,我們可以通過sysbench工具實現對數據庫的基準測試。在現在的系統架構中,前端都比較容易彈性水平拓展,數據庫相對較難,因此,基準測試對數據庫具有很重要的作用。而對數據庫的基準測試的作用,就是分析在當前的配置下(包括硬件配置、os、數據庫設置等),數據庫的性能表現,從而找出mysql的性能閾值,并根據實際系統的要求調整配置。

2.sysbench的安裝

1)安裝命令

yum -y install sysbench

2)查看安裝的版本

sysbench --version

通過sysbench工具實現MySQL數據庫的性能測試的方法

3)查看已安裝軟件的信息(主要是通 rpm 命令)。

 查詢sysbench的安裝信息,主要是測試mysql時,需要使用sysbench自帶的lua腳本進行測試。如果使用快速安裝的方式,默認的腳本路徑為:/usr/share/sysbench

 如果不在這個命令,我們我們執行以下命令查看,查找已安裝在本機linux系統上面的所有的sysbench軟件的程序:

rpm -qa sysbench

列出該軟件所有的文件與目錄所在完整文件名(list):

rpm -ql sysbench

通過sysbench工具實現MySQL數據庫的性能測試的方法

3.sysbench 語法

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
sysbench --help
usage:
 sysbench [options]... [testname] [command]
commands implemented by most tests: prepare run cleanup help
general options:
 --threads=n           number of threads to use [1]
 --events=n           limit for total number of events [0]
 --time=n            limit for total execution time in seconds [10]
 --forced-shutdown=string    number of seconds to wait after the --time limit before forcing shutdown, or 'off' to disable [off]
 --thread-stack-size=size    size of stack per thread [64k]
 --rate=n            average transactions rate. 0 for unlimited rate [0]
 --report-interval=n       periodically report intermediate statistics with a specified interval in seconds. 0 disables intermediate reports [0]
 --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. []
 --debug[=on|off]        print more debugging info [off]
 --validate[=on|off]       perform validation checks where possible [off]
 --help[=on|off]         print help and exit [off]
 --version[=on|off]       print version and exit [off]
 --config-file=filename     file containing command line options
 --tx-rate=n           deprecated alias for --rate [0]
 --max-requests=n        deprecated alias for --events [0]
 --max-time=n          deprecated alias for --time [0]
 --num-threads=n         deprecated alias for --threads [1]
pseudo-random numbers generator options:
 --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. when 0, the current time is used as a rng seed. [0]
 --rand-pareto-h=n parameter h for pareto distribution [0.2]
log options:
 --verbosity=n verbosity level {5 - debug, 0 - only critical messages} [3]
 --percentile=n    percentile to calculate in latency statistics (1-100). use the special value of 0 to disable percentile calculations [95]
 --histogram[=on|off] print latency histogram in report [off]
general database options:
 --db-driver=string specifies database driver to use ('help' to get list of available drivers) [mysql]
 --db-ps-mode=string prepared statements usage mode {auto, disable} [auto]
 --db-debug[=on|off] print database-specific debug information [off]
compiled-in database drivers:
 mysql - mysql driver
 pgsql - postgresql driver
mysql options:
 --mysql-host=[list,...]     mysql server host [localhost]
 --mysql-port=[list,...]     mysql server port [3306]
 --mysql-socket=[list,...]    mysql socket
 --mysql-user=string       mysql user [sbtest]
 --mysql-password=string     mysql password []
 --mysql-db=string        mysql database name [sbtest]
 --mysql-ssl[=on|off]       use ssl connections, if available in the client library [off]
 --mysql-ssl-cipher=string    use specific cipher for ssl connections []
 --mysql-compression[=on|off]   use compression, if available in the client library [off]
 --mysql-debug[=on|off]      trace all client library calls [off]
 --mysql-ignore-errors=[list,...] list of errors to ignore, or "all" [1213,1020,1205]
 --mysql-dry-run[=on|off]     dry run, pretend that all mysql client api calls are successful without executing them [off]
pgsql options:
 --pgsql-host=string   postgresql server host [localhost]
 --pgsql-port=n     postgresql server port [5432]
 --pgsql-user=string   postgresql user [sbtest]
 --pgsql-password=string postgresql password []
 --pgsql-db=string    postgresql database name [sbtest]
compiled-in tests:
 fileio - file i/o test
 cpu - cpu performance test
 memory - memory functions speed test
 threads - threads subsystem performance test
 mutex - mutex performance test

基本語法如下:

sysbench [options]... [testname] [command]

command 是sysbench要執行的命令,包括prepare、run和cleanup。prepare是為測試提前準備數據,run是執行正式的測試,cleanup是在測試完成后對數據庫進行清理

testname  指定了要進行的測試,在老版本的sysbench中,可以通過--test參數指定測試的腳本;而在新版本中,--test參數已經聲明為廢棄,可以不使用--test,而是直接指定腳本。測試時使用的腳本為lua腳本,可以使用sysbench自帶腳本,也可以自己開發。

options 關于mysql的主要包括mysql 連接信息參數 和 mysql 執行相關的參數。

4 測試

step 1 準備壓測數據

通過sysbench工具實現MySQL數據庫的性能測試的方法

?
1
sysbench /usr/share/sysbench/oltp_insert.lua --mysql-host=xxx.xxx.xxx.xxx --mysql-port=3306 --mysql-user=testsbuser --mysql-password='textpwd' --mysql-db=tssysbench --db-driver=mysql --tables=15 --table-size=500000 --report-interval=10 --threads=128  --time=120 prepare

step 2  壓測

?
1
sysbench /usr/share/sysbench/oltp_insert.lua --mysql-host=xxx.xxx.xxx.xxx --mysql-port=3306 --mysql-user=testsbuser --mysql-password='textpwd' --mysql-db=tssysbench --db-driver=mysql --tables=15 --table-size=500000 --report-interval=10 --threads=128  --time=120 run

也可以將測試結果導出到文件中,便于后續分析。

?
1
sysbench /usr/share/sysbench/oltp_insert.lua --mysql-host=xxx.xxx.xxx.xxx --mysql-port=3306 --mysql-user=testsbuser --mysql-password='testpwd' --mysql-db=tssysbench --db-driver=mysql --tables=15 --table-size=500000 --report-interval=10 --threads=128  --time=120 run >> ./mysysbench.log

通過sysbench工具實現MySQL數據庫的性能測試的方法

step 3 清理壓測數據

?
1
sysbench /usr/share/sysbench/oltp_insert.lua --mysql-host=xxx.xxx.xxx.xxx --mysql-port=3306 --mysql-user=testsbuser --mysql-password='testpwd' --mysql-db=tssysbench --db-driver=mysql --tables=15 --table-size=500000 --report-interval=10 --threads=128  --time=120 cleanup

 

通過sysbench工具實現MySQL數據庫的性能測試的方法

5.注意事項

(1) 測試數據庫需要提前創建,及時測試賬號擁有創建數據庫的權限。

     --mysql-db 參數指定了測試的數據,默認是sbtest。

    不提前創建,報錯信息如下;

fatal: `sysbench.cmdline.call_command' function failed: /usr/share/sysbench/oltp_common.lua:83: connection creation failed
(last message repeated 3 times)
fatal: error 1049: unknown database 'sysbench_db'
fatal: `sysbench.cmdline.call_command' function failed: /usr/share/sysbench/oltp_common.lua:83: connection creation failed
fatal: unable to connect to mysql server on host 'xxx.xxx.xxx.xxx', port 3306, aborting...
(last message repeated 1 times)
fatal: error 1049: unknown database 'sysbench_db'
(last message repeated 1 times)

或是(不指定數據庫)

fatal: `sysbench.cmdline.call_command' function failed: /usr/share/sysbench/oltp_common.lua:83: connection creation failed
fatal: error 1049: unknown database 'sbtest'
fatal: unable to connect to mysql server on host 'xxx.xxx.xxx.xxx', port 3306, aborting...

(2)不要在mysql服務器運行的機器上進行測試,一方面可能無法體現網絡(哪怕是局域網)的影響,另一方面,sysbench的運行(尤其是設置的并發數較高時)會影響mysql服務器的表現.

(3)逐步增加客戶端的并發連接數(--thread參數),觀察在連接數不同情況下,mysql服務器的表現。

(4)如果連續進行多次測試,注意確保之前測試的數據已經被清理干凈。

(5)如果生成的報告,圖形化分析,可以通過gnuplot工具進行分析。

總結

以上所述是小編給大家介紹的通過sysbench工具實現mysql數據庫的性能測試的方法,希望對大家有所幫助,如果大家有任何疑問請給我留言,小編會及時回復大家的。在此也非常感謝大家對服務器之家網站的支持!

如果你覺得本文對你有幫助,歡迎轉載,煩請注明出處,謝謝!

原文鏈接:https://www.cnblogs.com/xuliuzai/p/11243376.html

延伸 · 閱讀

精彩推薦
主站蜘蛛池模板: 性xxxx18学生第一次出血 | 久久理论片迅播影院一级 | 男女肉粗暴进来下面好紧 | 亚洲成a人片777777久久 | 亚洲精品国产精品麻豆99 | 免费视频亚洲 | 按摩椅play啊太快了h | 免费一级黄 | 成年人免费观看 | 日韩成人小视频 | 男生操女生漫画 | 亚洲第一综合网 | 国产一区日韩二区欧美三区 | 四虎影院最新网址 | 欧美一区精品 | 国产视频一区在线观看 | 王的视频vk | 久久视频这只精品99re6 | 欧美在线视频免费播放 | 日本高清免费看 | 蝴蝶传媒3o45| 亚洲女同一区二区 | 久久全国免费观看视频 | 97理伦 | 国产日产精品久久久久快鸭 | 精品国产自在现线久久 | 精品免费久久久久久影院 | 日本高清动作片www欧美 | 亚瑟天堂久久一区二区影院 | 国产在线精品亚洲第一区香蕉 | 精品无码人妻一区二区免费AV | 色菇凉天天综合网 | 久久精品AV一区二区无码 | 日本暖暖在线 | 日本精品一区二区在线播放 | 日韩综合一区 | 亚洲香蕉伊在人在线观看9 亚洲系列国产系列 | 日本ww视频 | 亚洲AV永久无码精品澳门 | 歪歪私人影院成人毛片 | 婷婷日日夜夜 |