歸檔日誌記錄著資料庫的操作記錄,是做資料恢複的依據,如果資料庫開啟了歸檔模式,那麼就會產生大量的歸檔日誌,當然如果有RMAN備份的話,可以在備份之後刪除已經備份過的日誌,如果是沒有採用rman備份的話,就需要自己來刪除這寫歸檔日誌。 下面的幾個指令碼就減輕了DBA的工作量。
Linux 平台:
0 2 * * * /home/oracle/scripts/del_archive.sh > /home/oracle/scripts/del_archive.log
[oracle@hfcc-svr-newccsdb1 ~]$ more /home/oracle/scripts/del_archive.sh
#!/usr/bin/ksh
# create by tianlesoftware
export ORACLE_HOME=/dba/oracle/product/10.2.0/db_1
export ORACLE_SID=orcl
export SHELL_DIR=/home/oracle/scripts
del_seq=`ls /u01/newccs_archive/|head -1|cut -f2 -d_`
echo $del_seq
$ORACLE_HOME/bin/sqlplus -s "sys/PWD@SID as sysdba" <<eof >/home/oracle/scripts/max
_sn.log
set head off;
set feedback;
select max(sequence#) from v/$log_history;
exit;
eof
max_sn=`cat /home/oracle/scripts/max_sn.log|awk '{print $1}'|grep ^[0-9]`
max_sn=`expr $max_sn - 5`
echo $max_sn
while [ $del_seq -lt $max_sn ]
do
rm /u01/archive/1_"$del_seq"_692846987.dbf
del_seq=`expr $del_seq + 1`
echo $del_seq
done
或者用指令碼:
del_arc.sh
find /u01/backups -mtime +10 -name "*.dbf" -exec rm -rf {} /;
windows 平台:
del_arc_orcl.bat
forfiles /p d:/arc_orcl /m *.DBF /d -3 /c "cmd /c del @file"
將del_arc_orcl.bat 添加到計劃任務即可.