OCP认证考试指南(1ZO-063) Oracle Database 12c高级管理
上QQ阅读APP看书,第一时间看更新

4.2.5 增量备份

如第3章和本章前面所述,增量备份有两种类型:级别0和级别1。级别0增量备份包含指定数据文件中的所有块,但从未使用过的块除外。另外,级别0备份实质上等同于同一个数据文件的完全备份,只是完全备份不能与增量备份策略共用,完全备份是独立的。级别1备份有两种类型:一种是差异备份,它备份上一个级别0或级别1之后发生了变化的块;一种是累积备份,它备份上一个级别0备份以来所有发生了变化的块。

在RMAN BACKUP命令中使用以下关键字指定增量级别0或级别1备份:

        INCREMENTAL LEVEL [0|1]

下面几节将介绍如何为USERS表空间制定增量备份策略。

1.级别0增量备份

级别0备份包含数据库对象中的所有块,但超过HWM的从未用过的块除外。其后的级别1备份将最新的级别0备份用作比较基准,以此来确定发生了变化的块。

执行级别0备份的频率取决于备份之间数据库对象(如表空间)的改动。如果一个表空间包含的表很少被应用程序更改,例如每个星期才更改5%的表行,而另一个表空间包含的表变化频繁,每个星期会发生全面性的变化,那么后者的级别0备份的频率很可能更高。不过,更改幅度也可能根据行中块的分布情况而定。

在本例中,在增量备份策略中执行USERS表空间的第一个级别0备份:

        RMAN> backup incremental level 0 tablespace users;

        Starting backup at 25-FEB-14
        using channel ORA_DISK_1
        using channel ORA_DISK_2
        using channel ORA_DISK_3
        using channel ORA_DISK_4
        channel ORA_DISK_1: starting compressed incremental level 0
            datafile backup set
        channel ORA_DISK_1: specifying datafile(s) in backup set
        input datafile file number=00005
              name=+DATA/RPT12C/DATAFILE/users.269.826931347
        channel ORA_DISK_1: starting piece 1 at 25-FEB-14
        channel ORA_DISK_2: starting compressed incremental level 0
            datafile backup set
        channel ORA_DISK_2: specifying datafile(s) in backup set
        input datafile file number=00006
            name=+DATA/RPT12C/DATAFILE/users.259.826650843
        channel ORA_DISK_2: starting piece 1 at 25-FEB-14
        channel ORA_DISK_1: finished piece 1 at 25-FEB-14
        piece handle=+RECOV/RPT12C/BACKUPSET/2014_02_25/
            nnndn0_tag20140225t093233_0.288.840447153 tag=TAG20140225T093233
            comment=NONE
        channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
        channel ORA_DISK_2: finished piece 1 at 25-FEB-14
        piece handle=+RECOV/RPT12C/BACKUPSET/2014_02_25/
        nnndn0_tag20140225t093233_0.268.840447153 tag=TAG20140225T093233
            comment=NONE
        channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
        Finished backup at 25-FEB-14

        RMAN>

随后的级别1备份会将此次备份作为起点,以此来判断哪些块发生了变化。

2.差异增量备份

差异备份是默认的增量备份类型,它备份自上次执行级别0和级别1增量备份以来所有发生了变化的块。再次使用USERS表空间。此处执行增量备份:

        RMAN> backup incremental level 1 tablespace users;

        Starting backup at 25-FEB-14
        using channel ORA_DISK_1
        using channel ORA_DISK_2
        using channel ORA_DISK_3
        using channel ORA_DISK_4
        channel ORA_DISK_1: starting compressed incremental level 1
          datafile backup set
        channel ORA_DISK_1: specifying datafile(s) in backup set
        input datafile file number=00005
            name=+DATA/RPT12C/DATAFILE/users.269.826931347
        channel ORA_DISK_1: starting piece 1 at 25-FEB-14
        channel ORA_DISK_2: starting compressed incremental level 1
            datafile backup set
        channel ORA_DISK_2: specifying datafile(s) in backup set
        input datafile file number=00006
            name=+DATA/RPT12C/DATAFILE/users.259.826650843

        channel ORA_DISK_2: starting piece 1 at 25-FEB-14
        channel ORA_DISK_1: finished piece 1 at 25-FEB-14
        piece handle=+RECOV/RPT12C/BACKUPSET/2014_02_25/
        nnndn1_tag20140225t093513_0.315.840447313 tag=TAG20140225T093513
            comment=NONE
        channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
        channel ORA_DISK_2: finished piece 1 at 25-FEB-14
        piece handle=+RECOV/RPT12C/BACKUPSET/2014_02_25/
        nnndn1_tag20140225t093513_0.284.840447313 tag=TAG20140225T093513
            comment=NONE
        channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
        Finished backup at 25-FEB-14

        RMAN>

提示:

差异备份是默认的增量备份类型。大多数Oracle命令都允许你为默认设置使用关键字,但此处不同,不能为RMAN BACKUP命令指定DIFFERENTIAL关键字。

3.累积增量备份

累积增量备份会备份自从上次执行级别0增量备份以来所有发生了变化的块。执行累积增量级别1备份的方式与执行差异级别1备份的方式相同,只是需要指定CUMULATIVE关键字,见本例:

        RMAN> backup incremental level 1 cumulative tablespace users;

        Starting backup at 25-FEB-14
        using channel ORA_DISK_1
        using channel ORA_DISK_2
        using channel ORA_DISK_3
        using channel ORA_DISK_4
        channel ORA_DISK_1: starting compressed incremental level 1
            datafile backup set
        channel ORA_DISK_1: specifying datafile(s) in backup set
        input datafile file number=00005
            name=+DATA/RPT12C/DATAFILE/users.269.826931347
        channel ORA_DISK_1: starting piece 1 at 25-FEB-14
        channel ORA_DISK_2: starting compressed incremental level 1
            datafile backup set
        channel ORA_DISK_2: specifying datafile(s) in backup set
        input datafile file number=00006
            name=+DATA/RPT12C/DATAFILE/users.259.826650843
        channel ORA_DISK_2: starting piece 1 at 25-FEB-14
        channel ORA_DISK_1: finished piece 1 at 25-FEB-14
        piece handle=+RECOV/RPT12C/BACKUPSET/2014_02_25/
            nnndn1_tag20140225t093821_0.283.840447501 tag=TAG20140225T093821
            comment=NONE
        channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
        channel ORA_DISK_2: finished piece 1 at 25-FEB-14
        piece handle=+RECOV/RPT12C/BACKUPSET/2014_02_25/
            nnndn1_tag20140225t093821_0.282.840447501 tag=TAG20140225T093821
            comment=NONE
        channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
        Finished backup at 25-FEB-14

        RMAN>

是使用累积备份还是差异备份?这在一定程度上取决于期望的CPU循环数和可供使用的磁盘空间。使用累积备份意味着,在执行下一个级别0增量备份前,每个增量备份将逐渐增大,需要的时间更长。由于还原和恢复操作只需要两个备份集,这种方法会带来好处。而另一方面,差异备份仅记录自上次备份以来发生的变化,因此每个备份集可能比上次备份更小或更大,数据块备份之间没有交叠。但是,如果基于多个备份集(而不仅是两个)执行还原,还原和恢复操作需要的时间更长。