Oracle 批量扩数据文件脚本(file_id 间断)
- nohup ./resize.sh 20 25 &,参数指定数据文件 file_id 20 到 25 顺次串行扩大大小;
- 每次扩大数据文件从 100m 递增扩大到 2400m,每次递增 100m;初始数据文件大小要小于 100m 或者未应用,否则报错;
- 校验 Linux CPU IOwait,只有 <5% 时才 resize 数据文件;
-
IO 性能足够状况,#sleep 1 无需放开,IO 较差环境,倡议设置脚本执行间隔时间,单位 - 秒;
#!/bin/bash # Usage: nohup ./resize.sh 20 25 & source ~/.bash_profile export resize_tmp=/tmp/resize_tmp.log > $resize_tmp f=$1 for((f=$1; f<=$2; f++)); do echo "$(date +'%F %T'): Resize datafile : $f">> $resize_tmp for((i=100; i<=2400; i=i+100)) do echo "$(date +'%F %T'):Begin alter database datafile $f resize $i m;">> $resize_tmp export wa=99 # resize datafile only when CPU iowait is less than 5% until [$wa -lt 5]; do wa=$(top -cn 1 | grep 'wa,'|grep -v grep|awk '{print $10}'|cut -d. -f1) echo -e "alter database datafile $f resize $i m;\nexit;" | sqlplus -S / as sysdba echo "$(date +'%F %T'):End alter database datafile $f resize $i m;">> $resize_tmp #sleep 1 done done done # End