ORACLE 11G 單一實例 磁碟檔案系統 DG 歸檔日誌刪除指令碼 基於RED HAT LINUX 5.3 X86 64BIT

來源:互聯網
上載者:User

最近做個DG的歸檔日誌刪除,

[oracle@.local logs]crontab -l* 8 * * * sh /home/oracle/dbscripts/del_arc.sh

該指令碼分別調用 產生 刪除 校正 三個指令碼
cat del_arc.sh#! /bin/bashsource /home/oracle/.bash_profilesh /home/oracle/dbscripts/build_del_archivelog.sh >> /home/oracle/dbscripts/del_arch`date +%F_%H`.shsleep 5sh /home/oracle/dbscripts/del_arch`date +%F_%H`.sh >> /home/oracle/dbscripts/logs/del_arch`date +%F_%H`.logsleep 5sh /home/oracle/dbscripts/crosscheck_archivelog.sh >> /home/oracle/dbscripts/logs/cross_check`date +%F_%H`.log

先看產生的

cat build_del_archivelog.sh sqlplus -s shark/235619<<EOFset heading  offset linesize 1000set echo offset feedback offset timing  offset termout onset trimout offset trimspool onset newpage noneselect 'rm -f '||name  from  v\$archived_log where applied='YES' and deleted='NO' and completion_time < trunc(sysdate);EOF


主要是產生物理刪除 已經應用的歸檔日誌 從V$archived_log中擷取 , 注意ASM磁碟管理中的NAME 不包含路徑.

另外 產生的每行間距太大了,望各位指教下.


產生的刪除指令碼

]head del_arch2014-05-07_08.sh rm -f /arch_backup/1_24144_831167377.log                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                rm -f /arch_backup/2_22765_831167377.log       


就是Y的太大行間距了.

]cat crosscheck_archivelog.sh #! /bin/bashsource /home/oracle/.bash_profileexec >> /home/oracle/dbscripts/logs/del_arch`date +%F_%H`.log$ORACLE_HOME/bin/rman target / <<EOFcrosscheck archivelog all;delete noprompt expired archivelog all;#delete noprompt archivelog until time 'sysdate-1';exit;EOF

這是最後個指令碼 為 檢驗! 原本通過它來刪除歸檔日誌的 從註解中可知.

這個校正指令碼主要是為了清理下歸檔資訊. 如果該資訊存放在控制檔案中DG是刪除不了的




相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.