Oracle 11g 中恢复管理器RMAN介绍

Posted 熊出陌

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Oracle 11g 中恢复管理器RMAN介绍相关的知识,希望对你有一定的参考价值。

这是我平时摘录的笔记,从管理艺术那本书上摘录出来的,放到这里

 

RMAN 可在数据库服务器的帮助下从数据库内备份数据文件,可构造数据文件映像副本、控制文件和控制文件映像、对当日志 SPFILE 和RMAN备份片的备份,建议使用RMAN界面备份数据库

 

 RMAN好处:

 

1 增量备份
2 可联机修补数据文件的部分讹误数据块,不需要从备份文件复原文件 称为介质恢复
3 人为错误最小化
4 一条简单命令 BACKUP DATABASE即可
5 RMAN新的快比较特性允许在备份中跳过数据文件中从未使用的数据块备份,节省存储空间和备份时间
6 通过RMAN容易进行自动化备份和恢复
7 在备份和恢复中可 进行错误检查
8 RMAN在联机备份中不生成重做信息,降低联机备份开销
9 二进制压缩特性降低保存磁盘上备份的大小
10 使用恢复目录catelog可直接在其中的存储备份和恢复脚本
11 RMAN 可执行模拟备份和恢复
12 允许进行映像复制,类似操作系统的文件备份
13 RMAN与第三方介质管理产品集成,使磁带备份极为容易
14 RMAN与OEM集成的很好
15 可利用RMAN功能方便克隆数据库和维护备用数据库

 

RMAN执行其备份和恢复功能的条目列表

 

目标数据库:RMAN需要备份的数据库
RMAN信息库:RMAN关于备份。归档重做日志及其拥有的活动的元数据,每个数据库控制文件为RMAN信息    库主存储
恢复目录模式:拥有RMAN备份和恢复元数据的数据库中数据库模式
RMAN客户机:用户通过RMAN客户机管理RMAN操作
RMAN可执行程序:管理所有备份和恢复操作的实际程序
服务器进程:RMAN可执行程序与目标数据库通信的后台进程,在备份和恢复中完成读写磁盘和磁带设备的实际工作

注:在使用RMAN中,有三个实体是可选的:闪回恢复区 恢复目录数据库和介质管理软件

 

RMAN信息库和恢复目录

RMAN信息库包含的条目信息:

数据文件备份集合副本
归档重做日志副本和备份集
表空间和数据文件信息
存储脚本和RMAN配置设置

RMAN的信息首先写入到控制文件,然后在写到恢复目录(如果存在)

在创建新备份集时,可在V$BACKUP_SET视图看到响应的信息,也可以在恢复目录视图RC_BACUP_SET中看到相同的信息

SQL> select * from V$BACKUP_SET;

     RECID	STAMP  SET_STAMP  SET_COUNT B CON INCREMENTAL_LEVEL	PIECES START_TIM COMPLETIO ELAPSED_SECONDS BLOCK_SIZE INP KEE KEEP_UNTI KEEP_OPTION MUL
---------- ---------- ---------- ---------- - --- ----------------- ---------- --------- --------- --------------- ---------- --- --- --------- ----------- ---
	 1  929985613  929985608	  1 L NO			     1 07-DEC-16 07-DEC-16		 5	  512 NO  NO			    NO
	 2  929985708  929985624	  2 D NO			     1 07-DEC-16 07-DEC-16		84	 8192 NO  NO			    NO
	 3  929985711  929985709	  3 D YES			     1 07-DEC-16 07-DEC-16		 2	16384 NO  NO			    NO
	 4  929985721  929985720	  4 L NO			     1 07-DEC-16 07-DEC-16		 1	  512 NO  NO			    NO

有一些RMAN命令可在仅使用恢复目录时使用。还可以在仅使用恢复目录时使用RMAN存储脚本。如果使用控制文件,要冒某些历史数据被覆盖的风险,但恢复目录将保障这些数据的安全,这是因为控制文件与备份有关的活动分配的空间有限,从而恢复目录有更多的空间存储备份历史。系统中的一个恢复目录可对多个Oracle数据库执行备份、复原和恢复活动.Oracle建议使用专门的数据库来运行恢复目录

连接到RMAN

[[email protected] ~]{content}nbsp;rman

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 8 16:04:15 2016

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

RMAN> connect target /

connected to target database: YOON (DBID=781817860)

-- 或者
[[email protected] ~]{content}nbsp;rman target system/alog20160428

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 8 16:07:34 2016

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: YOON (DBID=781817860)

RMAN> 
-- 或者通过操作系统认证
[[email protected] ~]{content}nbsp;rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu Dec 8 16:09:25 2016

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: YOON (DBID=781817860)

 

在ORACLE 10g 版本2中,引用了自己的专有介质管理方案 Oracle Secure Backup

 

RMAN脚本,提供了两种脚本:

1 存储脚本:保存在RMAN恢复目录中

2 文本脚本:保存在普通的文本文件中

 

 RMAN术语:

1 备份片

一个操作系统文件 包含一个数据文件、一个控制文件或数个归档重做日志文件的备份,备份信息以RMAN专门格式存储

2 备份集

逻辑结构,由一个或多个RMAN备份片组成。可在磁盘或磁带上创建备份集,备份集时仅RMAN能识别的适当格式的一个文件或一组文件,只有RMAN才能使用备份集恢复数据库

3 映像文件

类似UNIX中用cp命令或DOC中用COPY命令所做的操作系统文件备份,可制作数据文件、控制文件和归档重做日志文件的映像副本。RMAN映像副本只能做到磁盘,不能做到磁带中

4 代理副本

还可以执行一种叫代理副本的特殊备份,其中介质管理器得到复制进程的控制权,对磁盘不能使用代理副本。

5 通道

RMAN必须使用对服务器的某种连接,以执行备份和恢复任务,通道就代表这种连接。通道指定用于备份或恢复的设备、磁盘或磁带。可预先配置通道。也可手动指定 

RMAN还可以使用利用非RMAN操作系统应用程序做的副本,这些类型的副本称为用户管理的副本或操作系统副本

 

 RMAN允许对每个备份使用一个标记tag,以便容易地识别出相应的备份

 标记全数据库备份

SQL>BACKUP TAG ‘weekly_full_db_bkup‘ DATABASE;

 备份命令还可以使员工FORMAT来指定备份片和副本的位置和名字们使用替换变量来生成唯一的文件名

SQL>BACKUP FORMAT=‘AL_%d/%t/%s/%p‘ ARCHIVELOG LIKE ‘%arc_dest%‘;

 

RMAN命令

备份命令
作业命令
复制命令
报告命令
列表命令
验证命令

 

备份命令

RMAN> BACKUP DATABASE;

Starting backup at 09-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=200 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/yoon/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/yoon/example01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_TAG20161209T104834_d4n6w3lm_.bkp tag=TAG20161209T104834 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:16
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsnf_TAG20161209T104834_d4n70cdv_.bkp tag=TAG20161209T104834 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16

RMAN> BACKUP TABLESPACE users;
Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_TAG20161209T105136_d4n71s00_.bkp tag=TAG20161209T105136 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16
RMAN> BACKUP DATAFILE ‘/u01/app/oracle/oradata/yoon/users01.dbf‘;

Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_TAG20161209T105248_d4n7412s_.bkp tag=TAG20161209T105248 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16

使用简单的BACKUP DATABASE命令与使用BACKUP AS BACKUPSET DATABASE命令相同。如果使用上述命令,RMAN将生成一个或多个备份集。他们是RMAN专门的逻辑备份单元

映像复制备份

RMAN> BACKUP AS COPY DATABASE;

Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
output file name=/u01/app/oracle/recovery_area/YOON/datafile/o1_mf_system_d4n7orl8_.dbf tag=TAG20161209T110216 RECID=3 STAMP=930135794
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
output file name=/u01/app/oracle/recovery_area/YOON/datafile/o1_mf_sysaux_d4n7qwjt_.dbf tag=TAG20161209T110216 RECID=4 STAMP=930135854
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/yoon/undotbs01.dbf
output file name=/u01/app/oracle/recovery_area/YOON/datafile/o1_mf_undotbs1_d4n7sk41_.dbf tag=TAG20161209T110216 RECID=5 STAMP=930135865
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/yoon/example01.dbf
output file name=/u01/app/oracle/recovery_area/YOON/datafile/o1_mf_example_d4n7t08c_.dbf tag=TAG20161209T110216 RECID=6 STAMP=930135881
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/recovery_area/YOON/controlfile/o1_mf_TAG20161209T110216_d4n7thbt_.ctl tag=TAG20161209T110216 RECID=7 STAMP=930135888
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
output file name=/u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7tllf_.dbf tag=TAG20161209T110216 RECID=8 STAMP=930135890
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnsnf_TAG20161209T110216_d4n7tmsz_.bkp tag=TAG20161209T110216 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16
RMAN> BACKUP AS COPY TABLESPACE USERS;

Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
output file name=/u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7xwgq_.dbf tag=TAG20161209T110636 RECID=9 STAMP=930135997
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16

RMAN> BACKUP AS COPY DATAFILE ‘/u01/app/oracle/oradata/yoon/users01.dbf‘;

Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
output file name=/u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7ym0w_.dbf tag=TAG20161209T110658 RECID=10 STAMP=930136019
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:02
Finished backup at 09-DEC-16

 

可以在备份时候,使用tag

RMAN> BACKUP DATABASE TAG=‘weekly_backup‘;

Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/yoon/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/yoon/example01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_WEEKLY_BACKUP_d4n89gvn_.bkp tag=WEEKLY_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsnf_WEEKLY_BACKUP_d4n8drs0_.bkp tag=WEEKLY_BACKUP comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 09-DEC-16

 

RMAN备份逻辑检查

在备份过程中使用关键字LOGICAL让RMAN对备份文件进行逻辑检查。

 

增量备份

增量备份的级别为0或者1,

0:像完整备份一样复制所有的数据库,并且作为后续增量备份的基础

1:首先有一个基本的级别为0的备份

提供了两种类型

差异备份:备份最近级别为1或级别为0的增量备份后更改的所有块

累计备份:备份最近级别为0的增量备份后更改的所有块

开始一个级别为0的备份,

RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;

Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/yoon/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/yoon/example01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnnd0_TAG20161209T113141_d4n9dyty_.bkp tag=TAG20161209T113141 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting incremental level 0 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsn0_TAG20161209T113141_d4n9j87n_.bkp tag=TAG20161209T113141 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16

一旦有了级别为0的备份,可执行级别为1的差异增量备份

RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;

Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/yoon/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/yoon/example01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnnd1_TAG20161209T113421_d4n9kxs2_.bkp tag=TAG20161209T113421 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting incremental level 1 datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsn1_TAG20161209T113421_d4n9lqj6_.bkp tag=TAG20161209T113421 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16

增量备份文件大小取决于更改过的块的数据和增量级别.累积备份比差异备份大,因为他们复制相同级别备份所复制的数据。具有减少恢复时间的有几点,如果空间不是个问题,建议累积备份

 

结合增量备份提出的备份策略

星期天 执行一个级别为0的增量备份
星期一到星期六,执行级别为1的差异增量备份
下一周重复这个循环

在这个策略中,如果需要星期四晚上恢复数据,应该讲星期一到星期三的增量备份应用到星期天的级别为0的备份

考虑一个累积备份替代策略

星期天,执行级别为0的增量备份
星期一到星期六,执行级别为1的累积增量备份
下一周重复这个循环

在此情况下,每天的级别为1的累积备份将备份自星期天备份以来更改的所有块。因此,如果星期四需要恢复,只需要将头天晚上的为一个累积备份应用到星期天的级别为0的增量备份即可

 

作业命令

不能单独使用ALLOCATE CHANNEL和SWITCH命令,必须与RUN命令一起使用

SQL>RUN{
ALLOCATE CHANNEL c1 DEVICE TYPE DISK
PARMS=‘ENV=(NSR_GROUP=default)‘;
BACKUP DATAFILE 1;
}

allocated channel: c1
channel c1: SID=200 device type=DISK

Starting backup at 09-DEC-16
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
channel c1: starting piece 1 at 09-DEC-16
channel c1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_TAG20161209T135641_d4nkwsns_.bkp tag=TAG20161209T135641 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:25
channel c1: starting full datafile backup set
channel c1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel c1: starting piece 1 at 09-DEC-16
channel c1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsnf_TAG20161209T135641_d4nkxmok_.bkp tag=TAG20161209T135641 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16
released channel: c1



ALLOCATE CHANNEL c1 DEVICE TYPE DISK 这个类型可以从

RMAN> list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
8       Full    3.27M      DISK        00:00:01     09-DEC-16      

这里可以查出来

SWITCH 命令类似于ALTER DATABASE RENAME  DATAFILE命令,允许用RMAN所做的文件副本替换一个数据文件

 

数据文件副本

RMAN的BACKUP AS COPY命令构造数据文件的一个无格式副本,但Oracle不加以在10g使用COPY命令。这些映像副本等同于使用操作系统使用程序所做的副本

RMAN> BACKUP AS COPY DATAFILE 1;

Starting backup at 09-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=200 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
output file name=/u01/app/oracle/recovery_area/YOON/datafile/o1_mf_system_d4nln51m_.dbf tag=TAG20161209T140908 RECID=11 STAMP=930146971
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=/u01/app/oracle/recovery_area/YOON/controlfile/o1_mf_TAG20161209T140908_d4nlnxq6_.ctl tag=TAG20161209T140908 RECID=12 STAMP=930146974
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 09-DEC-16
channel ORA_DISK_1: finished piece 1 at 09-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnsnf_TAG20161209T140908_d4nlo0x7_.bkp tag=TAG20161209T140908 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 09-DEC-16

-- 使用旧的COPY命令
RMAN> COPY DATAFILE 1 TO ‘/tmp/test.copy‘;

Starting backup at 09-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
output file name=/tmp/test.copy tag=TAG20161209T141120 RECID=13 STAMP=930147105
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
Finished backup at 09-DEC-16

 

备份删除

使用DELETE命令来删除RMAN所做的物理备份,DELETE命令删除物理备份,更新控制文件记录及支出备份已删除,而且此命令还从恢复目录中删除备份的记录,可删除备份集。归档重做日志和数据文件副本

通常应该使用RMAN的DELETE命令而不是操作系统的删除命令来删除RMAN备份,否则,RMAN的信息库将会包含不在可用的备份记录

删除RMAN已经至少两次备份到磁盘的所有归档重做日志

RMAN> DELETE ARCHIVELOG ALL BACKED UP 2 TIMES TO DEVICE TYPE DISK;

released channel: ORA_DISK_1
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=200 device type=DISK
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_67_929897742.dbf thread=1 sequence=67
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_68_929897742.dbf thread=1 sequence=68
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_69_929897742.dbf thread=1 sequence=69
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_70_929897742.dbf thread=1 sequence=70
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_71_929897742.dbf thread=1 sequence=71
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_72_929897742.dbf thread=1 sequence=72
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_73_929897742.dbf thread=1 sequence=73
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_74_929897742.dbf thread=1 sequence=74
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_75_929897742.dbf thread=1 sequence=75
RMAN-08138: WARNING: archived log not deleted - must create more backups
archived log file name=/u01/oradata/archive_bak/1_76_929897742.dbf thread=1 sequence=76

DELETE OBSOLETE命令将删除所有不在需要的备份,可以定期执行DELETE OBSOLETE删除所有废弃的备份。

DELETE EXPIRED命令删除国企的备份的恢复目录记录,并将它们标记成DELETED。可以先执行CROSSCHECK命令,RMAN标记它不能找到的备份为国企。一个备份过期代表RMAN不能找到该备份文件,可是使用DELETE EXPIRED命令从控制文件和恢复目录删除这些文件的记录

 

报告命令

RMAN提供了几个非常有用的报告命令,他们允许检查备份和恢复过程。可查询RMAN,有哪些文件需要备份,哪些文件废弃,从而可以删除

REPORT SCHEMA命令列出目标数据库的所有数据文件

REPORT OBSOLETE命令显示被锁选择的保留策略认定为废弃的所有备份

RMAN> REPORT OBSOLETE;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of obsolete backups and copies
Type                 Key    Completion Time    Filename/Handle
-------------------- ------ ------------------ --------------------
Control File Copy     2      07-DEC-16          /u01/app/oracle/oradata/yoon/standby_control01.ctl
Archive Log          141    07-DEC-16          /u01/oradata/archive_bak/1_67_929897742.dbf
Archive Log          143    07-DEC-16          /u01/oradata/archive_bak/1_68_929897742.dbf
Archive Log          145    08-DEC-16          /u01/oradata/archive_bak/1_69_929897742.dbf
Archive Log          147    08-DEC-16          /u01/oradata/archive_bak/1_70_929897742.dbf
Archive Log          149    08-DEC-16          /u01/oradata/archive_bak/1_71_929897742.dbf
Archive Log          151    08-DEC-16          /u01/oradata/archive_bak/1_72_929897742.dbf
Archive Log          153    08-DEC-16          /u01/oradata/archive_bak/1_73_929897742.dbf
Archive Log          155    09-DEC-16          /u01/oradata/archive_bak/1_74_929897742.dbf
Archive Log          157    09-DEC-16          /u01/oradata/archive_bak/1_75_929897742.dbf
Datafile Copy        6      09-DEC-16          /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_example_d4n7t08c_.dbf
Control File Copy     7      09-DEC-16          /u01/app/oracle/recovery_area/YOON/controlfile/o1_mf_TAG20161209T110216_d4n7thbt_.ctl
Datafile Copy        8      09-DEC-16          /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7tllf_.dbf
Datafile Copy        9      09-DEC-16          /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7xwgq_.dbf
Backup Set           9      09-DEC-16         
  Backup Piece       9      09-DEC-16          /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnsnf_TAG20161209T110216_d4n7tmsz_.bkp
Datafile Copy        10     09-DEC-16          /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7ym0w_.dbf
Backup Set           10     09-DEC-16         
  Backup Piece       10     09-DEC-16          /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_WEEKLY_BACKUP_d4n89gvn_.bkp
Backup Set           11     09-DEC-16         
  Backup Piece       11     09-DEC-16          /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsnf_WEEKLY_BACKUP_d4n8drs0_.bkp
Backup Set           13     09-DEC-16         
  Backup Piece       13     09-DEC-16          /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsn0_TAG20161209T113141_d4n9j87n_.bkp
Backup Set           15     09-DEC-16         
  Backup Piece       15     09-DEC-16          /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsn1_TAG20161209T113421_d4n9lqj6_.bkp
Backup Set           16     09-DEC-16         
  Backup Piece       16     09-DEC-16          /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_TAG20161209T135641_d4nkwsns_.bkp
Datafile Copy        11     09-DEC-16          /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_system_d4nln51m_.dbf
Backup Set           17     09-DEC-16         
  Backup Piece       17     09-DEC-16          /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsnf_TAG20161209T135641_d4nkxmok_.bkp

RMAN> REPORT NEED BACKUP;

RMAN retention policy will be applied to the command
RMAN retention policy is set to redundancy 1
Report of files with less than 1 redundant backups
File #bkps Name
---- ----- -----------------------------------------------------

RMAN> 

 

目录报告

CATALOG命令帮助表示和编目文件,这儿写文件未在RMAN中记录,因此RMAN并不知道他们。下面的任意事件都可能导致这种情况出现

复原一个备份控制文件
复原一个备用控制文件
重建控制文件
启用DB_RECOVERY_FILE_DEST参数,然后又禁用它

 

列表命令

LIST BACKUP 列出RMAN 注册的所有已经完成的备份。列出所有的备份集和映像集以及备份文件中的单独数据文件、控制文件、归档重做日志文件和SPFILE。也可以通过查询V$BACKUP_FILES和RC_BACKUP_FILES恢复目录视图列出所有备份

RMAN> LIST BACKUP;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
9       Full    80.00K     DISK        00:00:01     09-DEC-16      
        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20161209T110216
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnsnf_TAG20161209T110216_d4n7tmsz_.bkp
  SPFILE Included: Modification time: 08-DEC-16
  SPFILE db_unique_name: YOON

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
10      Full    1.09G      DISK        00:01:43     09-DEC-16      
        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: WEEKLY_BACKUP
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_WEEKLY_BACKUP_d4n89gvn_.bkp
  List of Datafiles in backup set 10
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1441493    09-DEC-16 /u01/app/oracle/oradata/yoon/system01.dbf
  2       Full 1441493    09-DEC-16 /u01/app/oracle/oradata/yoon/sysaux01.dbf
  3       Full 1441493    09-DEC-16 /u01/app/oracle/oradata/yoon/undotbs01.dbf
  4       Full 1441493    09-DEC-16 /u01/app/oracle/oradata/yoon/users01.dbf
  5       Full 1441493    09-DEC-16 /u01/app/oracle/oradata/yoon/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
11      Full    9.64M      DISK        00:00:02     09-DEC-16      
        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: WEEKLY_BACKUP
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsnf_WEEKLY_BACKUP_d4n8drs0_.bkp
  SPFILE Included: Modification time: 08-DEC-16
  SPFILE db_unique_name: YOON
  Control File Included: Ckp SCN: 1441612      Ckp time: 09-DEC-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
12      Incr 0  1.09G      DISK        00:01:42     09-DEC-16      
        BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20161209T113141
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnnd0_TAG20161209T113141_d4n9dyty_.bkp
  List of Datafiles in backup set 12
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1    0  Incr 1443387    09-DEC-16 /u01/app/oracle/oradata/yoon/system01.dbf
  2    0  Incr 1443387    09-DEC-16 /u01/app/oracle/oradata/yoon/sysaux01.dbf
  3    0  Incr 1443387    09-DEC-16 /u01/app/oracle/oradata/yoon/undotbs01.dbf
  4    0  Incr 1443387    09-DEC-16 /u01/app/oracle/oradata/yoon/users01.dbf
  5    0  Incr 1443387    09-DEC-16 /u01/app/oracle/oradata/yoon/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
13      Incr 0  9.64M      DISK        00:00:01     09-DEC-16      
        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20161209T113141
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsn0_TAG20161209T113141_d4n9j87n_.bkp
  SPFILE Included: Modification time: 08-DEC-16
  SPFILE db_unique_name: YOON
  Control File Included: Ckp SCN: 1443472      Ckp time: 09-DEC-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
14      Incr 1  352.00K    DISK        00:00:15     09-DEC-16      
        BP Key: 14   Status: AVAILABLE  Compressed: NO  Tag: TAG20161209T113421
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnnd1_TAG20161209T113421_d4n9kxs2_.bkp
  List of Datafiles in backup set 14
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1    1  Incr 1443561    09-DEC-16 /u01/app/oracle/oradata/yoon/system01.dbf
  2    1  Incr 1443561    09-DEC-16 /u01/app/oracle/oradata/yoon/sysaux01.dbf
  3    1  Incr 1443561    09-DEC-16 /u01/app/oracle/oradata/yoon/undotbs01.dbf
  4    1  Incr 1443561    09-DEC-16 /u01/app/oracle/oradata/yoon/users01.dbf
  5    1  Incr 1443561    09-DEC-16 /u01/app/oracle/oradata/yoon/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
15      Incr 1  9.64M      DISK        00:00:02     09-DEC-16      
        BP Key: 15   Status: AVAILABLE  Compressed: NO  Tag: TAG20161209T113421
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsn1_TAG20161209T113421_d4n9lqj6_.bkp
  SPFILE Included: Modification time: 08-DEC-16
  SPFILE db_unique_name: YOON
  Control File Included: Ckp SCN: 1443617      Ckp time: 09-DEC-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
16      Full    596.60M    DISK        00:00:20     09-DEC-16      
        BP Key: 16   Status: AVAILABLE  Compressed: NO  Tag: TAG20161209T135641
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnndf_TAG20161209T135641_d4nkwsns_.bkp
  List of Datafiles in backup set 16
  File LV Type Ckp SCN    Ckp Time  Name
  ---- -- ---- ---------- --------- ----
  1       Full 1458913    09-DEC-16 /u01/app/oracle/oradata/yoon/system01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
17      Full    9.64M      DISK        00:00:02     09-DEC-16      
        BP Key: 17   Status: AVAILABLE  Compressed: NO  Tag: TAG20161209T135641
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_ncsnf_TAG20161209T135641_d4nkxmok_.bkp
  SPFILE Included: Modification time: 08-DEC-16
  SPFILE db_unique_name: YOON
  Control File Included: Ckp SCN: 1458987      Ckp time: 09-DEC-16

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
18      Full    80.00K     DISK        00:00:01     09-DEC-16      
        BP Key: 18   Status: AVAILABLE  Compressed: NO  Tag: TAG20161209T140908
        Piece Name: /u01/app/oracle/recovery_area/YOON/backupset/2016_12_09/o1_mf_nnsnf_TAG20161209T140908_d4nlo0x7_.bkp
  SPFILE Included: Modification time: 08-DEC-16
  SPFILE db_unique_name: YOON

RMAN> LIST COPY;

List of Datafile Copies
=======================

Key     File S Completion Time Ckp SCN    Ckp Time       
------- ---- - --------------- ---------- ---------------
13      1    A 09-DEC-16       1460803    09-DEC-16      
        Name: /tmp/test.copy
        Tag: TAG20161209T141120

11      1    A 09-DEC-16       1460490    09-DEC-16      
        Name: /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_system_d4nln51m_.dbf
        Tag: TAG20161209T140908

10      4    A 09-DEC-16       1440772    09-DEC-16      
        Name: /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7ym0w_.dbf
        Tag: TAG20161209T110658

9       4    A 09-DEC-16       1440676    09-DEC-16      
        Name: /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7xwgq_.dbf
        Tag: TAG20161209T110636

8       4    A 09-DEC-16       1440398    09-DEC-16      
        Name: /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_users_d4n7tllf_.dbf
        Tag: TAG20161209T110216

6       5    A 09-DEC-16       1440358    09-DEC-16      
        Name: /u01/app/oracle/recovery_area/YOON/datafile/o1_mf_example_d4n7t08c_.dbf
        Tag: TAG20161209T110216

List of Control File Copies
===========================

Key     S Completion Time Ckp SCN    Ckp Time       
------- - --------------- ---------- ---------------
12      A 09-DEC-16       1460531    09-DEC-16      
        Name: /u01/app/oracle/recovery_area/YOON/controlfile/o1_mf_TAG20161209T140908_d4nlnxq6_.ctl
        Tag: TAG20161209T140908

7       A 09-DEC-16       1440394    09-DEC-16      
        Name: /u01/app/oracle/recovery_area/YOON/controlfile/o1_mf_TAG20161209T110216_d4n7thbt_.ctl
        Tag: TAG20161209T110216

2       A 07-DEC-16       1106297    07-DEC-16      
        Name: /u01/app/oracle/oradata/yoon/standby_control01.ctl
        Tag: TAG20161207T101949

List of Archived Log Copies for database with db_unique_name YOON
=====================================================================

Key     Thrd Seq     S Low Time 
------- ---- ------- - ---------
141     1    67      A 07-DEC-16
        Name: /u01/oradata/archive_bak/1_67_929897742.dbf

143     1    68      A 07-DEC-16
        Name: /u01/oradata/archive_bak/1_68_929897742.dbf

145     1    69      A 07-DEC-16
        Name: /u01/oradata/archive_bak/1_69_929897742.dbf

147     1    70      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_70_929897742.dbf

149     1    71      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_71_929897742.dbf

151     1    72      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_72_929897742.dbf

153     1    73      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_73_929897742.dbf

155     1    74      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_74_929897742.dbf

157     1    75      A 09-DEC-16
        Name: /u01/oradata/archive_bak/1_75_929897742.dbf

159     1    76      A 09-DEC-16
        Name: /u01/oradata/archive_bak/1_76_929897742.dbf

RMAN> LIST ARCHIVELOG ALL;

List of Archived Log Copies for database with db_unique_name YOON
=====================================================================

Key     Thrd Seq     S Low Time 
------- ---- ------- - ---------
141     1    67      A 07-DEC-16
        Name: /u01/oradata/archive_bak/1_67_929897742.dbf

143     1    68      A 07-DEC-16
        Name: /u01/oradata/archive_bak/1_68_929897742.dbf

145     1    69      A 07-DEC-16
        Name: /u01/oradata/archive_bak/1_69_929897742.dbf

147     1    70      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_70_929897742.dbf

149     1    71      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_71_929897742.dbf

151     1    72      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_72_929897742.dbf

153     1    73      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_73_929897742.dbf

155     1    74      A 08-DEC-16
        Name: /u01/oradata/archive_bak/1_74_929897742.dbf

157     1    75      A 09-DEC-16
        Name: /u01/oradata/archive_bak/1_75_929897742.dbf

159     1    76      A 09-DEC-16
        Name: /u01/oradata/archive_bak/1_76_929897742.dbf

 

LIST COPY:相当于LIST BACKUP,显示利用RMAN做的所有副本的列表

LIST ARCHIVELOG ALL:命令列出所有可得到的归档日志副本

 

验证命令:

RMAN> VALIDATE BACKUPSET 1;

 

RMAN配置参数

RMAN> SHOW ALL;

RMAN configuration parameters for database with db_unique_name YOON are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
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_yoon.f‘; # default

 

1 备份保留的策略

备份保留策略指示RMAN合适考虑废弃数据文件和日志文件的备份,请注意,当指定RMAN在一定的时间后考虑废弃某个备份文件时,RMAN只标记该文件为废弃,并不删除它

默认的REDUNDANCY选项和RETENTION WINDOW选项

RMAN> CONFIGURE RETENTION POLICY TO REDUNDANCY 2;

using target database control file instead of recovery catalog
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters are successfully stored

 如果每天备份数据文件,RMAN只保留每个数据库文件的两个备份,RMAN将保留恢复两天的数据文件备份需要的所有重做日志。任何早于两天的备份被认为是废弃的。

如果希望之星一个PITR到某个比最近备份更早的时间。归档的备份是有用的。如果当前备份不能使用,还有一个备选的备份集可用

RECOVERY WINDOW选项

如果数据库收到介质故障的影响,则从过去的某个时间开始恢复,RMAN保留数据文件和日志文件比恢复时间窗造一个备份的所欲备份,例如,如果恢复时间窗为7天,RMAN将保留7天以前最后做的备份开始的所有备份,如下设置恢复时间窗

RMAN> CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;

using target database control file instead of recovery catalog
old RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO REDUNDANCY 2;
new RMAN configuration parameters:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 14 DAYS;
new RMAN configuration parameters are successfully stored

 

 默认设备类型

备份的默认设备为磁盘,RMAN将自动备份到服务器上文件系统中,如果希望备份到磁盘中,需要配置默认设备类型为sbt(所有磁带目标都为sbt)

SQL>CONFIGURE DEFUALT DEVICE TYPE TO sbt;

 如果希望从默认设备切换到磁盘

SQL>CONFIGURE DEFAULT DEVICE TYPE TO DISK; 

 

备份优化

BACKUP OPTIMIZATION保证。如果RMAN已经备份了某个文件的相同版本,则不会进行该文件的备份。

SQL>CONFIGURE BACKUP OPTIMIZATION ON;

 控制文件参数

有几个设计控制文件备份的参数,

控制文件自动备份

如果将CONFIGURE AUTOBACKUP 设置成ON,则每次进行数据文件备份时,控制文件也与SPFILE一起自动备份。

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP ON;
new RMAN configuration parameters are successfully stored

 现在,如果使用任何备份命令,控制文件和SPFILE两者都会自动备份

 RMAN> BACKUP TABLESPACE sysaux;

Starting backup at 13-DEC-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=139 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_nnndf_TAG20161213T094438_d4ynn80x_.bkp tag=TAG20161213T094438 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/2016_12_13/o1_mf_s_930476744_d4ynp93n_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

 控制文件的备份位置和格式

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/u01/app/oracle/recovery_area/YOON/autobackup/cf_%F‘;

old RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/u01/app/oracle/recovery_area/YOON/autobackup/2016_12_13/cf_%F‘;
new RMAN configuration parameters:
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO ‘/u01/app/oracle/recovery_area/YOON/autobackup/cf_%F‘;
new RMAN configuration parameters are successfully stored

RMAN> BACKUP TABLESPACE sysaux;

Starting backup at 13-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_nnndf_TAG20161213T102630_d4yq2pz4_.bkp tag=TAG20161213T102630 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/cf_c-781817860-20161213-02 comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

 

 创建恢复目录模式

SQL> create temporary tablespace temp02 tempfile ‘/u01/app/oracle/oradata/yoon/temp02.dbf‘ size 10000M;
SQL> create tablespace rman_tbsp   
datafile ‘/u01/app/oracle/oradata/yoon/rman_tbsp.dbf‘   
size 5000M   
autoextend on next 500M maxsize 30000M;
SQL>CREATE USER RMAN IDENTIFIED BY rman 
TEMPORARY TABLESPACE temp02
DEFAULT TABLESPACE rman_tbsp
QUOTA UNLIMITED ON rman_tbsp;
SQL> GRANT RECOVERY_CATALOG_OWNER TO rman;

Grant succeeded.

 连接到RMAN

[[email protected] backupset]{content}nbsp;rman CATALOG rman/rman

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Dec 13 11:13:59 2016

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to recovery catalog database

RMAN> 
RMAN> connect target yoon

target database Password: 
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
ORA-01005: null password given; logon denied

RMAN> connect target yoon

target database Password: 
connected to target database: YOON (DBID=781817860)

 创建恢复目录

RMAN> CREATE CATALOG;

recovery catalog created

 删除恢复目录

RMAN> DROP CATALOG;

recovery catalog owner is RMAN
enter DROP CATALOG command again to confirm catalog removal

RMAN> DROP CATALOG;

recovery catalog dropped

 

 注册数据库

为使RMAN完成其工作,需要注册想要备份和恢复

 在恢复目录中注册数据库

RMAN> REGISTER DATABASE;

database registered in recovery catalog
starting full resync of recovery catalog
full resync complete

 

 检查数据库化身

RMAN> LIST INCARNATION;


List of Database Incarnations
DB Key  Inc Key DB Name  DB ID            STATUS  Reset SCN  Reset Time
------- ------- -------- ---------------- --- ---------- ----------
2       23      YOON     781817860        PARENT  1          15-AUG-09
2       4       YOON     781817860        CURRENT 945184     06-DEC-16

 

在每次执行备份或恢复时,BACKUP和COPY命令将自动执行重新同步,但是有两种情况,可能需要手动同步,目标数据库刚尽心改了许多物理备份,以及目标数据库在备份之间进行了大量的日志交换

RMAN> RESYNC CATALOG;

starting full resync of recovery catalog
full resync complete

 

 RMAN备份的例子

RMAN> BACKUP DATABASE;

Starting backup at 13-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=139 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/yoon/rman_tbsp.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/yoon/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/yoon/example01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_nnndf_TAG20161213T113851_d4yvbdng_.bkp tag=TAG20161213T113851 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/cf_c-781817860-20161213-04 comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

 

 备份归档日志,将所有数据文件及任意归档重做日志文件

 

RMAN> BACKUP DATABASE PLUS ARCHIVELOG;


Starting backup at 13-DEC-16
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=67 RECID=141 STAMP=930002431
input archived log thread=1 sequence=68 RECID=143 STAMP=930003123
input archived log thread=1 sequence=69 RECID=145 STAMP=930016837
input archived log thread=1 sequence=70 RECID=147 STAMP=930038442
input archived log thread=1 sequence=71 RECID=149 STAMP=930060057
input archived log thread=1 sequence=72 RECID=151 STAMP=930078067
input archived log thread=1 sequence=73 RECID=153 STAMP=930088842
input archived log thread=1 sequence=74 RECID=155 STAMP=930099902
input archived log thread=1 sequence=75 RECID=157 STAMP=930121228
input archived log thread=1 sequence=76 RECID=159 STAMP=930142615
input archived log thread=1 sequence=77 RECID=161 STAMP=930160254
input archived log thread=1 sequence=78 RECID=163 STAMP=930175228
input archived log thread=1 sequence=79 RECID=165 STAMP=930182421
input archived log thread=1 sequence=80 RECID=167 STAMP=930203266
input archived log thread=1 sequence=81 RECID=169 STAMP=930211579
input archived log thread=1 sequence=82 RECID=171 STAMP=930225529
input archived log thread=1 sequence=83 RECID=173 STAMP=930236428
input archived log thread=1 sequence=84 RECID=175 STAMP=930248459
input archived log thread=1 sequence=85 RECID=177 STAMP=930262535
input archived log thread=1 sequence=86 RECID=179 STAMP=930279663
input archived log thread=1 sequence=87 RECID=181 STAMP=930290431
input archived log thread=1 sequence=88 RECID=183 STAMP=930305189
input archived log thread=1 sequence=89 RECID=185 STAMP=930320950
input archived log thread=1 sequence=90 RECID=187 STAMP=930334014
input archived log thread=1 sequence=91 RECID=189 STAMP=930348429
input archived log thread=1 sequence=92 RECID=191 STAMP=930364903
input archived log thread=1 sequence=93 RECID=193 STAMP=930385632
input archived log thread=1 sequence=94 RECID=195 STAMP=930406626
input archived log thread=1 sequence=95 RECID=197 STAMP=930424789
input archived log thread=1 sequence=96 RECID=199 STAMP=930434440
input archived log thread=1 sequence=97 RECID=201 STAMP=930448841
input archived log thread=1 sequence=98 RECID=203 STAMP=930469306
input archived log thread=1 sequence=99 RECID=205 STAMP=930482166
input archived log thread=1 sequence=100 RECID=207 STAMP=930482728
input archived log thread=1 sequence=101 RECID=209 STAMP=930483779
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_annnn_TAG20161213T114259_d4yvl4gn_.bkp tag=TAG20161213T114259 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:05
Finished backup at 13-DEC-16

Starting backup at 13-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/yoon/rman_tbsp.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/yoon/undotbs01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/yoon/example01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_nnndf_TAG20161213T114505_d4yvp467_.bkp tag=TAG20161213T114505 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:56
Finished backup at 13-DEC-16

Starting backup at 13-DEC-16
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=102 RECID=211 STAMP=930484028
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_annnn_TAG20161213T114709_d4yvsx85_.bkp tag=TAG20161213T114709 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/cf_c-781817860-20161213-05 comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

 

 用脚本执行联机备份

SQL>RUN{
ALLOCATE CHANNEL d1 TYPE DISK;
ALLOCATE CHANNEL d2 TYPE DISK;
ALLOCATE CHANNEL d3 TYPE DISK;
BACKUP TAG whole_database_open FORMAT ‘/u01/app/oracle/recovery_area/backups/db_%t_%s_p%p‘ DATABASE;
SQL ‘alter system archive log current‘;
BACKUP ARCHIVELOG ALL FORMAT ‘/u01/app/oracle/recovery_area/backups/al_%t_%s_p%p‘;
BACKUP CURRENT CONTROLFILE TAG = cf1 FORMAT ‘/u01/app/oracle/recovery_area/backups/cf_%t_%s_p%p‘;
RELEASE channel d1;
RELEASE channel d2;
RELEASE channel d3;
}

allocated channel: d1
channel d1: SID=13 device type=DISK

allocated channel: d2
channel d2: SID=76 device type=DISK

allocated channel: d3
channel d3: SID=137 device type=DISK

Starting backup at 13-DEC-16
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
input datafile file number=00006 name=/u01/app/oracle/oradata/yoon/rman_tbsp.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel d1: starting piece 1 at 13-DEC-16
channel d2: starting full datafile backup set
channel d2: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/yoon/example01.dbf
channel d2: starting piece 1 at 13-DEC-16
channel d3: starting full datafile backup set
channel d3: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/yoon/sysaux01.dbf
input datafile file number=00003 name=/u01/app/oracle/oradata/yoon/undotbs01.dbf
channel d3: starting piece 1 at 13-DEC-16
channel d1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/backups/db_930494182_54_p1 tag=WHOLE_DATABASE_OPEN comment=NONE
channel d1: backup set complete, elapsed time: 00:00:04
channel d2: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/backups/db_930494182_55_p1 tag=WHOLE_DATABASE_OPEN comment=NONE
channel d2: backup set complete, elapsed time: 00:01:46
channel d3: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/backups/db_930494183_56_p1 tag=WHOLE_DATABASE_OPEN comment=NONE
channel d3: backup set complete, elapsed time: 00:01:45
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/cf_c-781817860-20161213-08 comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

sql statement: alter system archive log current

Starting backup at 13-DEC-16
current log archived
channel d1: starting archived log backup set
channel d1: specifying archived log(s) in backup set
input archived log thread=1 sequence=67 RECID=141 STAMP=930002431
input archived log thread=1 sequence=68 RECID=143 STAMP=930003123
input archived log thread=1 sequence=69 RECID=145 STAMP=930016837
input archived log thread=1 sequence=70 RECID=147 STAMP=930038442
input archived log thread=1 sequence=71 RECID=149 STAMP=930060057
input archived log thread=1 sequence=72 RECID=151 STAMP=930078067
input archived log thread=1 sequence=73 RECID=153 STAMP=930088842
input archived log thread=1 sequence=74 RECID=155 STAMP=930099902
input archived log thread=1 sequence=75 RECID=157 STAMP=930121228
input archived log thread=1 sequence=76 RECID=159 STAMP=930142615
input archived log thread=1 sequence=77 RECID=161 STAMP=930160254
input archived log thread=1 sequence=78 RECID=163 STAMP=930175228
channel d1: starting piece 1 at 13-DEC-16
channel d2: starting archived log backup set
channel d2: specifying archived log(s) in backup set
input archived log thread=1 sequence=79 RECID=165 STAMP=930182421
input archived log thread=1 sequence=80 RECID=167 STAMP=930203266
input archived log thread=1 sequence=81 RECID=169 STAMP=930211579
input archived log thread=1 sequence=82 RECID=171 STAMP=930225529
input archived log thread=1 sequence=83 RECID=173 STAMP=930236428
input archived log thread=1 sequence=84 RECID=175 STAMP=930248459
input archived log thread=1 sequence=85 RECID=177 STAMP=930262535
input archived log thread=1 sequence=86 RECID=179 STAMP=930279663
input archived log thread=1 sequence=87 RECID=181 STAMP=930290431
input archived log thread=1 sequence=88 RECID=183 STAMP=930305189
input archived log thread=1 sequence=89 RECID=185 STAMP=930320950
input archived log thread=1 sequence=90 RECID=187 STAMP=930334014
channel d2: starting piece 1 at 13-DEC-16
channel d3: starting archived log backup set
channel d3: specifying archived log(s) in backup set
input archived log thread=1 sequence=91 RECID=189 STAMP=930348429
input archived log thread=1 sequence=92 RECID=191 STAMP=930364903
input archived log thread=1 sequence=93 RECID=193 STAMP=930385632
input archived log thread=1 sequence=94 RECID=195 STAMP=930406626
input archived log thread=1 sequence=95 RECID=197 STAMP=930424789
input archived log thread=1 sequence=96 RECID=199 STAMP=930434440
input archived log thread=1 sequence=97 RECID=201 STAMP=930448841
input archived log thread=1 sequence=98 RECID=203 STAMP=930469306
input archived log thread=1 sequence=99 RECID=205 STAMP=930482166
input archived log thread=1 sequence=100 RECID=207 STAMP=930482728
input archived log thread=1 sequence=101 RECID=209 STAMP=930483779
input archived log thread=1 sequence=102 RECID=211 STAMP=930484028
input archived log thread=1 sequence=103 RECID=213 STAMP=930493890
input archived log thread=1 sequence=104 RECID=215 STAMP=930493896
channel d3: starting piece 1 at 13-DEC-16
channel d1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/backups/al_930494306_58_p1 tag=TAG20161213T143826 comment=NONE
channel d1: backup set complete, elapsed time: 00:02:16
channel d1: starting archived log backup set
channel d1: specifying archived log(s) in backup set
input archived log thread=1 sequence=105 RECID=217 STAMP=930494299
input archived log thread=1 sequence=106 RECID=219 STAMP=930494305
channel d1: starting piece 1 at 13-DEC-16
channel d2: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/backups/al_930494306_59_p1 tag=TAG20161213T143826 comment=NONE
channel d2: backup set complete, elapsed time: 00:02:16
channel d3: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/backups/al_930494307_60_p1 tag=TAG20161213T143826 comment=NONE
channel d3: backup set complete, elapsed time: 00:02:15
channel d1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/backups/al_930494442_61_p1 tag=TAG20161213T143826 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-DEC-16

Starting backup at 13-DEC-16
channel d1: starting full datafile backup set
channel d1: specifying datafile(s) in backup set
including current control file in backup set
channel d1: starting piece 1 at 13-DEC-16
channel d1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/backups/cf_930494444_62_p1 tag=CF1 comment=NONE
channel d1: backup set complete, elapsed time: 00:00:03
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/cf_c-781817860-20161213-09 comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

released channel: d1

released channel: d2

released channel: d3

 

 备份控制文件

RMAN> BACKUP CURRENT CONTROLFILE;

Starting backup at 13-DEC-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=13 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_ncnnf_TAG20161213T144453_d4z676f5_.bkp tag=TAG20161213T144453 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/cf_c-781817860-20161213-0a comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

 

 备份表空间

RMAN> BACKUP TABLESPACE USERS;

Starting backup at 13-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=/u01/app/oracle/oradata/yoon/users01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_nnndf_TAG20161213T144643_d4z6bmlx_.bkp tag=TAG20161213T144643 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/cf_c-781817860-20161213-0b comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

 

备份数据文件

RMAN> BACKUP DATAFILE ‘/u01/app/oracle/oradata/yoon/system01.dbf‘;

Starting backup at 13-DEC-16
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/u01/app/oracle/oradata/yoon/system01.dbf
channel ORA_DISK_1: starting piece 1 at 13-DEC-16
channel ORA_DISK_1: finished piece 1 at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/backupset/2016_12_13/o1_mf_nnndf_TAG20161213T144748_d4z6dnv2_.bkp tag=TAG20161213T144748 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
Finished backup at 13-DEC-16

Starting Control File and SPFILE Autobackup at 13-DEC-16
piece handle=/u01/app/oracle/recovery_area/YOON/autobackup/cf_c-781817860-20161213-0c comment=NONE
Finished Control File and SPFILE Autobackup at 13-DEC-16

以上是关于Oracle 11g 中恢复管理器RMAN介绍的主要内容,如果未能解决你的问题,请参考以下文章

Oracle 11g 使用RMAN备份数据库

Oracle 11g单实例RMAN恢复到Oracle 11g RAC

Oracle 11g单实例RMAN恢复到Oracle 11g RAC

Oracle 11G RMAN 单实例异机恢复

Oracle 11g R2 rac通过rman 恢复到单实例数据库

Oracle 11g R2 RAC数据库备份通过RMAN恢复到单实例数据库实现