溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

DG歸檔日志刪除腳本怎么寫(xiě)

發(fā)布時(shí)間:2021-11-09 11:55:02 來(lái)源:億速云 閱讀:188 作者:小新 欄目:關(guān)系型數(shù)據(jù)庫(kù)

這篇文章主要介紹DG歸檔日志刪除腳本怎么寫(xiě),文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

由于磁盤(pán)資源緊缺,需要一個(gè)歸檔日志處理的策略

網(wǎng)上找了幾個(gè)腳本,發(fā)現(xiàn)寫(xiě)的那么麻煩

毛了,于是簡(jiǎn)單寫(xiě)了一個(gè),實(shí)際路徑等可以自己在修改

主庫(kù)備庫(kù)都可以用,自己再做crontab就好,建議錯(cuò)開(kāi)時(shí)間進(jìn)行

需要注意,提前查詢DEST_ID,下面這個(gè)是主庫(kù)刪除的腳本(備庫(kù)只需更改dest_id即可),我的主庫(kù)v$archived_log里,主庫(kù)的歸檔dest_id=1,備庫(kù)是dest_id=2

1.  #!/bin/bash 

2.   

3.  ############ easy script by lcrash @ 2011-1-25############ 

4.  # for delete DG archive log                              # 

5.  # you should modify USER_HOME && make sure del_dir exists# 

6.  # and you can change your keep date by modify SQL below  # 

7.  ########################################################## 

8.   

9.  USER_HOME=/opt/Oracle 

10.DEL_DIR=$USER_HOME/del_arch 

11. 

12.source $USER_HOME/.bash_profile  

13.$ORACLE_HOME/bin/sqlplus -S "/as sysdba" <<eof  </eof <>

14.set heading off 

15.set feedback off 

16.spool /opt/oracle/del_arch/del_arch.list 

17.select 'rm -rf '||name from v\$archived_log  

18.where DEST_ID=1 and SEQUENCE#<(select max(SEQUENCE#) from v\$archived_log where applied='YES') and COMPLETION_TIME<=sysdate-0; 

19.spool off 

20.exit 

21.EOF 

22. 

23.cd $DEL_DIR 

24.sed -n '/dbf/p' del_arch.list>del_arch_do.sh 

25.chmod +x del_arch_do.sh 

26.source del_arch_do.sh 

27. 

28.rm del_arch.list 

29.mv {,`date +%Y-%m-%d-%H`}del_arch_do.sh 

30. 

31. 

32.rman target / <<eof  </eof <>

33.crosscheck archivelog all; 

34.delete obsolete; 

35.delete noprompt expired archivelog all; 

36.EOF 

以上是“DG歸檔日志刪除腳本怎么寫(xiě)”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注億速云行業(yè)資訊頻道!

向AI問(wèn)一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

dg
AI