Tpcc-MySQL測試並使用gnuplot生成圖表

初始化表結構 






點擊(此處)摺疊或打開 


# 創建測試數據庫, tpcc1000(隨意) 
mysql -uroot -ppwd -e 'create database tpcc1000;' 
# 創建測試帳號:用戶名,密碼都是tpcc 
mysql -uroot -ppwd -e "GRANT ALL ON tpcc1000.* TO 'tpcc'@'127.0.0.1' identified by 'tpcc';flush privileges;" 
# 導入表結構、索引、外鍵等 
mysql -h127.0.0.1 -utpcc -ptpcc tpcc1000 < create_table.sql 
mysql -h127.0.0.1 -utpcc -ptpcc tpcc1000 < add_fkey_idx.sql 


初始化測試數據 

        tpcc_load 生成多少個數據倉庫數據。比較耗時 

點擊(此處)摺疊或打開 


# ./tpcc_load --help 
tpcc_load [server] [DB] [user] [pass] [warehouse] 
Server: 服務器名。host:port[3306] 
DB: 數據庫名 
user: 用戶名 
pass: 密碼 
Warehouse: 倉庫的數量 


    # 本機3306端口, 數據庫tpcc1000, 用戶名密碼都是tpcc, 數據倉庫100個
    ./tpcc_load 127.0.0.1:3306 tpcc1000 tpcc tpcc 100 

進行壓力測試 
    tpcc_start 進行壓力測試
#./tpcc_start --help 
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 
-h server_host: 服務器名 
-P port : 端口號,默認爲3306 
-d database_name: 數據庫名 
-u mysql_user : 用戶名 
-p mysql_password : 密碼 
-w warehouses: 倉庫的數量 
-c connections : 線程數,默認爲1 
-r warmup_time : 熱身時間,單位:s,默認爲10s ,熱身是爲了將數據加載到內存。 
-l running_time: 測試時間,單位:s,默認爲20s 
-i report_interval: 指定生成報告間隔時長 
-f report_file: 測試結果輸出文件 

注意
tpcc 默認會讀取/var/lib/mysql/mysql.sock 這個socket位置,
 如果mysql socket不在相應路徑的話,就需要做個軟連接,或者通過TCP/IP的方式連接測試服務器。

    # 10個倉庫,100個線程,熱身30秒,測試120秒,輸出到 tpcc.out
     ./tpcc_start -h127.0.0.1 -p3306 -dtpcc1000 -utpcc -ptpcc -w10 -c100 -r30 -l120  > tpcc.out
     # 下一步分析腳本將分析藍色部分的數據

點擊(此處)摺疊或打開 


*************************************** 
*** ###easy### TPC-C Load Generator *** 
*************************************** 
option h with value \'127.0.0.1\' 
option p with value \'3306\' 
option d with value \'tpcc1000\' 
option u with value \'tpcc\' 
option p with value \'tpcc\' 
option w with value \'10\' 
option c with value \'100\' 
option r with value \'30\' 
option l with value \'120\' 
option f with value \'tpcc.out\' 
<Parameters> 
[server]: 127.0.0.1 
[port]: 3306 
[DBname]: tpcc1000 
[user]: tpcc 
[pass]: tpcc 
[warehouse]: 10 
[connection]: 100 
[rampup]: 30 (sec.) 
[measure]: 120 (sec.) 


RAMP-UP TIME.(30 sec.) 


MEASURING START. 


 10, 153(0):2.453|2.829, 166(0):0.651|1.130, 17(0):0.352|0.466, 17(0):2.770|3.007, 23(0):7.171|7.935 
 20, 165(0):2.380|2.450, 156(0):0.457|0.484, 15(0):0.229|0.262, 18(0):2.653|2.688, 18(0):6.136|6.839 
 30, 162(0):2.372|2.440, 164(0):0.480|0.487, 17(0):0.269|0.272, 13(0):2.703|2.729, 17(0):6.009|6.535 
 40, 171(0):2.484|2.542, 171(0):0.478|0.493, 17(0):0.218|0.245, 18(0):2.811|2.854, 15(0):6.296|6.490 
 50, 173(0):2.437|2.515, 181(0):0.476|0.483, 18(0):0.233|0.240, 15(0):2.678|2.706, 19(0):6.402|6.762 
 60, 184(0):2.412|2.419, 205(0):0.459|0.488, 19(0):0.226|0.235, 21(0):2.700|2.726, 17(0):6.065|6.071 
 70, 182(0):2.322|2.438, 162(0):0.467|0.482, 18(0):0.228|0.233, 18(0):2.759|2.841, 19(0):6.177|6.368 
 80, 157(0):2.426|2.576, 164(0):0.468|0.476, 16(0):0.228|0.233, 15(0):2.671|2.707, 17(0):6.156|6.851 
 90, 188(0):2.459|2.484, 165(0):0.508|0.515, 18(0):0.261|0.274, 19(0):2.749|2.776, 18(0):6.283|6.402 
 100, 175(0):2.422|2.440, 195(0):0.484|0.493, 18(0):0.248|0.255, 17(0):2.657|2.664, 18(0):6.132|6.190 
 110, 176(0):2.346|2.398, 164(0):0.484|0.509, 17(0):0.228|0.229, 19(0):2.830|2.853, 18(0):6.128|6.452 
 120, 169(0):2.526|2.559, 176(0):0.514|0.553, 17(0):0.257|0.263, 16(0):2.781|3.103, 16(0):6.142|6.259 


STOPPING THREADS.................................................................................................... 


<Raw Results> 
[0] sc:2055 lt:0 rt:0 fl:0 
[1] sc:2069 lt:0 rt:0 fl:0 
[2] sc:207 lt:0 rt:0 fl:0 
[3] sc:206 lt:0 rt:0 fl:0 
[4] sc:215 lt:0 rt:0 fl:0 
in 120 sec. 


<Raw Results2(sum ver.)> 
[0] sc:2055 lt:0 rt:0 fl:0 
[1] sc:2076 lt:0 rt:0 fl:0 
[2] sc:207 lt:0 rt:0 fl:0 
[3] sc:207 lt:0 rt:0 fl:0 
[4] sc:215 lt:0 rt:0 fl:0 


<Constraint Check> (all must be [OK]) 
[transaction percentage] 
Payment: 43.54% (>=43.0%) [OK] 
Order-Status: 4.36% (>= 4.0%) [OK] 
Delivery: 4.34% (>= 4.0%) [OK] 
Stock-Level: 4.52% (>= 4.0%) [OK] 
[response time (at least 90% passed)] 
New-Order: 100.00% [OK] 
Payment: 100.00% [OK] 
Order-Status: 100.00% [OK] 
Delivery: 100.00% [OK] 
Stock-Level: 100.00% [OK] 


<TpmC> 
1027.500 TpmC 



1. 業務邏輯
tpcc包括了4個業務邏輯: 1. New-Order:新訂單 
2. Order-Status:支付 
3. Delivery:發貨 
4. Stock-Level:庫存 


2. late的定義
 根據不同的業務,late的定義也不同,4種業務邏輯分別對操作延遲定義的界限值如下所示:
1. Payment 5ms 
2. Order-Status 5ms 
3. Delivery 80ms 
4. Stock-Level 20ms 


3. 數據意義
10, 2286(0):1.373|1.590, 2283(0):0.279|0.398, 228(0):0.148|0.208, 229(0):1.604|1.863, 228(0):4.438|4.993


二到六列數值組成格式是:  成功執行的次數(推遲執行的次數):90%事務的相應時間|最大相應時間 
 這一行有6列數據,意思分別是 1. 第一列:因爲是10秒輸出一句,所以這裏代表的數據是0-10秒之間的結果。 
2. 第二列:這一列是總的結果 
3. 第三列:新訂單業務的結果 
4. 第四列:支付業務的結果 
5. 第五列:發貨業務的結果 
6. 第六列:庫存業務的結果
這裏我們主要關注總的結果就行了。 


4. TmpC的意義
tpmC是代表每分鐘事務處理的數量。 


分析測試數據 


    # 分析測試結果,並保存到tpcc.ana文件中
    sh tpcc-analyze.sh tpcc.out > tpcc.ana


     # 正常情況下會進行多個測試,則需要對每個結果進行分析,併產生相應的分析結果
    # 測試分類: 同配置,同線程數,不同測試時間; 同配置,不同線程數; 不同配置
    sh tpcc-analyze.sh tpcc.out.1 > tpcc.ana.1
    sh tpcc-analyze.sh tpcc.out.2 > tpcc.ana.2
    sh tpcc-analyze.sh tpcc.out.3 > tpcc.ana.3


     # 合併分析結果(此出爲2個)
     paste tpcc.ana.1 tpcc.ana.2 > tpcc-graph.data




繪圖(使用分析結果) 


    gnuplot使用說明


    ./tpcc-graph-build.sh tpcc-graph.data tpcc-graph.jpg


附shell腳本 

 tpcc-analyze.sh

TIMESLOT=1 
if [ -n \"$2\" ] 
then 
TIMESLOT=$2 
echo “Defined $2″ 
fi 
cat $1 | grep -v HY000 | grep -v payment | grep -v neword | awk -v timeslot=$TIMESLOT 'BEGIN { FS=”[,():]“; s=0; cntr=0; aggr=0 } /MEASURING START/ { s=1} /STOPPING THREADS/ {s=0} /0/ { if (s==1) { cntr++; aggr+=$2; } if ( cntr==timeslot ) { printf (“%d %3d\\n”,$1,(aggr/’$TIMESLOT’)) ; cntr=0; aggr=0 } }' 

 


 tpcc-graph-build.sh
#!/bin/bash 
### goto user homedir and remove previous file 
rm -f ‘$2′ 
gnuplot << EOP 
### set data source file 
datafile = ‘$1′ 
### set graph type and size 
set terminal jpeg size 640,480 
### set titles 
set grid x y 
set xlabel “Time (sec)” 
set ylabel “Transactions” 
### set output filename 
set output ‘$2′ 
### build graph 
# plot datafile with lines 
plot datafile using 1:2 title “Test Result 1: XXX ” with lines, \ 
    datafile using 3:4 title “Test Result 2: XXX ” with lines axes x1y1 

EOP 



參考:
[1]: http://blog.csdn.net/kyle__shaw/article/details/9666661 
[2]: http://www.mysqlperformanceblog.com/2013/07/01/tpcc-mysql-simple-usage-steps-and-how-to-build-graphs-with-gnuplot/
[3]: http://blog.chinaunix.net/uid-25266990-id-4080103.html 


發佈了166 篇原創文章 · 獲贊 208 · 訪問量 132萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章