tpcc-mysqlを利用してのMYSQLベンチマーク
MS SQLのTPCCベンチマークをMS調布オフィスにて検証させて頂いた事があるが、
MYSQLにもTPCCベンチマークツールがあるのを聞いたので検証してみました。
※perconaが提供しているMYSQLのTPCCベンチマークツールです。
BZRが必要という事なのでインストール
[root@CentOS64VM ~]# yum install bzr Loaded plugins: fastestmirror, presto Loading mirror speeds from cached hostfile * base: www.ftp.ne.jp * extras: www.ftp.ne.jp * updates: www.ftp.ne.jp Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package bzr.x86_64 0:2.1.1-2.el6 will be installed --> Processing Dependency: python-paramiko for package: bzr-2.1.1-2.el6.x86_64 --> Running transaction check ---> Package python-paramiko.noarch 0:1.7.5-2.1.el6 will be installed --> Processing Dependency: python-crypto >= 1.9 for package: python-paramiko-1.7.5-2.1.el6.noarch --> Running transaction check ---> Package python-crypto.x86_64 0:2.0.1-22.el6 will be installed --> Finished Dependency Resolution ==================================================================================== Install 3 Package(s) Total download size: 6.2 M Installed size: 32 M Is this ok [y/N]: y Downloading Packages: Setting up and reading Presto delta metadata Processing delta metadata Package(s) data still to download: 6.2 M (1/3): bzr-2.1.1-2.el6.x86_64.rpm | 5.3 MB 00:02 (2/3): python-crypto-2.0.1-22.el6.x86_64.rpm | 159 kB 00:00 (3/3): python-paramiko-1.7.5-2.1.el6.noarch.rpm | 728 kB 00:00 ------------------------------------------------------------------------------------ ====================================================================================
bazaarフォルダーを作成してtpcc-mysqlのソースをダウンロード
[root@CentOS64VM tools]# mkdir bazaar [root@CentOS64VM tools]# ls -l 合計 59468 -r--r--r--. 1 root root 60883070 6月 9 10:59 2012 VMwareTools-8.8.4-743747.tar.gz drwxr-xr-x. 2 root root 4096 7月 16 12:47 2012 bazaar drwxr-xr-x. 7 root root 4096 6月 9 10:59 2012 vmware-tools-distrib [root@CentOS64VM tools]# [root@CentOS64VM bazaar]# bzr init Created a standalone tree (format: 2a) [root@CentOS64VM bazaar]# ls -la 合計 12 drwxr-xr-x. 3 root root 4096 7月 16 12:48 2012 . drwxr-xr-x. 4 root root 4096 7月 16 12:47 2012 .. drwxr-xr-x. 6 root root 4096 7月 16 12:48 2012 .bzr [root@CentOS64VM bazaar]# [root@CentOS64VM bazaar]# bzr branch lp:~percona-dev/perconatools/tpcc-mysql You have not informed bzr of your Launchpad ID, and you must do this to write to Launchpad or access private data. See "bzr help launchpad-login". Branched 42 revision(s). [root@CentOS64VM bazaar]# [root@CentOS64VM bazaar]# ls tpcc-mysql [root@CentOS64VM bazaar]# cd tpcc-mysql/ [root@CentOS64VM tpcc-mysql]# ls -l 合計 36 -rw-r--r--. 1 root root 749 7月 16 12:50 2012 README -rw-r--r--. 1 root root 1621 7月 16 12:50 2012 add_fkey_idx.sql -rw-r--r--. 1 root root 317 7月 16 12:50 2012 count.sql -rw-r--r--. 1 root root 3105 7月 16 12:50 2012 create_table.sql -rw-r--r--. 1 root root 763 7月 16 12:50 2012 drop_cons.sql -rw-r--r--. 1 root root 477 7月 16 12:50 2012 load.sh drwxr-xr-x. 2 root root 4096 7月 16 12:50 2012 schema2 drwxr-xr-x. 5 root root 4096 7月 16 12:50 2012 scripts drwxr-xr-x. 2 root root 4096 7月 16 12:50 2012 src [root@CentOS64VM tpcc-mysql]#
MYSQL関連ファイルのインストール
※バイナリー(Linux – Generic 2.6 (x86, 64-bit), Compressed TAR Archive)
を利用して予めMYSQLを設定したのですが、TPCCの検証でセグメントエラーが出てしまったので
MYSQLも検証の為だけに一度RPMからインストールしました。↓
【課題】
自分でMYSQLSERVER(コンパイル済みバイナリー)を設定して、
他のMYSQLパッケージをRPMでインストールした場合、実際に負荷をかけるtpcc_startの処理が失敗した。
エラーは、セグメンテーション違反(英語:segmentation fault)。
tpcc_loadの時は、Socket接続エラーが出たのでシンボリックリンクを作成して対応。
「ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock」
しかし、tpcc_startは失敗してしまったので、結局MYSQL ServerもRPMからインストールしたら問題無く処理された。
rpm -U --force MySQL-server-5.5.25a-1.linux2.6.x86_64.rpm
パスだけの問題?後日確認する。
[root@CentOS64VM tools]# ls -l MySQL-* -rw-rw-r--. 1 root root 17644285 7月 16 13:54 2012 MySQL-client-5.5.25a-1.linux2.6.x86_64.rpm -rw-rw-r--. 1 root root 6460556 7月 16 13:00 2012 MySQL-devel-5.5.25a-1.linux2.6.x86_64.rpm -rw-rw-r--. 1 root root 67059427 7月 16 14:02 2012 MySQL-embedded-5.5.25a-1.linux2.6.x86_64.rpm -rw-rw-r--. 1 root root 53387152 7月 16 16:37 2012 MySQL-server-5.5.25a-1.linux2.6.x86_64.rpm -rw-rw-r--. 1 root root 2010686 7月 16 14:01 2012 MySQL-shared-5.5.25a-1.linux2.6.x86_64.rpm -rw-rw-r--. 1 root root 5175183 7月 16 14:02 2012 MySQL-shared-compat-5.5.25a-1.linux2.6.x86_64.rpm -rw-rw-r--. 1 root root 41228968 7月 16 14:02 2012 MySQL-test-5.5.25a-1.linux2.6.x86_64.rpm [root@CentOS64VM tools]#
MYSQL関連のパッケージをインストールしたので、TPCC-MYSQLのコンパイル
———————————————————————————
README
———————————————————————————
[root@CentOS64VM tpcc-mysql]# cat README 1. Build binaries * cd scr ; make ( you should have mysql_config available in $PATH) 2. Load data * create database mysqladmin create tpcc1000 * create tables mysql tpcc1000 < create_table.sql * create indexes and FK ( this step can be done after loading data) mysql tpcc1000 < add_fkey_idx.sql * populate data - simple step tpcc_load localhost tpcc1000 root "" 1000 |hostname| |dbname| |user| |password| |WAREHOUSES| - load data in parallel check load.sh script 3. start benchmark * tpcc_start localhost tpcc1000 root "" 1000 32 10 10800 |hostname| |dbname| |user| |password| |WAREHOUSES| |CONNECTIONS| |WARMUP TIME| |BENCHMARK TIME| [root@CentOS64VM tpcc-mysql]# [root@CentOS64VM src]# pwd /home/tools/bazaar/tpcc-mysql/src [root@CentOS64VM src]# make all cc load.o support.o `mysql_config --libs_r` -lrt -o ../tpcc_load cc -w -O2 -g -I. `mysql_config --include` -c main.c cc -w -O2 -g -I. `mysql_config --include` -c spt_proc.c cc -w -O2 -g -I. `mysql_config --include` -c driver.c cc -w -O2 -g -I. `mysql_config --include` -c sequence.c cc -w -O2 -g -I. `mysql_config --include` -c rthist.c cc -w -O2 -g -I. `mysql_config --include` -c neword.c cc -w -O2 -g -I. `mysql_config --include` -c payment.c cc -w -O2 -g -I. `mysql_config --include` -c ordstat.c cc -w -O2 -g -I. `mysql_config --include` -c delivery.c cc -w -O2 -g -I. `mysql_config --include` -c slev.c cc main.o spt_proc.o driver.o support.o sequence.o rthist.o neword.o payment.o ordstat.o delivery.o slev.o `mysql_config --libs_r` -lrt -o ../tpcc_start [root@CentOS64VM src]# [/SHELL] <a href="http://variable.jp/wp-content/uploads/2012/07/tpcc-mysql.jpg"><img src="http://variable.jp/wp-content/uploads/2012/07/tpcc-mysql.jpg" alt="tpcc-mysql" title="tpcc-mysql" width="735" height="498" /></a> <strong>tpcc_loadがデータ生成プログラム</strong> <strong>tpcc_startが負荷生成プログラム</strong> [SHELL] [root@CentOS64VM tpcc-mysql]# pwd /home/tools/bazaar/tpcc-mysql [root@CentOS64VM tpcc-mysql]# ls -l 合計 248 -rw-r--r--. 1 root root 749 7月 16 12:50 2012 README -rw-r--r--. 1 root root 1621 7月 16 12:50 2012 add_fkey_idx.sql -rw-r--r--. 1 root root 317 7月 16 12:50 2012 count.sql -rw-r--r--. 1 root root 3105 7月 16 12:50 2012 create_table.sql -rw-r--r--. 1 root root 763 7月 16 12:50 2012 drop_cons.sql -rw-r--r--. 1 root root 477 7月 16 12:50 2012 load.sh drwxr-xr-x. 2 root root 4096 7月 16 12:50 2012 schema2 drwxr-xr-x. 5 root root 4096 7月 16 12:50 2012 scripts drwxr-xr-x. 2 root root 4096 7月 16 14:09 2012 src -rwxr-xr-x. 1 root root 60273 7月 16 14:08 2012 tpcc_load -rwxr-xr-x. 1 root root 153141 7月 16 14:09 2012 tpcc_start [root@CentOS64VM tpcc-mysql]#
TPCC用のDBとユーザーの作成
mysql> create database tpcc; Query OK, 1 row affected (0.01 sec) mysql> grant all privileges on tpcc.* to tpcc@'%' identified by 'tpcc-mysql-pass'; Query OK, 0 rows affected (0.14 sec) mysql> [root@CentOS64VM tpcc-mysql]# mysql -u tpcc -p tpcc < create_table.sql Enter password: [root@CentOS64VM tpcc-mysql]# mysql -u tpcc -p tpcc < add_fkey_idx.sql Enter password: [root@CentOS64VM tpcc-mysql]# [/SHELL] <a href="http://variable.jp/wp-content/uploads/2012/07/tpcc-create-tables.jpg"><img src="http://variable.jp/wp-content/uploads/2012/07/tpcc-create-tables.jpg" alt="table" title="tpcc-create-tables" width="603" height="298" /></a> <a href="http://variable.jp/wp-content/uploads/2012/07/tpcc-tables.jpg"><img src="http://variable.jp/wp-content/uploads/2012/07/tpcc-tables.jpg" alt="tables" title="tpcc-tables" width="494" height="296" /></a> <strong>検証用データのロード</strong> [SHELL] [root@CentOS64VM tpcc-mysql]# ./tpcc_load ************************************* *** ###easy### TPC-C Data Loader *** ************************************* usage: tpcc_load [server] [DB] [user] [pass] [warehouse] OR tpcc_load [server] [DB] [user] [pass] [warehouse] [part] [min_wh] [max_wh] * [part]: 1=ITEMS 2=WAREHOUSE 3=CUSTOMER 4=ORDERS [root@CentOS64VM tpcc-mysql]# tpcc_loadにはwarehouseというパラメータを付与する。 warehouse表のレコード数になります。 warehouse表のレコード数によってその他のテーブルのレコード数が決まるので、 この値がスケールファクターになります。 1 warehouse(以下WH)あたりデータベース容量が約100MB増加するとの事。 [root@CentOS64VM tpcc-mysql]# ./tpcc_load localhost tpcc tpcc tpcc-mysql-pass 2 ************************************* *** ###easy### TPC-C Data Loader *** ************************************* <Parameters> [server]: localhost [port]: 3306 [DBname]: tpcc [user]: tpcc [pass]: tpcc-mysql-pass [warehouse]: 2 TPCC Data Load Started... Loading Item .................................................. 5000 .................................................. 10000 .................................................. 15000 .................................................. 20000 .................................................. 25000 .................................................. 30000 [省略] Orders Done. Loading Orders for D=8, W= 2 .......... 1000 .......... 2000 .......... 3000 Orders Done. Loading Orders for D=9, W= 2 .......... 1000 .......... 2000 .......... 3000 Orders Done. Loading Orders for D=10, W= 2 .......... 1000 .......... 2000 .......... 3000 Orders Done. ...DATA LOADING COMPLETED SUCCESSFULLY. [root@CentOS64VM tpcc-mysql]#
tpcc_startを実行して負荷をかけ、実際のベンチマーク開始。
※データを更新したりするので、数回実行するのであればバックアップを取得しておいた方が良い。
[root@CentOS64VM tpcc-mysql]$ ./tpcc_start -h *************************************** *** ###easy### TPC-C Load Generator *** *************************************** ./tpcc_start: option requires an argument -- 'h' Usage: tpcc_start -h server_host -P port -d database_name -u mysql_user -p mysql_password -w warehouses -c connections -r warmup_time -l running_time -i report_interval -f report_file [root@CentOS64VM tpcc-mysql]$ [root@CentOS64VM tpcc-mysql]# ./tpcc_start -h localhost -d tpcc -u tpcc -p tpcc-mysql-pass -w 2 -c 3 -r 60 -l 120 *************************************** *** ###easy### TPC-C Load Generator *** *************************************** option h with value 'localhost' option d with value 'tpcc' option u with value 'tpcc' option p with value 'tpcc-mysql-pass' option w with value '2' option c with value '3' option r with value '60' option l with value '120' <Parameters> [server]: localhost [port]: 3306 [DBname]: tpcc [user]: tpcc [pass]: tpcc-mysql-pass [warehouse]: 2 [connection]: 3 [rampup]: 60 (sec.) [measure]: 120 (sec.) [省略] STOPPING THREADS... <Raw Results> [0] sc:1157 lt:891 rt:0 fl:0 [1] sc:2047 lt:2 rt:0 fl:0 [2] sc:206 lt:0 rt:0 fl:0 [3] sc:205 lt:0 rt:0 fl:0 [4] sc:148 lt:57 rt:0 fl:0 in 120 sec. <Raw Results2(sum ver.)> [0] sc:1157 lt:891 rt:0 fl:0 [1] sc:2047 lt:2 rt:0 fl:0 [2] sc:206 lt:0 rt:0 fl:0 [3] sc:205 lt:0 rt:0 fl:0 [4] sc:148 lt:57 rt:0 fl:0 <Constraint Check> (all must be [OK]) [transaction percentage] Payment: 43.48% (>=43.0%) [OK] Order-Status: 4.37% (>= 4.0%) [OK] Delivery: 4.35% (>= 4.0%) [OK] Stock-Level: 4.35% (>= 4.0%) [OK] [response time (at least 90% passed)] New-Order: 56.49% [NG] * Payment: 99.90% [OK] Order-Status: 100.00% [OK] Delivery: 100.00% [OK] Stock-Level: 72.20% [NG] * <TpmC> 1024.000 TpmC [root@CentOS64VM tpcc-mysql]#