温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

RMAN归档日志删除策略有什么用

发布时间:2021-10-26 14:41:26 来源:亿速云 阅读:129 作者:小新 栏目:建站服务器

小编给大家分享一下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

以上是“RMAN归档日志删除策略有什么用”这篇文章的所有内容,感谢各位的阅读!相信大家都有了一定的了解,希望分享的内容对大家有所帮助,如果还想学习更多知识,欢迎关注亿速云行业资讯频道!

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI