oracle自動(dòng)清理archivelog文件的具體方法
更新時(shí)間:2013年09月22日 15:39:57 作者:
這篇文章介紹了oracle自動(dòng)清理archivelog文件的具體方法,有需要的朋友可以參考一下
1.登陸到服務(wù)器上創(chuàng)建rman自動(dòng)刪除兩天前的歸檔日志腳本
[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.手動(dòng)執(zhí)行清除日志
[oracle@108 ~]$ rman target/ cmdfile=/home/oracle/del_ora_log.rman msglog=/home/oracle/del_ora_log.rman.log
3.將腳本加入系統(tǒng)定時(shí)任務(wù)
注意:任務(wù)執(zhí)行的時(shí)候環(huán)境變量不能應(yīng)用上,導(dǎo)致rman命令不能執(zhí)行成功,可以將環(huán)境變量和命令放到一個(gè)腳本中,這樣執(zhí)行就沒(méi)有問(wèn)題。
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.手動(dòng)執(zhí)行清除日志
[oracle@108 ~]$ rman target/ cmdfile=/home/oracle/del_ora_log.rman msglog=/home/oracle/del_ora_log.rman.log
3.將腳本加入系統(tǒng)定時(shí)任務(wù)
注意:任務(wù)執(zhí)行的時(shí)候環(huán)境變量不能應(yīng)用上,導(dǎo)致rman命令不能執(zhí)行成功,可以將環(huán)境變量和命令放到一個(gè)腳本中,這樣執(zhí)行就沒(méi)有問(wèn)題。
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ù)備步驟(詳細(xì)圖文教程)
這篇文章主要介紹了Oracle 10g 服務(wù)器端安裝預(yù)備步驟(詳細(xì)圖文教程),需要的朋友可以參考下2017-03-03Oracle 12.2處理sysaux空間占滿問(wèn)題
今天處理別的問(wèn)題查看告警日志偶然發(fā)現(xiàn)大量的報(bào)錯(cuò),無(wú)法擴(kuò)展SYSAUX表空間,于是登錄系統(tǒng),查看系統(tǒng)表空間使用情況,發(fā)現(xiàn)SYSAUX表空間用滿了,所以本文給大家介紹了Oracle 12.2處理sysaux空間占滿問(wèn)題,需要的朋友可以參考下2024-02-02Oracle數(shù)據(jù)庫(kù)中ORDER BY排序和查詢按IN條件的順序輸出
這篇文章主要介紹了Oracle數(shù)據(jù)庫(kù)中ORDER BY排序和查詢按IN條件的順序輸出的方法,其中ORDER BY的排序結(jié)果需要注意其是否穩(wěn)定,需要的朋友可以參考下2015-11-11Oracle數(shù)據(jù)庫(kù)兩表關(guān)聯(lián)更新的問(wèn)題
需要寫一個(gè)更新語(yǔ)句,但是更新的判斷條件是兩個(gè)表關(guān)聯(lián)查詢出來(lái)的,本文通過(guò)實(shí)例代碼給大家講解Oracle數(shù)據(jù)庫(kù)兩表關(guān)聯(lián)更新的問(wèn)題及遇到的坑,感興趣的朋友一起看看吧2023-11-11ORACLE常見(jiàn)錯(cuò)誤代碼的分析與解決(三)
ORACLE常見(jiàn)錯(cuò)誤代碼的分析與解決(三)...2007-03-03Oracle中rank,over partition函數(shù)的使用方法
本文主要介紹Oracle中rank,over partition函數(shù)的用法,希望對(duì)大家有所幫助。2016-05-05