SwingbenchでOracle Databaseにベンチマークしたい!
ベンチマークのマニアックな話です。
Oracle Databaseに簡単に負荷がかけられるツールとしてSwingbenchが有名です。最近swingbenchに触る機会があり、ちょっと勉強したのでアウトプットしようと思います。
swingbench自体の説明と負荷かけ結果をExcelでレポートにしたい!という時に微妙にめんどくさいcsv化を自動化する自作のpythonスクリプトを紹介します!
swingbenchとは?
概要
まぁ、取り敢えず本家サイトから引用します。
Swingbench is a free load generator (and benchmarks) designed to stress test an Oracle database (12c, 18c, 19c). It can be downloaded here. See my blog for new releases and what Im currently working on. Swingbench 2.6 is now considered production. --#日本語訳#-- SwingbenchはOracleデータベース(12c、18c、19c)に対して負荷テストをするために設計された負荷生成器(ベンチマークツール)です。本サイトからダウンロード可能です。最新のリリースや現在取り組んでいることに関しては私のブログを見てください。 Swingbench 2.6の製造を検討しています。
※現在(2020年1月10日時点)で最新バージョンは2.6がリリースされています。
もっと具体的なところまで踏み込むと以下の特徴があります。
・Javaで書かれている(動作にはJVMが必要)
・OLTPの負荷とOLAPの負荷のシナリオが複数用意されている
・Oracle Database用に設計されており、RACにも対応している
・GUIも用意されており、負荷中のモニタリングも可能
・簡単なOSの性能もモニタリング可能
6つのシナリオ
Swingbenchには6つのシナリオが用意されています
適当に読み取れる情報からまとめてみました。(内容の正しさは保証できないので参考程度に)
(画像読めない場合に備えて表)
シナリオ |
種別 |
概要 |
---|---|---|
SOE または OE (Simple Order Entry) |
OLTP |
注文入力(管理)システムをモデルとしたワークロード。TPC-Cのようなベンチマークを実施できる。(SwingbenchでOLTPの負荷をかけるならこれ) |
CC (Calling Circle) |
OLTP |
コールセンターのシステムをモデルとしたワークロード。SOEよりも高い負荷をかけるできる(ややこしいのであまり使わない?) |
SH (Sales History) |
OLAP |
販売実績確認をモデルとしたワークロード |
TPCDS (TPCDS Like Workload) |
OLAP |
TPC-DSのようなワークロード。クエリ版とトランザクション版の2種類を用意 |
JSON (JSON Workload) |
? |
空港の搭乗処理をモデルとしたJSONに対するCRUD処理のワークロード。※Simple Oracle Document Access (SODA)(NoSQL形式のAPIセット)を使用している模様 |
Stress_Test |
? |
単純なCRUD処理のワークロードを実施できる |
インストール手順
今回はインターネットに接続出来る状態のOracle Linux7.7に導入する手順を書いておきます。
インストール要件のJVMの確認
# javaのバージョンを確認(バージョンが8であること) java -version # Javaがいなければ、openjdkの8をインストール(デフォルトとかは8かわからないので明示的にインストールする) yum install -y java-1.8.0-openjdk # javaのバージョンを確認(バージョンが8であること) java -version
Swingbenchのファイルをダウンロード
# /var/tmpフォルダにSwingbenchインストーラーをダウンロード # ダウンロード元:http://www.dominicgiles.com/swingbench/swingbenchlatest.zip ls -l /var/tmp/ # ダウンロード実施(wgetのインストールが必要な場合はインストールから) yum install wget wget http://www.dominicgiles.com/swingbench/swingbenchlatest.zip -O /var/tmp/swingbenchlatest.zip # ダウンロードしたファイルの確認 ls -l /var/tmp/swingbench*
解凍して権限を変更
# 解凍先:/opt/swingbenchの確認(任意に変えてください)) ls -ld /opt/swingbench # 解凍する(unzipがインストールされていない場合はインストールから) yum install unzip unzip -q /var/tmp/swingbenchlatest.zip -d /opt # 権限の操作(めんどくさいので777に設定。細かく設定する必要があればどうぞ) chmod -R 777 /opt/swingbench # インストールディレクトリの確認 ls -ld /opt/swingbench ls -l /opt/swingbench
以上で終了です。
Sales Order Entry (SOE)のシナリオでベンチマークする手順
おまけとして、今回はSOEベンチマークを実施する手順を紹介します。
SOEスキーマの中身や実施しているトランザクション(SQL)がどんな感じなのかは時間を見つけてまとめてみようと思っています。
実施する手順の概要は次の通りです。
1) SOEベンチマーク用のスキーマを用意
2) SOEベンチマークの実施
1) SOEベンチマーク用のスキーマを用意
SOEベンチマークは事前にスキーマが作成されていて、そこにトランザクションが投げられるような負荷が発生します。
つまり、最初にスキーマを作成し、大量のデータをロードするステップが必要になります。
そのために使用するのがoewizardです。
今回はGUIベースで操作する手順です。
(非対話的に設定することも可能です。その場合はwizard用のconfigファイルがあるので編集して使用します。詳しくは実際のconfigファイルやwizardのヘルプ(-hオプション)を見てみましょう。変更する箇所は以下のウィザードの画面を参考にしながらあたりをつけてみてください。)
# oewizardの起動(X windowを使用する場合はDISPLAY変数等を通しておきましょう) cd /opt/swingbench/bin LANG=C ./oewizard
この後はログ用のウィンドウが追加で開いたりします。
進行状況をモニターしたり休憩したりしましょう ^^) _旦~~
終わったら×かcancelボタンをクリックしてウィザードを閉じます。
2) SOEベンチマークの実施
ベンチマーク実行ツールは3つ用意されています。
①swingbench:GUIベースでベンチマークの設定から実行・モニタリングまでできます。
②minibench:①の軽量版です。設定ができずモニタリングに特化しています。
③charbench:CLIベースのベンチマーク実行が可能です。
①swingbenchを使用する場合
cd /opt/swingbench/bin LANG=C ./swingbench
②minibenchも同様です。
cd /opt/swingbench/bin LANG=C ./minibench
③charbenchはいろいろオプションで指定して好みのアウトプットを得ましょう
以下は例です。
cd /opt/swingbench/bin charbench -c ../config/SOE_Server_Side_V2 \ -cs //<ホスト名>/<サービス名> \ -p <パスワード> \ -f <結果ファイル名> \ -rt <実行時間※hh:mm.sec形式で指定> \ -v tpm,tps,resp,vresp \ -vo <冗長出力ファイルのファイル名>
結果はxml形式で出力されますが、いまいち情報量が足りないので-vや-voを出しておくようにしています。
最後に
慣れると簡単にベンチマークができるので、素晴らしいツールですね。
作成者のDominic Gilesさんに感謝!!
【おまけ】
charbenchのヘルプを確認
[oracle@ol77-sb bin]$ charbench -h usage: parameters: -D <variable=value> use value for given environment variable -a run automatically -be <stopafter> end recording statistics after. Value is in the form hh:mm.sec -bg indicate that charbench will be run in the background -bs <startafter> start recording statistics after. Value is in the form hh:mm.sec -c <filename> specify config file -cf <username> the location of a crendentials file for Oracle Cloud (ADW/ATP./ExaExp) -co <hostname> specify/override coordinator in configuration file. -com <comment> specify comment for this benchmark run (in double quotes) -cpuloc <hostname > specify/overide location/hostname of the cpu monitor. -cpupass specify/overide os password of the user used to monitor cpu. -cpuuser specify/overide os username of the user used to monitor cpu. -cs <connectstring> override connect string in configuration file -dbap <password> the password of admin user (used for collecting DB Stats) -dbau <username> the username of admin user (used for collecting DB stats) -debug turn on debugging. Written to standard out -debugf turn on debugging. Witten to debug.log. -debugfine turn on finest level of debugging -di <shortname(s)> disable transactions(s) by short name, comma separated -dt <drivertype> override driver type in configuration file (thin, oci, ttdirect, ttclient) -dumptx output transaction response times to file -dumptxdir <directory name> directory for transaction response times files -en <shortname(s)> enable transactions(s) by short name, comma separated -env display environment configuration -f force data collection and run termination regardless of state -g <groupID> distributed group identifier -h,--help print this message -i run interactively (default) -intermax <milliseconds> override minimum inter transaction sleep time (default = 0) -intermin <milliseconds> override minimum inter transaction sleep time (default = 0) -ld <milliseconds> specify/overide the logon delay (milliseconds) -max <milliseconds> override maximum intra transaction think time in configuration file -min <milliseconds> override minimum intra transaction think time in configuration file -mr produce a mini report of the results of a run -mt <maxtrans> maximum tasks to be executed before terminating run -nr don't produce a results file at the end of a run -p <password> override password in configuration file -r <filename> specify results file -rr specify/overide refresh rate for charts in secs -rt <runtime> specify/overide run time for the benchmark. Value is in the form hh:mm.sec -s run silent -stats <stats level> specify level result stats detail (full or simple) -u <username> override username in configuration file -uc <user count> override user count in configuration file. -v <options> display run statistics (vmstat/sar like output), options include (comma separated no spaces). trans|cpu|disk|dml|errs|tpm|tps|users|resp|vresp|tottx|trem -ver display version and exit -vo <verboseOutput> output file for verbose output (defaults to stdout) -wc wait until all session have disconnected from the database [oracle@ol77-sb bin]$
【捕捉】2020/01/19時点でswingbenchのサイトにつながらない状態です。。。しばらくしたら治るかな?