oracle自動清理archivelog檔案的具體方法_oracle

來源:互聯網
上載者:User
1.登陸到伺服器上建立rman自動刪除兩天前的歸檔日誌指令碼
[oracle@108 ~]$ cat >>del_ora_log.rman <<EOF
 crosscheck archivelog all;
delete noprompt expired archivelog all;
delete noprompt force archivelog until time 'sysdate -2';   -------刪除兩天前的archivelog
exit;
EOF
2.手動執行清除日誌
[oracle@108 ~]$ rman target/ cmdfile=/home/oracle/del_ora_log.rman msglog=/home/oracle/del_ora_log.rman.log

3.將指令碼加入系統定時任務
注意:任務執行的時候環境變數不能應用上,導致rman命令不能執行成功,可以將環境變數和命令放到一個指令碼中,這樣執行就沒有問題。
Shell代碼 
PATH=$PATH:$HOME/bin 

export PATH 

export ORACLE_BASE=/home/oracle/app 

export ORACLE_HOME=$ORACLE_BASE/oracle/product/11.2.0/dbhome_1 

export ORACLE_SID=ORCL 

export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin 

export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib:/usr/local/lib 

rman target/ cmdfile=/home/oracle/del_ora_log.rman msglog=/home/oracle/del_ora_log.rman.log >>/home/oracle/rman.log 2>&1 

[oracle@108 ~]$ crontab -e  
13 * * * * /home/oracle/del_ora_log.sh >>del_ora_log.log 2>&1

4.某些表插入資料頻繁但資料又不太重要可以去掉log。

alter table  <tablename>  NOLOGGING;

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.