安裝和使用 TPCC-MySQL 工具遇到的問題
阿新 • • 發佈:2018-12-23
本文主要講述 TPCC-MySQL 工具在獲取和使用時遇到的問題。
============= 我是分割線 ===============
Tpcc-mysql 是 percona 基於 tpcc 衍生出來的產品,專用於 mysql 基準測試,其原始碼放在 bazaar 上( Bazaar 是一個分散式的版本控制系統,採用 GPL 許可協議,可運行於 Windows、GNU/Linux、UNIX 以及 Mac OS 系統之上。Bazaar 由 Canonical 公司(Ubuntu 母公司)贊助),因此還需要先安裝 bazaar 客戶端。
【TPC-C】
TPC-C 是 TPC(Transaction Processing Performance Council ) 組織釋出的一個測試規範,用於模擬測試複雜的線上事務處理系統。其測試結果包括每分鐘事務數(tpmC),以及每事務的成本(Price/tpmC )。在進行大壓力下 MySQL 的一些行為時經常使用。
【工具的獲取】
1. 安裝 bzr 客戶端
可以通過 yum -y install bzr 方式安裝 bzr ,但預設會安裝到 /usr/lib64/python2.4/site-packages 之中(我的系統為 CentOS release 5.6 (Final) )。如果希望安裝的位置是 /usr/local/lib/python2.7/site-packages ,通過 yum 方式可能無法滿足(或者說我不知道怎麼操作)。於是採用 pip 方式安裝。
?
安裝成功後,可以看到
?
2. 用 bzr 客戶端下載 tpcc-mysql 原始碼
首先需要登入到 https://launchpad.net/bzr 上註冊帳號(假設註冊後用戶 ID 為 special-agent ),並登陸。
然後需要在 linux 下生成 SSH 使用的金鑰。
?
之後將公鑰所在檔案 id_rsa.pub 的內容複製到 https://launchpad.net/~special-agent/+editsshkeys 中的輸入框中,並提交(紅色部分換成你自己的 UserID)。
最後通過 bzr 命令下載 tpcc-mysql 原始碼。
?
?
?
檢視下載下來的檔案。
?
可能需要對 Makefile 檔案做調整才能通過編譯。我的 改動如下:
?
執行 make 後生成工具 tpcc_load 和 tpcc_start 。
?
檢視 README 檔案的內容(簡單實用的說明)
?
檢視兩個工具的幫助命令。
?
?
【工具的簡單使用】
建立庫 tpcc100 。
?
建立表。
?
建立索引和 FK 。
?
建立 100 個數據倉庫並填充資料(即使100個倉庫也花了好久時間)。
?
對 100 個數據倉庫,預熱 120 秒,100 個併發連線,執行 3600 秒, 結果存放在檔案 tpcc100_20130730 中。
?
============= 我是分割線 ===============
Tpcc-mysql 是 percona 基於 tpcc 衍生出來的產品,專用於 mysql 基準測試,其原始碼放在 bazaar 上( Bazaar 是一個分散式的版本控制系統,採用 GPL 許可協議,可運行於 Windows、GNU/Linux、UNIX 以及 Mac OS 系統之上。Bazaar 由 Canonical 公司(Ubuntu 母公司)贊助),因此還需要先安裝 bazaar 客戶端。
【TPC-C】
TPC-C 是 TPC(Transaction Processing Performance Council
【工具的獲取】
1. 安裝 bzr 客戶端
可以通過 yum -y install bzr 方式安裝 bzr ,但預設會安裝到 /usr/lib64/python2.4/site-packages 之中(我的系統為 CentOS release 5.6 (Final) )。如果希望安裝的位置是 /usr/local/lib/python2.7/site-packages ,通過 yum 方式可能無法滿足(或者說我不知道怎麼操作)。於是採用 pip 方式安裝。
?
1 | [[email protected] site-packages] # pip install bzr |
?
1234567 | [[email protected] site-packages] # pip show bzr --- Name: bzr Version: 2.6.0 Location: /usr/local/lib/python2 .7 /site-packages Requires: [[email protected] site-packages] # |
2. 用 bzr 客戶端下載 tpcc-mysql 原始碼
首先需要登入到 https://launchpad.net/bzr
然後需要在 linux 下生成 SSH 使用的金鑰。
?
1234567891011 | [[email protected] WGET_DIR] # ssh-keygen -t rsa Generating public /private rsa key pair. Enter file in which to save the key ( /root/ . ssh /id_rsa ): Created directory '/root/.ssh' . Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/ . ssh /id_rsa . Your public key has been saved in /root/ . ssh /id_rsa .pub. The key fingerprint is: 17:b3:91:e6:b2:47:5c:15:5f:d6:ee:8a:d8:b1:5c:da [email protected] [[email protected] WGET_DIR] # |
最後通過 bzr 命令下載 tpcc-mysql 原始碼。
?
123456789101112131415161718192021222324252627 | [[email protected] WGET_DIR] # bzr help launchpad-login Purpose: Show or set the Launchpad user ID. Usage: bzr launchpad-login [NAME] Options: --usage Show usage message and options. --no-check Don't check that the user name is valid. -q, --quiet Only display errors and warnings. - v , --verbose Display more information. -h, --help Show help message. Description: When communicating with Launchpad, some commands need to know your Launchpad user ID. This command can be used to set or show the user ID that Bazaar will use for such communication. Examples: Show the Launchpad ID of the current user: bzr launchpad-login Set the Launchpad ID of the current user to 'bob' : bzr launchpad-login bob Aliases: lp-login From: plugin "launchpad" |
1 | [[email protected] WGET_DIR] # bzr launchpad-login special-agent |
1234567 | [[email protected] WGET_DIR] # bzr branch lp:~percona-dev/perconatools/tpcc-mysql The authenticity of host 'bazaar.launchpad.net (91.189.95.84)' can't be established. RSA key fingerprint is 9d:38:3a:63:b1:d5:6f:c4:44:67:53:49:2e:ee:fc:89. Are you sure you want to continue connecting ( yes /no )? yes Warning: Permanently added 'bazaar.launchpad.net,91.189.95.84' (RSA) to the list of known hosts. Branched 48 revisions. [[email protected] WGET_DIR] # |
檢視下載下來的檔案。
?
123456789101112 | [[email protected] WGET_DIR] # ll tpcc-mysql/ total 36 -rw-r--r-- 1 root root 851 Jul 30 14:30 README -rw-r--r-- 1 root root 1621 Jul 30 14:30 add_fkey_idx.sql -rw-r--r-- 1 root root 317 Jul 30 14:30 count.sql -rw-r--r-- 1 root root 3105 Jul 30 14:30 create_table.sql -rw-r--r-- 1 root root 763 Jul 30 14:30 drop_cons.sql -rw-r--r-- 1 root root 477 Jul 30 14:30 load.sh drwxr-xr-x 2 root root 4096 Jul 30 14:30 schema2 drwxr-xr-x 5 root root 4096 Jul 30 14:30 scripts drwxr-xr-x 2 root root 4096 Jul 30 14:30 src [[email protected] WGET_DIR] # |
可能需要對 Makefile 檔案做調整才能通過編譯。我的 改動如下:
?
123456789101112131415161718192021222324252627 | # # "make all" to build necessary executables. # LIBS= `mysql_config --libs_r` -lrt INC= -I. `mysql_config --include` -I /usr/local/mysql/include/ #DEFS= -DDEBUG CFLAGS= -w -O2 -g TRANSACTIONS= neword.o payment.o ordstat.o delivery.o slev.o OBJS= main.o spt_proc.o driver.o support.o sequence.o rthist.o $(TRANSACTIONS) .SUFFIXES: .SUFFIXES: .o .c .c.o: $(CC) $(CFLAGS) $(INC) $(DEFS) -c $*.c all: .. /tpcc_load .. /tpcc_start .. /tpcc_load : load.o support.o $(CC) load.o support.o $(LIBS) -L /usr/local/mysql/lib/ -o .. /tpcc_load .. /tpcc_start : $(OBJS) $(CC) $(OBJS) $(LIBS) -L /usr/local/mysql/lib/ -o .. /tpcc_start clean : rm -f *.o |
執行 make 後生成工具 tpcc_load 和 tpcc_start 。
?
1234567891011121314151617 | [[email protected] src] # [[email protected] src] # make cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c load.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c support.c cc load.o support.o `mysql_config --libs_r` -lrt -L /usr/local/mysql/lib/ -o .. /tpcc_load cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c main.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c spt_proc.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c driver.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c sequence.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c rthist.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c neword.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c payment.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c ordstat.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/include/ -c delivery.c cc -w -O2 -g -I. `mysql_config --include` -I /usr/local/mysql/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 -L /usr/local/mysql/lib/ -o .. /tpcc_start [[email protected] src] # |
檢視 README 檔案的內容(簡單實用的說明)
?
123456789101112131415161718192021222324252627 | [[email protected] tpcc-mysql] # vi 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 127.0.0.1:33000 tpcc1000 root "" 1000 | hostname :port| |dbname| |user| |password| |WAREHOUSES| ref. tpcc_load --help for all options - load data in parallel check load.sh script 3. start benchmark * . /tpcc_start -h127.0.0.1 -P33000 -dtpcc1000 -uroot -w1000 -c32 -r10 -l10800 | hostname | |port| |dbname| |user| |WAREHOUSES| |CONNECTIONS| |WARMUP TIME| |BENCHMARK TIME| * ref. tpcc_start --help for all options |
檢視兩個工具的幫助命令。
?
12345678910 | [[email protected] tpcc-mysql] # ./tpcc_load --help ************************************* *** ###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 |
?
1234567 | [[email protected] tpcc-mysql] # ./tpcc_start --help *************************************** *** ###easy### TPC-C Load Generator *** *************************************** . /tpcc_start : invalid option -- - 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 -t trx_file [[email protected] tpcc-mysql] # |
【工具的簡單使用】
建立庫 tpcc100 。
?
123456 | [[email protected] tpcc-mysql] # mysqladmin create tpcc100 mysqladmin: connect to server at 'localhost' failed error: 'Can' t connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)' Check that mysqld is running and that the socket: '/var/lib/mysql/mysql.sock' exists! [[email protected] tpcc-mysql] # [[email protected] tpcc-mysql] # mysqladmin -S /tmp/mysql.sock create tpcc100 |
建立表。
?
1 | [[email protected] tpcc-mysql] # mysql -S /tmp/mysql.sock tpcc100 < create_table.sql |
建立索引和 FK 。
?
1 | [[email protected] tpcc-mysql] # mysql -S /tmp/mysql.sock tpcc100 < add_fkey_idx.sql |
建立 100 個數據倉庫並填充資料(即使100個倉庫也花了好久時間)。
?
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061 | [[email protected] tpcc-mysql] # [[email protected] tpcc-mysql] # ./tpcc_load localhost tpcc100 root "" 100 ************************************* *** ###easy### TPC-C Data Loader *** ************************************* <Parameters> [server]: localhost [port]: 3306 [DBname]: tpcc100 [user]: root [pass]: [warehouse]: 100 TPCC Data Load Started... Loading Item .................................................. 5000 .................................................. 10000 .................................................. 15000 ... Loading Orders for D=4, W= 100 .......... 1000 .......... 2000 .......... 3000 Orders Done. Loading Orders for D=5, W= 100 .......... 1000 .......... 2000 .......... 3000 Orders Done. Loading Orders for D=6, W= 100 .......... 1000 .......... 2000 .......... 3000 Orders Done. Loading Orders for D=7, W= 100 .......... 1000 .......... 2000 .......... 3000 Orders Done. Loading Orders for D=8, W= 100 .......... 1000 .......... 2000 .......... 3000 Orders Done. Loading Orders for D=9, W= 100 .......... 1000 .......... 2000 .......... 3000 Orders Done. Loading Orders for D=10, W= 100 .......... 1000 .......... 2000 .......... 3000 Orders Done. ...DATA LOADING COMPLETED SUCCESSFULLY. [[email protected] tpcc-mysql] # |
對 100 個數據倉庫,預熱 120 秒,100 個併發連線,執行 3600 秒, 結果存放在檔案 tpcc100_20130730 中。
?
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |