oracle自動清理archivelog文件的具體方法
更新時間:2013年09月22日 15:39:57 作者:
這篇文章介紹了oracle自動清理archivelog文件的具體方法,有需要的朋友可以參考一下
1.登陸到服務(wù)器上創(chuàng)建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.手動執(zhí)行清除日志
[oracle@108 ~]$ rman target/ cmdfile=/home/oracle/del_ora_log.rman msglog=/home/oracle/del_ora_log.rman.log
3.將腳本加入系統(tǒng)定時任務(wù)
注意:任務(wù)執(zhí)行的時候環(huán)境變量不能應(yīng)用上,導(dǎo)致rman命令不能執(zhí)行成功,可以將環(huán)境變量和命令放到一個腳本中,這樣執(zhí)行就沒有問題。
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.某些表插入數(shù)據(jù)頻繁但數(shù)據(jù)又不太重要可以去掉log。
alter table <tablename> NOLOGGING;
[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.手動執(zhí)行清除日志
[oracle@108 ~]$ rman target/ cmdfile=/home/oracle/del_ora_log.rman msglog=/home/oracle/del_ora_log.rman.log
3.將腳本加入系統(tǒng)定時任務(wù)
注意:任務(wù)執(zhí)行的時候環(huán)境變量不能應(yīng)用上,導(dǎo)致rman命令不能執(zhí)行成功,可以將環(huán)境變量和命令放到一個腳本中,這樣執(zhí)行就沒有問題。
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.某些表插入數(shù)據(jù)頻繁但數(shù)據(jù)又不太重要可以去掉log。
alter table <tablename> NOLOGGING;
相關(guān)文章
Oracle 10g 服務(wù)器端安裝預(yù)備步驟(詳細圖文教程)
這篇文章主要介紹了Oracle 10g 服務(wù)器端安裝預(yù)備步驟(詳細圖文教程),需要的朋友可以參考下2017-03-03Oracle數(shù)據(jù)庫中ORDER BY排序和查詢按IN條件的順序輸出
這篇文章主要介紹了Oracle數(shù)據(jù)庫中ORDER BY排序和查詢按IN條件的順序輸出的方法,其中ORDER BY的排序結(jié)果需要注意其是否穩(wěn)定,需要的朋友可以參考下2015-11-11Oracle數(shù)據(jù)庫兩表關(guān)聯(lián)更新的問題
需要寫一個更新語句,但是更新的判斷條件是兩個表關(guān)聯(lián)查詢出來的,本文通過實例代碼給大家講解Oracle數(shù)據(jù)庫兩表關(guān)聯(lián)更新的問題及遇到的坑,感興趣的朋友一起看看吧2023-11-11Oracle中rank,over partition函數(shù)的使用方法
本文主要介紹Oracle中rank,over partition函數(shù)的用法,希望對大家有所幫助。2016-05-05