壓測工具之Sysbench(1_系統壓測)
一、sysbench下載
專案地址:二、sysbench安裝
[root@DB_TEST tools]# tar -xzvf sysbench-1.0.3.tar.gz
[root@DB_TEST tools]# cd sysbench-1.0.3
[root@DB_TEST sysbench-1.0.3]# ./autogen.sh
[root@DB_TEST sysbench-1.0.3]#./configure --prefix=/usr/local/sysbench --with-mysql
[root@DB_TEST sysbench-1.0.3]# make
[root@DB_TEST sysbench-1.0.3]# make install
[root@DB_TEST sysbench-1.0.3]# cp -rp /usr/local/sysbench/bin/sysbench /usr/bin/
[root@DB_TEST sysbench-1.0.3]# /usr/local/sysbench/bin/sysbench --help
點選(此處)摺疊或開啟
- [root@BJ-133-22 sysbench-1.0.3]# /usr/local/sysbench/bin/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 distibution [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)
- --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
-
- 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]
-
- 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
-
- See 'sysbench help' for a list of options for each test.
1、CPU效能測試
cpu效能測試:找範圍內最大素數{時間越短越好}
cpu效能測試主要是根據素數的加法運算,這裡指定最大素數(質數)為80000,--num-threads=`grep "processor" /proc/cpuinfo | wc -l`指定執行緒數,預設是1
/usr/local/sysbench/bin/sysbench --test=cpu --cpu-max-prime=80000 run點選(此處)摺疊或開啟
- [root@db_test ~]# /usr/local/sysbench/bin/sysbench --test=cpu --cpu-max-prime=80000 run
- WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
- sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
-
- Running the test with following options:
- Number of threads: 1
- Initializing random number generator from current time
-
-
- Prime numbers limit: 80000
-
- Initializing worker threads...
-
- Threads started!
-
-
- General statistics:
- total time: 10.0057s
- total number of events: 520
-
- Latency (ms):
- min: 18.74
- avg: 19.24
- max: 19.39
- 95th percentile: 19.29
- sum: 10005.32
-
- Threads fairness:
- events (avg/stddev): 520.0000/0.00
- execution time (avg/stddev): 10.0053/0.00
實際環境CPU拷機壓測指令碼如下:
echo -e "進行CPU壓力測試: 尋找小於1千萬的最大質數,併發執行緒數10,最大請求數100 "
/usr/local/bin/sysbench --num-threads=10 --max-requests=100 --test=cpu --debug --cpu-max-prime=10000000 run
2、記憶體效能測試
sysbench 測試memory的時候是順序讀或寫記憶體的。根據選項的不同,每次操作過程中,每個執行緒可以獲取global或本地的資料塊
記憶體:以不同塊大小傳輸一定數量的資料吞吐量大小{越大越好}
點選(此處)摺疊或開啟
-
[root@db_test fileio]# /usr/local/sysbench/bin/sysbench --test=memory help
-
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
-
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
-
-
memory options:
-
--memory-block-size=SIZE size of memory block for test [1K] 測試時記憶體塊大小
-
--memory-total-size=SIZE total size of data to transfer [100G] 傳輸資料總大小
-
--memory-scope=STRING memory access scope {global,local} [global] 記憶體訪問範圍
-
--memory-hugetlb[=on|off] allocate memory from HugeTLB pool [off] 從 HugeTLB pool記憶體分配
-
--memory-oper=STRING type of memory operations {read, write, none} [write] 記憶體操作型別
- --memory-access-mode=STRING memory access mode {seq,rnd} [seq] 儲存器存取方式
[root@db_test fileio]# /usr/local/sysbench/bin/sysbench --test=memory --memory-block-size=1K --memory-total-size=5G run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
Operations performed: 5242880 (3518332.06 ops/sec)
5120.00 MiB transferred (3435.87 MiB/sec)
General statistics:
total time: 1.4883s
total number of events: 5242880
Latency (ms):
min: 0.00
avg: 0.00
max: 0.03
95th percentile: 0.00
sum: 631.01
Threads fairness:
events (avg/stddev): 5242880.0000/0.00
execution time (avg/stddev): 0.6310/0.00
實際記憶體壓力測試指令碼:
echo -e "進行記憶體壓力測試: 測試範圍32G,併發執行緒數10,最大請求數100, 讀 "
/usr/local/bin/sysbench --num-threads=10 --max-requests=100 --test=memory --memory-block-size=8K --memory-total-size=${MEM}G --memory-oper=read run
echo -e "進行記憶體壓力測試: 測試範圍32G,併發執行緒數10,最大請求數100, 寫 "
/usr/local/bin/sysbench --num-threads=10 --max-requests=100 --test=memory --memory-block-size=8K --memory-total-size=${MEM}G --memory-oper=write run
3、磁碟IO效能測試
IO效能測試:不同場景下IOPS{越大越好}
點選(此處)摺疊或開啟
- [root@db_test sysbench-1.0.3]# /usr/local/sysbench/bin/sysbench --test=fileio help
- WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
- sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
-
- fileio options:
- --file-num=N number of files to create [128]
- --file-block-size=N block size to use in all IO operations [16384]
- --file-total-size=SIZE total size of files to create [2G]
- --file-test-mode=STRING test mode {seqwr, seqrewr, seqrd, rndrd, rndwr, rndrw}
- --file-io-mode=STRING file operations mode {sync,async,mmap} [sync]
- --file-async-backlog=N number of asynchronous operatons to queue per thread [128]
- --file-extra-flags=STRING additional flags to use on opening files {sync,dsync,direct} []
- --file-fsync-freq=N do fsync() after this number of requests (0 - don't use fsync()) [100]
- --file-fsync-all[=on|off] do fsync() after each write operation [off]
- --file-fsync-end[=on|off] do fsync() at the end of test [on]
- --file-fsync-mode=STRING which method to use for synchronization {fsync, fdatasync} [fsync]
- --file-merged-requests=N merge at most this number of IO requests if possible (0 - don't merge) [0]
- --file-rw-ratio=N reads/writes ratio for combined test [1.5]
--file-num=N 建立測試檔案數量,預設是 [128]
--file-block-size=N 測試時檔案塊大小,預設是[16384],即16K
--file-total-size=SIZE 測試檔案的總大小,預設是 [2G]
--file-test-mode=STRING 測試模式 {seqwr(順序寫), seqrewr(順序讀寫), seqrd(順序讀), rndrd(隨機讀), rndwr(隨機寫), rndrw(隨機讀寫)}
--file-io-mode=STRING 檔案操作模式{sync,async,mmap} [sync]
--file-extra-flags=STRING 使用額外的標誌開啟檔案 {sync,dsync,direct} []
--file-fsync-freq=N 執行fsync()頻率,0表示不使用,預設100
--file-fsync-all=[on|off] 每執行一次寫操作執行一次fsync(),預設 [off]
--file-fsync-end=[on|off] 測試結束執行fsync(),預設 [on]
--file-fsync-mode=STRING 同步方法 {fsync, fdatasync} [fsync]
--file-merged-requests=N 如果可以,則合併IO請求數,預設0表示不合並
--file-rw-ratio=N 測試讀寫比例,預設[1.5]
seqwr 順序寫入
seqrewr 順序重寫
seqrd 順序讀取
rndrd 隨機讀取
rndwr 隨機寫入
rndrw 混合隨機讀/寫
##Fileio準備工作,生成測試資料(最好比記憶體的2倍大)
[root@db_test fileio]# /usr/local/sysbench/bin/sysbench --num-threads=16 --test=fileio --file-total-size=10G --file-test-mode=rndrw prepare
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
128 files, 81920Kb each, 10240Mb total
Creating files for the test...
Extra file open flags: 0
Creating file test_file.0
...
Creating file test_file.127
10737418240 bytes written in 9.96 seconds (1027.97 MiB/sec).
##正式執行FileIO測試
[root@db_test fileio]# /usr/local/sysbench/bin/sysbench --num-threads=16 --test=fileio --file-total-size=10G --file-test-mode=rndrw run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 16
Initializing random number generator from current time
Extra file open flags: 0
128 files, 80MiB each
10GiB total file size
Block size 16KiB
Number of IO requests: 0
Read/Write ratio for combined random IO test: 1.50
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
Initializing worker threads...
Threads started!
File operations:
reads/s: 1449.16
writes/s: 965.91
fsyncs/s: 3083.55
Throughput:
read, MiB/s: 22.64
written, MiB/s: 15.09
General statistics:
total time: 10.4176s
total number of events: 57291
Latency (ms):
min: 0.00
avg: 2.87
max: 825.08
95th percentile: 0.17
sum: 164312.66
Threads fairness:
events (avg/stddev): 3580.6875/469.53
execution time (avg/stddev): 10.2695/0.08
IO密切相關的包括每秒請求數和總吞吐量,其中請求數是(1449.16+965.91+3083.55)/s,吞吐量是(22.64+15.09)MB/s
##清理建立的檔案
[root@db_test fileio]# /usr/local/sysbench/bin/sysbench --num-threads=16 --test=fileio --file-total-size=10G --file-test-mode=rndrw cleanup
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Removing test files...
實際環境FILEIO壓力測試指令碼:
echo -e "進行IO壓力測試: 20個檔案,每個10GB,隨機讀寫 "
/usr/local/bin/sysbench --file-num=20 --num-threads=20 --test=fileio --file-total-size=${HDD}G --max-requests=1000000 --file-test-mode=rndrw prepare
/usr/local/bin/sysbench --file-num=20 --num-threads=20 --test=fileio --file-total-size=${HDD}G --max-requests=1000000 --file-test-mode=rndrw run
/usr/local/bin/sysbench --file-num=20 --num-threads=20 --test=fileio --file-total-size=${HDD}G --max-requests=1000000 --file-test-mode=rndrw cleanup
4、thread測試
執行緒排程:執行緒併發執行,迴圈響應訊號量花費的時間{越少越好}
測試執行緒排程器的效能。對於高負載情況下測試執行緒排程器的行為非常有用
點選(此處)摺疊或開啟
- [root@db_test fileio]# /usr/local/sysbench/bin/sysbench --test=threads help
- WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
- sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
-
- threads options:
-
--thread-yields=N number of yields to do per request [1000] 每個請求產生多少個執行緒,預設[1000]
- --thread-locks=N number of locks per thread [8] 每個執行緒的鎖數量,預設 [8]
[root@db_test fileio]# /usr/local/sysbench/bin/sysbench --num-threads=64 --test=threads --thread-yields=100 --thread-locks=2 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
WARNING: --num-threads is deprecated, use --threads instead
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 64
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 10.0043s
total number of events: 102842
Latency (ms):
min: 0.02
avg: 6.22
max: 28.83
95th percentile: 15.00
sum: 640039.96
Threads fairness:
events (avg/stddev): 1606.9062/31.79
execution time (avg/stddev): 10.0006/0.00
5、互斥鎖測試
互斥鎖:併發執行緒同時申請互斥鎖迴圈一定次數花費的時間{越少越好}
測試互斥鎖的效能,方式是模擬所有執行緒在同一時刻併發執行,並都短暫請求互斥鎖點選(此處)摺疊或開啟
-
[root@db_test fileio]# /usr/local/sysbench/bin/sysbench --test=mutex help
-
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
-
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
-
-
mutex options:
-
--mutex-num=N total size of mutex array [4096] 陣列互斥總大小,預設[4096]
-
--mutex-locks=N number of mutex locks to do per thread [50000] 每個執行緒互斥鎖的數量,預設 [50000]
- --mutex-loops=N number of empty loops to do inside mutex lock [10000] 內部互斥鎖的空迴圈數量,預設 [10000]
所有執行緒同時執行,獲取短時間的mutex lock,以便測試mutex的實現!
示例:[root@db_test fileio]# /usr/local/sysbench/bin/sysbench --test=mutex --mutex-num=4096 --mutex-locks=50000 --mutex-loops=20000 run
WARNING: the --test option is deprecated. You can pass a script name or path on the command line without any options.
sysbench 1.0.3 (using bundled LuaJIT 2.1.0-beta2)
Running the test with following options:
Number of threads: 1
Initializing random number generator from current time
Initializing worker threads...
Threads started!
General statistics:
total time: 0.0021s
total number of events: 1
Latency (ms):
min: 2.05
avg: 2.05
max: 2.05
95th percentile: 2.03
sum: 2.05
Threads fairness:
events (avg/stddev): 1.0000/0.00
execution time (avg/stddev): 0.0020/0.00
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/27067062/viewspace-2135156/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- sysbench 壓力測試
- sysbench壓測實踐
- mysql之 sysbench1.0.3 安裝與系統壓力測試MySql
- sysbench壓測Oracle 12COracle
- sysbench壓測Oracle 11gOracle
- NewSQL資料庫壓力測試工具系列——SysbenchSQL資料庫
- MySQL 效能壓測工具-sysbench,從入門到自定義測試項MySql
- [資料庫]000 - ?Sysbench 資料庫壓力測試工具資料庫
- Linux系統壓力測試工具(命令列工具)Linux命令列
- kafka壓測工具Kafka
- 壓測工具 wrk
- apache ab壓力測試工具-批次壓測指令碼Apache指令碼
- MySQL 5.7和8.0 MHA架構下sysbench壓測MySql架構
- 效能壓測工具 —— wrk
- 壓測工具jemiter使用MIT
- http 壓測工具(qbit)HTTP
- 全鏈路壓測演進之迭代式壓測
- 效能工具之Jmeter壓測Hprose RPC服務JMeterROSRPC
- 效能工具之Jmeter壓測Thrift RPC服務JMeterRPC
- 效能測試:主流壓測工具介紹
- 壓測工具之JMeter之環境配置及執行JMeter
- jmeter之——jms壓測(activemq)JMeterMQ
- NoSQLBench壓測工具入門教程SQL
- Go 效能壓測工具之wrk介紹與使用Go
- 很好用的壓測工具 - Apache Bench工具Apache
- oracle壓力測試之orastress!OracleAST
- locust壓測
- ClickHouse壓測
- 壓測流程
- 10大主流壓力測試工具
- CentOS 下安裝 wrk 壓測工具CentOS
- ELK esrally 壓測工具安裝使用
- 編寫一個介面壓測工具
- 軟體壓力測試知識分享,2022好用壓力測試工具有哪些?
- Taurus.MVC 效能壓力測試(ap 壓測 和 linux 下wrk 壓測):.NET 版本MVCLinux
- 超實用壓力測試工具-ab工具
- 壓縮機的測量系統分析(MSA)方法
- JMeter分散式壓測/JMeter負載新增/jmeter負載均衡/jmeter Windows系統壓測負載新增JMeter分散式負載Windows
- 讓測試事半功倍軟體壓力測試工具分享,壓力測試報告怎麼收費?測試報告