您的位置:首页 > 数据库

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

2015-10-09 18:40 267 查看
思路:连续增加多次大数据文件到某个表空间,根据时间花费计算出每秒的写字节数。如果数据库是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===================
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: