sysbenchコマンドはCPU,Memory,Disk I/O,データベースなどのワークロード試験(性能試験)を行うためのツールです。予め指定した処理・リクエストをどのくらい時間で、何秒で実行できたか、スループットを計測することができます。
CentOS6環境ではepelからリリースが可能です。yumでインストールします。
yum install epel-release
yum install sysbench
CPU,メモリ、ディスクどの性能を計測するかによってオプションを変更します。主に一般オプションで大まかな試験ジャンルを指定し、細かいパラメータはテストオプションで指定を行います。
【コマンド書式】
sysbench [一般オプション] --test=name [テストオプション] command
【一般オプション】
| オプション | 説明 | 
| --num-threads=N | スレッド数の指定(デフォルト1) | 
| --max-requests=N | リクエスト数の指定(デフォルト10000) | 
| --max-time=N | 実行時間のリミット指定 | 
| --test=STRING | テストモードを指定する。 ▼cpu CPUのパフォーマンステストを行う。 ▼memory メモリスピードテストを行う ▼fileio ディスク性能のベンチマークを行う ▼oltp データベースのトランザクション性能テストを行う ▼threads スレッド処理のパフォーマンステストを行う。 ▼mutex mutex処理のパフォーマンステストを行う。  | 
		
| --debug=[on|off] | 詳細情報を表示する。(デフォルトOFF) | 
CPUのパフォーマンス試験は素数計算にかかった時間を計測します。
実行例
sysbench --test=cpu run --max-requests=10000 --num-threads=4
試験結果
[root@study01 ~]# sysbench --test=cpu run --max-requests=10000 --num-threads=4
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 4
Doing CPU performance benchmark
Threads started!
Done.
Maximum prime number checked in CPU test: 10000
Test execution summary:
 total time: 12.5718s
 total number of events: 10000
 total time taken by event execution: 50.2610
 per-request statistics:
 min: 1.25ms
 avg: 5.03ms
 max: 14.25ms
 approx. 95 percentile: 7.26ms
Threads fairness:
 events (avg/stddev): 2500.0000/0.71
 execution time (avg/stddev): 12.5653/0.00
CPUオプション
| オプション | 説明 | 
| --num-threads=N | スレッド数の指定(デフォルト1) | 
| --max-requests=N | リクエスト数の指定(デフォルト10000) | 
| --max-time=N | 実行時間のリミット指定 | 
| --test=STRING | テストモードを指定する。 ▼cpu CPUのパフォーマンステストを行う。 ▼memory メモリスピードテストを行う ▼fileio ディスク性能のベンチマークを行う ▼oltp データベースのトランザクション性能テストを行う ▼threads スレッド処理のパフォーマンステストを行う。 ▼mutex mutex処理のパフォーマンステストを行う。  | 
		
| --debug=[on|off] | 詳細情報を表示する。(デフォルトOFF) | 
■メモリのパフォーマンステスト
実行例
sysbench --test=memory run
試験結果
[root@study01 ~]# sysbench --test=memory run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Doing memory operations speed test
Memory block size: 1K
Memory transfer size: 102400M
Memory operations type: write
Memory scope type: global
Threads started!
Done.
Operations performed: 104857600 (1748334.07 ops/sec)
102400.00 MB transferred (1707.36 MB/sec)
Test execution summary:
 total time: 59.9757s
 total number of events: 104857600
 total time taken by event execution: 50.9382
 per-request statistics:
 min: 0.00ms
 avg: 0.00ms
 max: 0.95ms
 approx. 95 percentile: 0.00ms
Threads fairness:
 events (avg/stddev): 104857600.0000/0.00
 execution time (avg/stddev): 50.9382/0.00
Memoryオプション
| オプション | 説明 | 
| 
			 --memory-block-size=SIZE 
			 | 
			
			 ブロックサイズを指定します。(デフォルト 1Kbyte) 
			 | 
		
| 
			 --memory-total-size=SIZE 
			 | 
			
			 メモリへの送信データのトータルサイズを指定(デフォルト100GB) 
			 | 
		
| 
			 --memory-scope=STRING 
			 | 
			
			 試験対象のメモリスコープを指定(デフォルトglobal) 
			 | 
		
| 
			 --memory-oper=STRING 
			 | 
			
			 {read, write, none} いずれかの試験モードを指定(デフォルトwrite) 
			 | 
		
| 
			 --memory-access-mode=STRING 
			 | 
			
			 {seq,rnd} メモリへのアクセス方法をシーケンシャルかrandで指定する。(デフォルトseq) 
			 | 
		
ディスクIOの試験は予め試験用ファイルを作成し、そのファイルに対して試験の処理が走ります。
実行例
(1)ファイル準備
ファイルがたくさん生成されるため、試験用ディレクトリ内で実行することをおすすめします。1Gのファイルサイズで8192Kbのファイルが128個作られます。(1024MB)
[root@study01 ~]# sysbench --test=fileio --file-total-size=1G prepare
(2)試験開始
[root@study01 ~]# sysbench --test=fileio --file-total-size=1G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run
(3)削除
[root@study01 ~]# sysbench --test=fileio --file-total-size=1G cleanup
試験結果
[root@study01 sysbench]# sysbench --test=fileio --file-total-size=1G --file-test-mode=rndrw --init-rng=on --max-time=300 --max-requests=0 run
sysbench 0.4.12: multi-threaded system evaluation benchmark
Running the test with following options:
Number of threads: 1
Initializing random number generator from timer.
Extra file open flags: 0
128 files, 8Mb each
1Gb total file size
Block size 16Kb
Number of random requests for random IO: 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
Threads started!
Time limit exceeded, exiting...
Done.
Operations performed: 103920 Read, 69280 Write, 221569 Other = 394769 Total
Read 1.5857Gb Written 1.0571Gb Total transferred 2.6428Gb (9.0198Mb/sec)
 577.27 Requests/sec executed
Test execution summary:
 total time: 300.0329s
 total number of events: 173200
 total time taken by event execution: 127.3912
 per-request statistics:
 min: 0.00ms
 avg: 0.74ms
 max: 96.62ms
 approx. 95 percentile: 5.29ms
Threads fairness:
 events (avg/stddev): 173200.0000/0.00
 execution time (avg/stddev): 127.3912/0.00
Diskテストオプション
| オプション | 説明 | 
| 
			 --file-num=N 
			 | 
			
			 作成するファイルのファイル数を指定する。(デフォルト128) 
			 | 
		
| 
			 --file-block-size=N 
			 | 
			
			 ブロックサイズを指定(デフォルト16KB) 
			 | 
		
| 
			 --file-total-size=SIZE 
			 | 
			
			 作成するファイルサイズ上限を指定。これを指定するとブロックサイズに応じて同容量程度になるような数のファイルを生成する。 
			 | 
		
| 
			 --file-test-mode=STRING 
			 | 
			
			 テストモードの指定 
			【シーケンシャル】…端から順番に処理 
			【ランダム】…不規則な処理 
			▼seqwr(シーケンシャルwrite) ▼seqrewr(シーケンシャルread&write) ▼seqrd(シーケンシャルread) ▼rndrd(ランダムread) ▼rndwr(ランダムwrite) ▼rndrw(シーケンシャルread&write)  | 
		
| 
			 --file-io-mode=STRING 
			 | 
			
			 ファイルのI/Oモードを指定する。 
			
  | 
		
| 
			 (テストオプション) 
			 | 
			
			 ▼prepare 
			fileioやoltp(on-line transaction processingの略)で試験ファイルを準備するときに利用する。 ▼run 
			ワークロード試験を実行するときに利用 ▼cleanup 
			試験で利用したファイルを削除する。  | 
		
Copyright © 2021 たぐたぐ.com. All rights reserved.