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;