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

4.2.1 创建备份集

“备份集”是RMAN的专用对象,只有RMAN才能创建和读取备份集。第3章中曾经介绍过,备份集包含一组称为备份段的文件,这些文件可以存储在文件系统或ASM磁盘(理想情况)上。每个备份段包含一个或多个数据库文件备份。与其他任何由RMAN支持的备份一样,所有备份集和备份段都记录在RMAN仓库中。

所有将磁盘作为备份目标的备份都默认采用备份集备份类型:

        CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO
            BACKUPSET; # default

结果,以下备份命令不需要AS BACKUPSET限定符;但是可以添加AS BACKUPSET,对于运行于使用不同默认值的RMAN会话的全局脚本,情况尤其如此。

        RMAN> backup as backupset format '/u00/rpt12c/backups/auxbak.set'
        2>       tablespace sysaux;

FORMAT子句可使用替代变量,按数据库和数据段等来区分备份集。下面列出一些替换变量类型的例子:

●%d 数据库名

●%e 归档日志序列号

●%f 绝对文件编号

●%F 组合DBID、日期、月份、年份和序列号,使用破折号分隔

●%c 多路复用备份中多个副本的副本编号

●%I 数据库标识符(Database Identifier, DBID)

●%n 数据库名,填充8个字符

●%p 备份集中的备份段编号

●%s 备份集编号

●%t 备份集时间戳

●%U 系统生成的唯一文件名(默认名称)

练习4-1

创建压缩的备份集

在本练习中将创建RMAN备份,目标位置是/u02/oradata/rman/rpt12c目录,此目录中包括数据库名、备份集编号、备份集时间戳和备份集中的备份段编号。使用默认备份位置和备份集格式,创建第二个RMAN备份。

(1)连接到目标数据库和RPT12C数据库上的恢复目录:

        [oracle@tettnang rpt12c]$ rman target / catalog rcat_owner/Rcat9095@rcat
        Recovery Manager: Release 12.1.0.1.0 -
            Production on Tue Feb 25 01:13:39 2014
        Copyright (c) 1982, 2013, Oracle and/or its affiliates.
            All rights reserved.
        connected to target database: RPT12C (DBID=1779317104)
        connected to recovery catalog database

        RMAN>

(2)运行RMAN备份,显式指定AS COMPRESSED BACKUPSET(即使这是默认选项也同样指定):

        RMAN> backup as compressed backupset
        2>      format '/u02/oradata/rman/rpt12c/rman_%d_%s_%t_%p.bkupset'
        3>      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 full 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 full 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=/u02/oradata/rman/rpt12c/rman_RPT12C_31_840418162_1.bkupset
        tag=TAG20140225T012921 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=/u02/oradata/rman/rpt12c/rman_RPT12C_32_840418162_1.bkupset
        tag=TAG20140225T012921 comment=NONE
        channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01
        Finished backup at 25-FEB-14

        RMAN>

(3)再次运行RMAN备份,此次备份SYSAUX表空间,使用默认位置和格式:

        RMAN> backup as compressed backupset tablespace sysaux;

        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 full datafile backup set
        channel ORA_DISK_1: specifying datafile(s) in backup set
        input datafile file number=00003
        name=+DATA/RPT12C/DATAFILE/sysaux.257.826650753
        channel ORA_DISK_1: 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/
            nnndf0_tag20140225t013056_0.268.840418257 tag=TAG20140225T013056
            comment=NONE
        channel ORA_DISK_1: backup set complete, elapsed time: 00:01:35
        Finished backup at 25-FEB-14

        RMAN>

可按两种方式提供FORMAT参数:在ALLOCATE CHANNEL中提供,或作为CONFIGURE命令的一部分提供。默认的FORMAT仅适用于自动备份控制文件,见下例:

        CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR
            DEVICE TYPE DISK TO '%F'; # default