测试数据库数据所在硬件写性能的脚本

思路:连续增加多次大数据文件到某个表空间,根据时间花费计算出每秒的写字节数。如果数据库是RAC架构,存储是SAN架构的话,可以在每个节点都执行该脚本来测试每个节点链路的IO性能。

#!/bin/sh
############ByCompard 2015.10.9##############
result=0
i=0
for SZ in 8 10 20 30;
#for SZ in  2 4;
do
  start_s=$(date +%s)
  echo begin at `date`,size=${SZ}GB

  sqlplus -s '/ as sysdba' <<EOF
    alter tablespace users add datafile '+DATA_DG/dqprd/datafile/user_01_compard.dbf' size ${SZ}g;
    exit;

EOF

  end_s=$(date +%s)
  echo end at `date`
  tcost_s=$(( $end_s - $start_s ))
  if [ $tcost_s -gt 0 ] ; then
    ed=`echo "${SZ}*1000/${tcost_s}"|bc`
    result=`echo "${result}+${ed}"|bc`
    echo begin_S=${start_s}, end_s=${end_s}, cost_s=${tcost_s}S
    i=`expr $i + 1`
  fi
  sqlplus -s "/ as sysdba" <<!
    Alter tablespace users drop datafile '+DATA_DG/dqprd/datafile/user_01_compard.dbf';
    exit;

!
done
result=`echo "scale=2;${result}/$i"|bc`
echo =================write speed is ${result} MB\/S===================

脚本的输出:

[oracle@compardraca ~]$ . ./testIO.sh
begin at Fri Oct 9 18:29:51 CST 2015,size=8GB

Tablespace altered.

end at Fri Oct 9 18:30:20 CST 2015
begin_S=1444386591, end_s=1444386620, cost_s=29S

Tablespace altered.

begin at Fri Oct 9 18:30:22 CST 2015,size=10GB

Tablespace altered.

end at Fri Oct 9 18:30:56 CST 2015
begin_S=1444386622, end_s=1444386656, cost_s=34S

Tablespace altered.

begin at Fri Oct 9 18:30:58 CST 2015,size=20GB

Tablespace altered.

end at Fri Oct 9 18:32:04 CST 2015
begin_S=1444386658, end_s=1444386724, cost_s=66S

Tablespace altered.

begin at Fri Oct 9 18:32:06 CST 2015,size=30GB

Tablespace altered.

end at Fri Oct 9 18:33:46 CST 2015
begin_S=1444386726, end_s=1444386826, cost_s=100S

Tablespace altered.

=================write speed is 293.00 MB/S===================
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值