11gR2 RMAN歸檔日誌刪除策略
從11gR2開始,RMAN引入了歸檔刪除策略的配置,下面我們透過簡單的例子來討論這個功能:
資料庫版本:
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
CORE 11.2.0.2.0 Production
TNS for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
1.檢視RMAN配置:
RMAN> show all;
RMAN configuration parameters for database with db_unique_name RACTEST are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 1 DAYS;
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/u01/app/oracle/product/11.2.0/db_1/dbs/snapcf_ractest.f'; # default
預設歸檔刪除策略沒有啟用。
2.啟用歸檔刪除策略:
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
new RMAN configuration parameters are successfully stored
配置歸檔刪除策略,只要求歸檔備份一次到磁碟,之後歸檔就允許被刪除。
3.歸檔刪除策略測試1:
當前的歸檔日誌:
SQL> !ls -al /u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13
total 20
drwxr-x--- 2 oracle oinstall 4096 Sep 13 02:37 .
drwxr-x--- 4 oracle oinstall 4096 Sep 13 01:24 ..
-rw-r----- 1 oracle oinstall 1536 Sep 13 02:37 o1_mf_1_20_76wnbnfk_.arc
-rw-r----- 1 oracle oinstall 1536 Sep 13 02:37 o1_mf_1_21_76wnbrt0_.arc
-rw-r----- 1 oracle oinstall 1024 Sep 13 02:37 o1_mf_1_22_76wnbrv9_.arc
RMAN> backup archivelog all delete all input;
Starting backup at 2011-09-13 02:37:42
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=20 RECID=16 STAMP=761711828
input archived log thread=1 sequence=21 RECID=17 STAMP=761711832
input archived log thread=1 sequence=22 RECID=18 STAMP=761711832
input archived log thread=1 sequence=23 RECID=19 STAMP=761711862
channel ORA_DISK_1: starting piece 1 at 2011-09-13 02:37:42
channel ORA_DISK_1: finished piece 1 at 2011-09-13 02:37:43
piece handle=/u01/app/oracle/fast_recovery_area/RACTEST/backupset/2011_09_13/o1_mf_annnn_TAG20110913T023742_76wncpk6_.bkp tag=TAG20110913T023742 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
archived log file name=/u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_20_76wnbnfk_.arc RECID=16 STAMP=761711828
archived log file name=/u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_21_76wnbrt0_.arc RECID=17 STAMP=761711832
archived log file name=/u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_22_76wnbrv9_.arc RECID=18 STAMP=761711832
archived log file name=/u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_23_76wncpd1_.arc RECID=19 STAMP=761711862
Finished backup at 2011-09-13 02:37:43
備份歸檔的同時刪除所有輸入的歸檔日誌檔案。
再次檢視歸檔日誌檔案,發現已經被刪除。
SQL> !ls -al /u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13
total 8
drwxr-x--- 2 oracle oinstall 4096 Sep 13 02:37 .
drwxr-x--- 4 oracle oinstall 4096 Sep 13 01:24 ..
4.歸檔刪除策略測試2:
修改歸檔日誌刪除策略,要求備份到磁碟的歸檔日誌有兩份才可以刪除:
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DISK
2> ;
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DISK;
new RMAN configuration parameters are successfully stored
檢視當前的歸檔日誌:
SQL> !ls -al /u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13
total 60
drwxr-x--- 2 oracle oinstall 4096 Sep 13 02:40 .
drwxr-x--- 4 oracle oinstall 4096 Sep 13 01:24 ..
-rw-r----- 1 oracle oinstall 47104 Sep 13 02:40 o1_mf_1_24_76wnkpn2_.arc
-rw-r----- 1 oracle oinstall 1024 Sep 13 02:40 o1_mf_1_25_76wnkt2l_.arc
執行歸檔備份和刪除:
RMAN> backup archivelog all delete all input;
Starting backup at 2011-09-13 02:41:25
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=24 RECID=20 STAMP=761712054
input archived log thread=1 sequence=25 RECID=21 STAMP=761712058
input archived log thread=1 sequence=26 RECID=22 STAMP=761712087
channel ORA_DISK_1: starting piece 1 at 2011-09-13 02:41:28
channel ORA_DISK_1: finished piece 1 at 2011-09-13 02:41:29
piece handle=/u01/app/oracle/fast_recovery_area/RACTEST/backupset/2011_09_13/o1_mf_annnn_TAG20110913T024128_76wnlr48_.bkp tag=TAG20110913T024128 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
channel ORA_DISK_1: deleting archived log(s)
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_24_76wnkpn2_.arc thread=1 sequence=24
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_25_76wnkt2l_.arc thread=1 sequence=25
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_26_76wnlqxq_.arc thread=1 sequence=26
Finished backup at 2011-09-13 02:41:29
執行同樣的備份歸檔同時刪除歸檔的命令,但是從返回的日誌中可以看出,歸檔日誌並沒有被刪除,這是由於我們將歸檔刪除策略修改為了至少備份兩份到磁碟。
SQL> !ls -al /u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13
total 64
drwxr-x--- 2 oracle oinstall 4096 Sep 13 02:41 .
drwxr-x--- 4 oracle oinstall 4096 Sep 13 01:24 ..
-rw-r----- 1 oracle oinstall 47104 Sep 13 02:40 o1_mf_1_24_76wnkpn2_.arc
-rw-r----- 1 oracle oinstall 1024 Sep 13 02:40 o1_mf_1_25_76wnkt2l_.arc
-rw-r----- 1 oracle oinstall 2048 Sep 13 02:41 o1_mf_1_26_76wnlqxq_.arc
歸檔日誌確實未被刪除!
5.歸檔刪除策略測試3:
將歸檔日誌備份策略修改為備份1份到磁碟:
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
old RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DISK;
new RMAN configuration parameters:
CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 1 TIMES TO DISK;
new RMAN configuration parameters are successfully stored
再次執行歸檔日誌備份:
RMAN> backup archivelog all;
Starting backup at 2011-09-13 02:45:36
current log archived
using channel ORA_DISK_1
skipping archived log file /u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_24_76wnkpn2_.arc; already backed up 1 time(s)
skipping archived log file /u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_25_76wnkt2l_.arc; already backed up 1 time(s)
skipping archived log file /u01/app/oracle/fast_recovery_area/RACTEST/archivelog/2011_09_13/o1_mf_1_26_76wnlqxq_.arc; already backed up 1 time(s)
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=27 RECID=23 STAMP=761712336
channel ORA_DISK_1: starting piece 1 at 2011-09-13 02:45:36
channel ORA_DISK_1: finished piece 1 at 2011-09-13 02:45:37
piece handle=/u01/app/oracle/fast_recovery_area/RACTEST/backupset/2011_09_13/o1_mf_annnn_TAG20110913T024536_76wntjqk_.bkp tag=TAG20110913T024536 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2011-09-13 02:45:37
由於之前已經有過一次歸檔的備份,所以再次備份歸檔日誌,已經有過一次備份的歸檔日誌檔案就被跳過,這和我們配置的歸檔刪除策略要求備份到磁碟的備份數是一致的。如果未設定歸檔日誌的刪除策略,那麼重複執行歸檔的備份就會出現重複備份歸檔日誌的情況。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28211342/viewspace-2134970/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20221121]rman刪除歸檔日誌問題.txt
- RMAN刪除歸檔日誌出現RMAN-0813錯誤的處理
- 配置rman來自動刪除應用過的歸檔日誌
- 通過RMAN設定standby接收日誌後主庫歸檔日誌才可刪除
- Oralce資料庫關閉歸檔日誌並且刪除歸檔日誌資料庫
- 手工rm刪除歸檔日誌對備份歸檔日誌的影響
- RMAN正確地刪除Archivelog以及設定有備庫的歸檔刪除策略Hive
- oracle 刪除過期的歸檔日誌Oracle
- oracle rman 刪除過期的歸檔Oracle
- rman 還原歸檔日誌(restore archivelogRESTHive
- 在Oracle中,如何定時刪除歸檔日誌檔案?Oracle
- oracle rman備份歸檔日誌需要先切換日誌嗎Oracle
- RMAN備份整庫和歸檔日誌的方法
- 在ASM磁碟組中刪除歸檔日誌報ORA-15028ASM
- 達夢資料庫DM8之刪除歸檔日誌檔案資料庫
- oracle adg主庫通過rman無法刪除歸檔Oracle
- ORACLE NBU調取oracle rman指令碼備份歸檔不自動刪除歸檔Oracle指令碼
- 刪除歸檔
- 【Oracle】歸檔日誌管理-設定歸檔日誌路徑以及歸檔日誌冗餘Oracle
- oracle刪除日誌Oracle
- PostgreSQL 歸檔日誌SQL
- 歸檔日誌挖掘
- oracle歸檔日誌Oracle
- Oracle設定多個歸檔路徑生成多份歸檔日誌,Rman備份時也只備份其中的一份歸檔日誌Oracle
- DG_保證歸檔日誌不能隨意被刪除的四種方法
- elasticsearch日誌刪除命令Elasticsearch
- Oracle歸檔日誌清理Oracle
- 歸檔oracle alert日誌Oracle
- 14. 日誌歸檔
- 瘋狂刪除tomcat日誌Tomcat
- Linux系統定時清空日誌內容和刪除日誌檔案教程。Linux
- MogDB/openGauss誤刪未歸檔的xlog日誌如何解決
- 批量註冊歸檔日誌
- [重慶思莊每日技術分享]-RMAN-08137 主庫無法刪除歸檔檔案
- [重慶思莊每日技術分享]-備庫使用RMAN獲得歸檔日誌
- 刪除事務日誌檔案並不安全WC
- Rman在run命令塊裡臨時設定歸檔目錄,歸檔日誌能否恢復主要看預設的歸檔路徑
- Oracle11g redo log 建立、新增、刪除(重做日誌組,重做日誌檔案)Oracle
- 在Linux中,有一堆日誌檔案,如何刪除7天前的日誌檔案?Linux