聊聊RMAN的ARCHIVELOG DELETION参数

RMANOracle推出的官方备份还原工具。经过几个大版本的发展,RMAN已经支持多种备份介质和恢复策略的主要工具,也是业界普遍认可是Oracle备份还原官方策略。

Archivelog是Oracle备份还原策略的重要组成元素,不完全备份+连续的归档日志可以让我们将数据库恢复到发生故障点,实现数据的无损失恢复。但是,现实生活中archive log给没有经验的运维人员也带来了不少的问题,归档空间占满引起Hang住、瞬间归档日志过多生成引起问题等。一些前辈也在不断强调“归档模式不美好”。

在RMAN工作参数中,针对archive log,是可以设置专门的删除策略(Deletion)。在实践领域中,已经备份过或者确保安全传输的归档日志,其实就可以删除了,特别是在有限的Fast Recovery Area管理模式下。对于自动删除archive log的策略,比较常见的是applied to standby和shipped to standby,也就是Data Guard场景下。

本篇介绍简单的backed up参数使用情况,并通过一系列实验去研究该参数影响下Oracle和RMAN的工作行为特性。

1、基本参数和实验环境

笔者使用Oracle 11gR2进行测试,具体版本编号为11.2.0.4。

SQL> select * from v$version;

BANNER

--------------------------------------------------------------------------------

Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

PL/SQL Release 11.2.0.3.0 - Production

CORE    11.2.0.3.0    Production

TNS for Linux: Version 11.2.0.3.0 - Production

NLSRTL Version 11.2.0.3.0 – Production

默认情况下,archivelog deletion policy参数为NONE。

RMAN> show all;     

RMAN configuration parameters for database with db_unique_name XXXXDB are:

CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default

(篇幅原因,有省略……)

CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default

该参数常见的集中取值如下:

configure archivelog deletion policy to backed up 2 times to sbt;

configure archivelog deletion policy to backed up 1 times to device type disk;

configure archivelog deletion policy to applied on standby;  --DG专用

configure archivelog deletion policy to shipped on standby;  --DG专用

configure archivelog deletion policy clear;

研究archivelog行为最好的工具视图是v$archived_log。很多DBA喜欢从操作系统层面删除归档日志,但是这种方式是不会直接被Oracle控制文件认可,所以建议使用RMAN或者官方工具来做。

--已归档未删除日志

SQL> select count(*) from v$archived_log where archived='YES' and deleted='NO';

COUNT(*)

----------

13

2、第一轮备份测试实验

首先我们修改archivelog deletion policy参数,设置为“两次备份后即可以删除”。

RMAN> configure archivelog deletion policy to backed up 2 times to device type disk;

new RMAN configuration parameters:

CONFIGURE ARCHIVELOG DELETION POLICY TO BACKED UP 2 TIMES TO DISK;

new RMAN configuration parameters are successfully stored

手工备份数据库和归档日志,不进行删除动作。

RMAN> backup database plus archivelog;

Starting backup at 21-SEP-15

current log archived

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=16 device type=DISK

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=100 RECID=12 STAMP=890690423

input archived log thread=1 sequence=101 RECID=13 STAMP=890712061

input archived log thread=1 sequence=102 RECID=14 STAMP=890727732

input archived log thread=1 sequence=103 RECID=15 STAMP=890776815

input archived log thread=1 sequence=104 RECID=16 STAMP=890776833

input archived log thread=1 sequence=105 RECID=17 STAMP=890805616

input archived log thread=1 sequence=106 RECID=18 STAMP=890814181

input archived log thread=1 sequence=107 RECID=19 STAMP=890820201

input archived log thread=1 sequence=108 RECID=20 STAMP=890859629

input archived log thread=1 sequence=109 RECID=21 STAMP=890892046

input archived log thread=1 sequence=110 RECID=22 STAMP=890900632

input archived log thread=1 sequence=111 RECID=23 STAMP=890906655

input archived log thread=1 sequence=112 RECID=24 STAMP=890942416

input archived log thread=1 sequence=113 RECID=25 STAMP=890990204

channel ORA_DISK_1: starting piece 1 at 21-SEP-15

channel ORA_DISK_1: finished piece 1 at 21-SEP-15

piece handle=/u01/app/oracle/fast_recovery_area/XXXXDB/backupset/2015_09_21/o1_mf_annnn_TAG20150921T091644_bzypmwty_.bkp tag=TAG20150921T091644 

(篇幅原因,省略部分……)

Finished Control File and SPFILE Autobackup at 21-SEP-15

此时,归档日志被备份,并且没有删除。

--多出来的两个是由于进行备份时候自动会有switch log

SQL> select count(*) from v$archived_log where archived='YES' and deleted='NO';

COUNT(*)

----------

15

下面进行第二次实验。

RMAN> backup database plus archivelog;

Starting backup at 21-SEP-15

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=100 RECID=12 STAMP=890690423

input archived log thread=1 sequence=101 RECID=13 STAMP=890712061

input archived log thread=1 sequence=102 RECID=14 STAMP=890727732

input archived log thread=1 sequence=103 RECID=15 STAMP=890776815

input archived log thread=1 sequence=104 RECID=16 STAMP=890776833

input archived log thread=1 sequence=105 RECID=17 STAMP=890805616

input archived log thread=1 sequence=106 RECID=18 STAMP=890814181

input archived log thread=1 sequence=107 RECID=19 STAMP=890820201

input archived log thread=1 sequence=108 RECID=20 STAMP=890859629

input archived log thread=1 sequence=109 RECID=21 STAMP=890892046

input archived log thread=1 sequence=110 RECID=22 STAMP=890900632

input archived log thread=1 sequence=111 RECID=23 STAMP=890906655

input archived log thread=1 sequence=112 RECID=24 STAMP=890942416

input archived log thread=1 sequence=113 RECID=25 STAMP=890990204

input archived log thread=1 sequence=114 RECID=26 STAMP=890990263

input archived log thread=1 sequence=115 RECID=27 STAMP=890990391

channel ORA_DISK_1: starting piece 1 at 21-SEP-15

channel ORA_DISK_1: finished piece 1 at 21-SEP-15

piece handle=/u01/app/oracle/fast_recovery_area/XXXXDB/backupset/2015_09_21/o1_mf_annnn_TAG20150921T091951_bzypsqj3_.bkp tag=TAG20150921T091951 

(篇幅原因,有省略……)

Finished Control File and SPFILE Autobackup at 21-SEP-15

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/d07001578a37b0e990a58a148b25630e.html