用orabm测试oracle服务器的TPS值

发表于:2007-9-21 13:58

字体: | 上一篇 | 下一篇 | 我要投稿

 作者:fwj0407    来源:fwj0407的专栏

        以下是一个测试例子,对本地数据库进行三个阶段测试,分别以1,2,6个并发执行10000个事务.

$ orabm 1,2,6 10000

Keep in mind that the specified number of transactions is run in each concurrent session.

        注意,这里定义的10000个事务是对每个session来说的.

Note: you should specify sufficient transactions such that the TPS results produced don't fluctuate significantly between runs for a given number of sessions; 100000 is a good value to choose.

        注意:你应该定义足够的事务以便TPS结果在不同数量并发下波动尽量小,通常100,000是一个好的选择.

Results Output

Output is appended to a log file orabm.database.log, where database is either the ORACLE_SID or TNS alias that identifies the database where the test was run e.g. orabm.t92.log. For each iteration, the TPS value for each concurrent session appears between begin and end markers. For example, the following shows the contents of the log for two concurrent sessions - in this case the second iteration for the previous command line example - where txn(all) displays the total transaction count, and xn(sam) and t(sam) show the total transactions and time for the middle 80% of transactions for which sampling took place:

        输出结果的说明:
txn(all)----代表Total transaction Count,总的事务数量.
xn(sam)-----采样的事务数量
t(sam)------采样事务运行的时间.

---begin sess=2 txn=10000 ORACLE_SID=t92 Fri Nov 8 20:31:48 2002
T92.WORLD txn(all)=10000 xn(sam)=7999 t(sam)=44 tps=182 ...
T92.WORLD txn(all)=10000 xn(sam)=7999 t(sam)=45 tps=178 ...
---end - Fri Nov 8 20:32:46 2002


The total TPS for this iteration is the sum of the TPS for the two concurrent sessions (182+178=360).
对于以上输出,在2个并发下,TPS值为182+178=360

A shell script (orabm_tps.sh) can be used to process output from the log on UNIX and Linux. The script aggregates the TPS values for concurrent sessions in a single iteration into a total TPS value for that iteration. The output based on the log info from the previous command line (3 iterations with 1, then 2, then 6 concurrent sessions) shows:
也可以用shell script(orabm_tps.sh)进行输出日志分析.

$ orabm_tps.sh orabm.t92.log
ORACLE_SID=t92 sess=1 tps=182
ORACLE_SID=t92 sess=2 tps=360
ORACLE_SID=t92 sess=6 tps=364

In this example the server was a 2 CPU model - as a result, 2 concurrent sessions running in orabm are enough to completely utilize all available CPU capacity.
在这个例子中,Server有两个CPU,测试中两个并发足以消耗所有的CPU资源.

Additional sessions should result in the total TPS remaining unchanged, or even falling slightly as the operating system performs context switches to share the overloaded CPU resource between more ready-to-run sessions than available CPUs.
        继续增加并发并不会导致TPS值得增加,甚至有可能会下降.

(2)测试TPS值
        下面我们来具体跑一下程序。在跑程序之前,要注意一下:前面的例子应该可以看到,在windows平台下运行orabmload时,设置了 LOCAL 变量,这个变量相当于UNIX平台下的ORACLE_SID,这次运行orabm程序,却有所不同,见下面的运行日志:

E:\temp>orabm 1,2,6,10 10000
ORACLE_SID not set

E:\temp>set LOCAL=ccbver

E:\temp>orabm 1,2,6,10 10000
ORACLE_SID not set

E:\temp>set ORACLE_SID=ccbver

E:\temp>orabm 1,2,6,10 10000
---begin sess=1 txn=10000 ORACLE_SID=ccbver Wed Jan 26 11:03:45 2005
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=17 tps=471 sl=3918(49%) on=2483(31%) o
i=1598(20%) end=260105-10:05:58
---end - Wed Jan 26 11:04:09 2005
---begin sess=2 txn=10000 ORACLE_SID=ccbver Wed Jan 26 11:04:09 2005
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=17 tps=471 sl=3999(50%) on=2441(30.5%)
 oi=1559(19.5%) end=260105-10:06:19
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=17 tps=471 sl=4025(50.3%) on=2396(30%)
 oi=1578(19.7%) end=260105-10:06:19
---end - Wed Jan 26 11:04:31 2005
---begin sess=6 txn=10000 ORACLE_SID=ccbver Wed Jan 26 11:04:31 2005
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=43 tps=186 sl=4041(50.5%) on=2372(29.7
%) oi=1586(19.8%) end=260105-10:07:13
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=43 tps=186 sl=4017(50.2%) on=2404(30.1
%) oi=1578(19.7%) end=260105-10:07:13
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=42 tps=190 sl=3917(49%) on=2505(31.3%)
 oi=1577(19.7%) end=260105-10:07:14
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=43 tps=186 sl=4016(50.2%) on=2394(29.9
%) oi=1589(19.9%) end=260105-10:07:14
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=43 tps=186 sl=4038(50.5%) on=2316(29%)
 oi=1645(20.6%) end=260105-10:07:14
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=47 tps=170 sl=4011(50.1%) on=2380(29.8
%) oi=1608(20.1%) end=260105-10:07:15
---end - Wed Jan 26 11:05:26 2005
---begin sess=10 txn=10000 ORACLE_SID=ccbver Wed Jan 26 11:05:26 2005
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=72 tps=111 sl=3969(49.6%) on=2390(29.9
%) oi=1640(20.5%) end=260105-10:08:45
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=72 tps=111 sl=4061(50.8%) on=2407(30.1
%) oi=1531(19.1%) end=260105-10:08:45
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=73 tps=110 sl=3996(50%) on=2444(30.6%)
 oi=1559(19.5%) end=260105-10:08:46
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=72 tps=111 sl=4089(51.1%) on=2334(29.2
%) oi=1576(19.7%) end=260105-10:08:46
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=71 tps=113 sl=3935(49.2%) on=2468(30.9
%) oi=1596(20%) end=260105-10:08:46
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=74 tps=108 sl=4015(50.2%) on=2380(29.8
%) oi=1604(20.1%) end=260105-10:08:47
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=72 tps=111 sl=4008(50.1%) on=2446(30.6
%) oi=1545(19.3%) end=260105-10:08:47
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=76 tps=105 sl=3939(49.2%) on=2454(30.7
%) oi=1606(20.1%) end=260105-10:08:48
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=76 tps=105 sl=4061(50.8%) on=2333(29.2
%) oi=1605(20.1%) end=260105-10:08:48
CCBVER txn(all)=10000 xn(sam)=7999 t(sam)=77 tps=104 sl=3932(49.2%) on=2432(30.4
%) oi=1635(20.4%) end=260105-10:08:48
---end - Wed Jan 26 11:06:59 2005

        原来还要设置 ORACLE_SID 变量!

        我跑的这个例子是分四个案例:
第一个是1个并发session跑10000个事务;
第二个是2个并发session跑10000个事务;
第三个是6个并发session跑10000个事务;
第四个是10个并发session跑10000个事务。

        测试程序运行结束后,会生成一个orabm.{ORACLE_SID}.log的文件,比如上面这个例子,生成的文件是 orabm.ccbver.log,该文件是累加的,如果继续跑测试程序,其测试结果会累加到这个文件中。

(3)格式化输出
        其实从上面的运行结果中已经差不多可以看出TPS的值了,把并发session的TPS值相加即可。不过,orabm程序包中有一个格式化输出结果的SHELL脚本,可以看得更加清楚。
        当然,得把日志文件上传到服务器上去运行,毕竟是SHELL程序嘛。
看结果:
$ ./orabm_tps.sh orabm.ccbver.log
ORACLE_SID=ccbver sess=1 tps=471
ORACLE_SID=ccbver sess=2 tps=942
ORACLE_SID=ccbver sess=6 tps=1104
ORACLE_SID=ccbver sess=10 tps=1089

        可以看出,这台机器的TPS值大概在1100左右。

        后来把事务数变为100000,再跑了一下,结果也差不多,如下:
$ ./orabm_tps.sh orabm.ccbver.log
ORACLE_SID=ccbver sess=1 tps=530
ORACLE_SID=ccbver sess=2 tps=979
ORACLE_SID=ccbver sess=6 tps=1106
ORACLE_SID=ccbver sess=10 tps=1097

 

33/3<123
《2023软件测试行业现状调查报告》独家发布~

关注51Testing

联系我们

快捷面板 站点地图 联系我们 广告服务 关于我们 站长统计 发展历程

法律顾问:上海兰迪律师事务所 项棋律师
版权所有 上海博为峰软件技术股份有限公司 Copyright©51testing.com 2003-2024
投诉及意见反馈:webmaster@51testing.com; 业务联系:service@51testing.com 021-64471599-8017

沪ICP备05003035号

沪公网安备 31010102002173号