备份集过期时间_Oracle RMAN(Recovery Manager) – 备份集备份与镜像复制备份

58a74acb6e52d925ef9b4757a6017a84.png

Oracle RMAN(Recovery Manager) – 备份集备份与镜像复制备份

Filed under Oracle Backup and Recovery(备份恢复), oracle, RMAN, 备份, 备份集, 恢复, 镜像复制

backup命令能够产生两种备份:备份集和镜像复制。

RMAN> show device type;

RMAN configuration parameters for database with db_unique_name MAA are:

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

– 表示默认为备份集备份

backup其实更正确的命令为backup as backupset。执行该命令的时候数据库必须在MOUNT或是OPEN状态,如果是OPEN状态,那么数据库必须运行于归档模式。

[oracle@localhost ~]$ export ORACLE_HOME=/u01/app/oracle/product/10.2.0.1/dbhome_1

[oracle@localhost ~]$ export ORACLE_SID=luocs10g

[oracle@localhost ~]$ /u01/app/oracle/product/10.2.0.1/dbhome_1/bin/sqlplus "/as sysdba"

SQL> archvie log list

SP2-0734: unknown command beginning "archvie lo..." - rest of line ignored.

SQL> archive log list

Database log mode No Archive Mode

Automatic archival Disabled

Archive destination /u01/app/oracle/product/10.2.0.1/dbhome_1/dbs/arch

Oldest online log sequence 471

Current log sequence 473

[oracle@localhost ~]$ /u01/app/oracle/product/10.2.0.1/dbhome_1/bin/rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Mon Nov 5 18:30:49 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.

connected to target database: LUOCS10G (DBID=1391338094)

RMAN> backup as backupset datafile 5;

Starting backup at 05-NOV-2012 18:31:34

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=118 devtype=DISK

channel ORA_DISK_1: starting full datafile backupset

channel ORA_DISK_1: specifying datafile(s) in backupset

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03009: failure of backup command on ORA_DISK_1 channel at 11/05/2012 18:31:35

ORA-19602: cannot backup or copy active file in NOARCHIVELOG mode

创建备份集

术语解释

输入文件:被RMAN备份的文件,都有控制文件、归档日志、数据文件、参数文件4类;

备份集:输入文件的备份,物理上由备份片(Backup Piece)组成;

备份片:一种由RMAN管理的文件,一般以备份文件相称。一个备份片可以包含多个输入文件,一个输入文件也可以分散在多个备份片中。从备份管理的角度出发,可以认为备份集就是备份片的集合。备份片的命名方式分为传统和OMF两种:传统方式格式由format子句指定;OMF则采用自动格式,只要使用闪回恢复区或"to destination"子句即是利用OMF。

传统方式:

%a 数据库活动id

%c 备份片拷贝数

%d 数据库名

%D 天(DD)

%e 归档序列号

%F c-iiiiiiiiii-YYYYMMDD-QQ ,iiiiiiiiii是数据库id号,QQ是1-256的序列

%I dbid

%p 备份集中的备份片号

%s 备份集编号

%t 时间戳

%T YYYYMMDD,年月日

%u 八字符表示的备份集创建时间

%U %u_%p_%c

OMF方式:

RMAN> backup current controlfile;

Starting backup at 06-NOV-2012 02:36:50

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=58 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 06-NOV-2012 02:36:51

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 02:36:52

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnnf_TAG20121106T023650_89j1t3ml_.bkp tag=TAG20121106T023650 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 02:36:52

备份片名称:o1_mf_ncnnf_TAG20121106T023650_89j1t3ml_.bkp

从这里我们需要关注的是从7~11个字符,它表示在备份片中的输入文件是何种类型,分别有:

a – 归档日志

c – 控制文件

s – 参数文件

d – 数据文件

f – 除归档日志以外的任何文件

n – 出现在哪个位置,就表示否定含义,代表没有此类输入文件

比如上面输出的o1_mf_ncnnf_TAG20121106T023650_89j1t3ml_.bkp,其中ncnnf抛去3个n和f,就是控制文件

RMAN> backup datafile 6;

Starting backup at 06-NOV-2012 02:45:31

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=+MSDATA/maa/datafile/l.267.798570165

channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 02:45:31

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 02:45:32

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T024531_89j2bcop_.bkp tag=TAG20121106T024531 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 02:45:32

RMAN> backup spfile;

Starting backup at 06-NOV-2012 02:46:32

using channel ORA_DISK_1

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 06-NOV-2012 02:46:32

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 02:46:33

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsnf_TAG20121106T024632_89j2d8p7_.bkp tag=TAG20121106T024632 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 02:46:33

o1_mf_nnndf_TAG20121106T024531_89j2bcop_.bkp和o1_mf_nnsnf_TAG20121106T024632_89j2d8p7_.bkp,从中前面的表示数据文件,后面的为参数文件。

backup命令所产生的备份集的数量由以下几个因素决定。

1)输入文件的数量

2)并行度

3)输入文件的种类

4)小括号的使用

5)"plus archivelog"子句

输入文件的数量

一个备份集至少包含一个输入文件,输入文件不可以跨越多个备份集,所以备份集的数量不会超过输入文件的数量。

默认情况下一个备份集最多容纳64个输入文件,backup命令的filesperset子句可以修改这一设置。

看示例,我的L表空间有三个数据文件

SQL> col FILE_NAME for a60

SQL> select FILE_ID, FILE_NAME FROM dba_data_files where TABLESPACE_NAME = 'L';

FILE_ID FILE_NAME

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

5 +MSDATA/maa/datafile/l.266.798569345

6 +MSDATA/maa/datafile/l.267.798570165

7 +MSDATA/maa/datafile/l.268.798572257

RMAN> run {

2> allocate channel a1 device type disk;

3> backup as backupset tablespace l;

4> }

released channel: ORA_DISK_1

allocated channel: a1

channel a1: SID=58 device type=DISK

Starting backup at 06-NOV-2012 03:01:40

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a1: starting piece 1 at 06-NOV-2012 03:01:41

channel a1: finished piece 1 at 06-NOV-2012 03:01:42

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T030140_89j38o3g_.bkp tag=TAG20121106T030140 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:01:42

Starting Control File and SPFILE Autobackup at 06-NOV-2012 03:01:42

piece handle=/u01/recovery/MAA/autobackup/2012_11_06/o1_mf_s_798606102_89j38pm8_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 06-NOV-2012 03:01:43

released channel: a1

-- 只产生了一个备份集

RMAN> run {

2> allocate channel a1 device type disk;

3> backup as backupset tablespace l filesperset 1;

4> }

allocated channel: a1

channel a1: SID=58 device type=DISK

Starting backup at 06-NOV-2012 03:04:04

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

channel a1: starting piece 1 at 06-NOV-2012 03:04:05

channel a1: finished piece 1 at 06-NOV-2012 03:04:06

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T030405_89j3f5cl_.bkp tag=TAG20121106T030405 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

channel a1: starting piece 1 at 06-NOV-2012 03:04:06

channel a1: finished piece 1 at 06-NOV-2012 03:04:07

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T030405_89j3f6jq_.bkp tag=TAG20121106T030405 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a1: starting piece 1 at 06-NOV-2012 03:04:07

channel a1: finished piece 1 at 06-NOV-2012 03:04:08

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T030405_89j3f7o9_.bkp tag=TAG20121106T030405 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:04:08

Starting Control File and SPFILE Autobackup at 06-NOV-2012 03:04:08

piece handle=/u01/recovery/MAA/autobackup/2012_11_06/o1_mf_s_798606248_89j3f98y_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 06-NOV-2012 03:04:09

released channel: a1

-- 产生了三个备份集

并行度

备份集的数量不会低于backup并行度的数量。若一次备份的输入文件是20个,但是DBA使用了4个并行度,结果至少产生4个备份集。

切记不是使用了4个通道就能使用4个并行度,如果输入文件只有3个,充其量并行度为3.

我们只设置了2个通道,结果是创建了2个备份集

RMAN> run {

2> allocate channel a1 device type disk;

3> allocate channel a2 device type disk;

4> backup as backupset tablespace l;

5> }

allocated channel: a1

channel a1: SID=58 device type=DISK

allocated channel: a2

channel a2: SID=45 device type=DISK

Starting backup at 06-NOV-2012 03:10:13

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a1: starting piece 1 at 06-NOV-2012 03:10:13

channel a2: starting full datafile backup set

channel a2: specifying datafile(s) in backup set

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

channel a2: starting piece 1 at 06-NOV-2012 03:10:13

channel a1: finished piece 1 at 06-NOV-2012 03:10:14

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031013_89j3rojw_.bkp tag=TAG20121106T031013 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

channel a2: finished piece 1 at 06-NOV-2012 03:10:14

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031013_89j3rokf_.bkp tag=TAG20121106T031013 comment=NONE

channel a2: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:10:14

Starting Control File and SPFILE Autobackup at 06-NOV-2012 03:10:14

piece handle=/u01/recovery/MAA/autobackup/2012_11_06/o1_mf_s_798606614_89j3rq4c_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 06-NOV-2012 03:10:15

released channel: a1

released channel: a2

设置了3个通道,产生了3个备份集

RMAN> run {

2> allocate channel a1 device type disk;

3> allocate channel a2 device type disk;

4> allocate channel a3 device type disk;

5> backup as backupset tablespace l;

6> }

allocated channel: a1

channel a1: SID=58 device type=DISK

allocated channel: a2

channel a2: SID=45 device type=DISK

allocated channel: a3

channel a3: SID=48 device type=DISK

Starting backup at 06-NOV-2012 03:12:48

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

channel a1: starting piece 1 at 06-NOV-2012 03:12:48

channel a2: starting full datafile backup set

channel a2: specifying datafile(s) in backup set

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

channel a2: starting piece 1 at 06-NOV-2012 03:12:48

channel a3: starting full datafile backup set

channel a3: specifying datafile(s) in backup set

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a3: starting piece 1 at 06-NOV-2012 03:12:49

channel a1: finished piece 1 at 06-NOV-2012 03:12:50

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031248_89j3xjyq_.bkp tag=TAG20121106T031248 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:02

channel a2: finished piece 1 at 06-NOV-2012 03:12:50

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031248_89j3xk30_.bkp tag=TAG20121106T031248 comment=NONE

channel a2: backup set complete, elapsed time: 00:00:02

channel a3: finished piece 1 at 06-NOV-2012 03:12:50

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T031248_89j3xk3t_.bkp tag=TAG20121106T031248 comment=NONE

channel a3: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:12:50

Starting Control File and SPFILE Autobackup at 06-NOV-2012 03:12:50

piece handle=/u01/recovery/MAA/autobackup/2012_11_06/o1_mf_s_798606770_89j3xlrw_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 06-NOV-2012 03:12:51

released channel: a1

released channel: a2

released channel: a3

输入文件的种类

有些文件不能同在一个备份集中,若backup命令需要一起备份这样的文件,产生的备份集会预期的多。

规则:数据文件、归档日志只能单独占用备份集,控制文件和参数文件可以合用备份集。

我们先把自动控制文件备份关闭:

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP OFF;

old RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP ON;

new RMAN configuration parameters:

CONFIGURE CONTROLFILE AUTOBACKUP OFF;

new RMAN configuration parameters are successfully stored

我们拿1号数据文件来测试,1号数据文件对应system表空间,它被备份,RMAN就会自动备份控制文件和参数文件。

RMAN> run {

2> allocate channel a1 device type disk;

3> backup as backupset datafile 1;

4> }

allocated channel: a1

channel a1: SID=58 device type=DISK

Starting backup at 06-NOV-2012 03:33:38

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

channel a1: starting piece 1 at 06-NOV-2012 03:33:38

channel a1: finished piece 1 at 06-NOV-2012 03:33:54

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T033338_89j54lyv_.bkp tag=TAG20121106T033338 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:16

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel a1: starting piece 1 at 06-NOV-2012 03:33:55

channel a1: finished piece 1 at 06-NOV-2012 03:33:56

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncsnf_TAG20121106T033338_89j553g0_.bkp tag=TAG20121106T033338 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:33:56

released channel: a1

-- 这里可以看到创建了两个备份集,这是因为数据文件和控制文件不兼容所致。

那么非1号文件能不能自动备份控制文件?经过测试验证不会,下面是2号sysaux表空间对应的数据文件备份例子:

RMAN> run {

2> allocate channel a1 device type disk;

3> backup as backupset datafile 2;

4> }

allocated channel: a1

channel a1: SID=58 device type=DISK

Starting backup at 06-NOV-2012 03:35:42

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

channel a1: starting piece 1 at 06-NOV-2012 03:35:42

channel a1: finished piece 1 at 06-NOV-2012 03:35:57

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T033542_89j58gdk_.bkp tag=TAG20121106T033542 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:15

Finished backup at 06-NOV-2012 03:35:57

released channel: a1

-- 可见只有一个备份集。

小括号的使用

小括号起到隔离的作用,不在同一个小括号内的输入文件一定不在同一个备份集中,在同一个小括号内的输入文件不一定在同一个备份集中。

下面两个使用了两个括号,生成了两个备份集,验证了第一句:不在同一个小括号内的输入文件一定不在同一个备份集中

RMAN> run {

2> allocate channel a1 device type disk;

3> backup as backupset

4> (datafile 5) (datafile 6,7);

5> }

allocated channel: a1

channel a1: SID=58 device type=DISK

Starting backup at 06-NOV-2012 03:40:11

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a1: starting piece 1 at 06-NOV-2012 03:40:11

channel a1: finished piece 1 at 06-NOV-2012 03:40:12

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034011_89j5jvfz_.bkp tag=TAG20121106T034011 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

channel a1: starting piece 1 at 06-NOV-2012 03:40:12

channel a1: finished piece 1 at 06-NOV-2012 03:40:13

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034011_89j5jwlm_.bkp tag=TAG20121106T034011 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:40:13

released channel: a1

下面这个示例也是用了两个小括号,结果产生了3个备份集,第二个小括号内输入文件有两个,结果产生了两个备份集,这就验证了第二句:在同一个小括号内的输入文件不一定在同一个备份集中

RMAN> run {

2> allocate channel a1 device type disk;

3> backup as backupset

4> (datafile 5) (datafile 1,7);

5> }

allocated channel: a1

channel a1: SID=58 device type=DISK

Starting backup at 06-NOV-2012 03:41:40

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a1: starting piece 1 at 06-NOV-2012 03:41:40

channel a1: finished piece 1 at 06-NOV-2012 03:41:55

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034140_89j5mngj_.bkp tag=TAG20121106T034140 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:15

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

channel a1: starting piece 1 at 06-NOV-2012 03:41:55

channel a1: finished piece 1 at 06-NOV-2012 03:41:56

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034140_89j5n403_.bkp tag=TAG20121106T034140 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel a1: starting piece 1 at 06-NOV-2012 03:41:58

channel a1: finished piece 1 at 06-NOV-2012 03:41:59

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncsnf_TAG20121106T034140_89j5n653_.bkp tag=TAG20121106T034140 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:41:59

released channel: a1

下面情况和上一种有点区别,我们依然使用了两个小括号,但却配置了3个通道,也说明并行度达到了3,于是依从并行度规则,生成3个备份集

RMAN> run {

2> allocate channel a1 device type disk;

3> allocate channel a2 device type disk;

4> allocate channel a3 device type disk;

5> backup as backupset

6> (datafile 5,6) (datafile 7);

7> }

allocated channel: a1

channel a1: SID=58 device type=DISK

allocated channel: a2

channel a2: SID=45 device type=DISK

allocated channel: a3

channel a3: SID=48 device type=DISK

Starting backup at 06-NOV-2012 03:45:11

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

channel a1: starting piece 1 at 06-NOV-2012 03:45:11

channel a2: starting full datafile backup set

channel a2: specifying datafile(s) in backup set

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

channel a2: starting piece 1 at 06-NOV-2012 03:45:12

channel a3: starting full datafile backup set

channel a3: specifying datafile(s) in backup set

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a3: starting piece 1 at 06-NOV-2012 03:45:12

channel a1: finished piece 1 at 06-NOV-2012 03:45:13

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034511_89j5t81k_.bkp tag=TAG20121106T034511 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:02

channel a2: finished piece 1 at 06-NOV-2012 03:45:13

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034511_89j5t84p_.bkp tag=TAG20121106T034511 comment=NONE

channel a2: backup set complete, elapsed time: 00:00:01

channel a3: finished piece 1 at 06-NOV-2012 03:45:13

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034511_89j5t85m_.bkp tag=TAG20121106T034511 comment=NONE

channel a3: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:45:13

released channel: a1

released channel: a2

released channel: a3

下面示例设置了3个通道,但却在小括号内显式指派了通道,也说明并行度只有2,产生了2个备份集。

RMAN> run {

2> allocate channel a1 device type disk;

3> allocate channel a2 device type disk;

4> allocate channel a3 device type disk;

5> backup as backupset

6> (datafile 5,6 channel a1) (datafile 7 channel a2);

7> }

allocated channel: a1

channel a1: SID=58 device type=DISK

allocated channel: a2

channel a2: SID=45 device type=DISK

allocated channel: a3

channel a3: SID=48 device type=DISK

Starting backup at 06-NOV-2012 03:47:45

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

channel a1: starting piece 1 at 06-NOV-2012 03:47:45

channel a2: starting full datafile backup set

channel a2: specifying datafile(s) in backup set

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a2: starting piece 1 at 06-NOV-2012 03:47:45

channel a1: finished piece 1 at 06-NOV-2012 03:47:46

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034745_89j5z1q9_.bkp tag=TAG20121106T034745 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

channel a2: finished piece 1 at 06-NOV-2012 03:47:46

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T034745_89j5z1so_.bkp tag=TAG20121106T034745 comment=NONE

channel a2: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:47:46

released channel: a1

released channel: a2

released channel: a3

"plus archivelog"子句

如果是备份时使用了"plus archivelog"子句,RMAN会做一个"归档收尾",即切换当前在线日志 — 归档该日志 — 备份刚刚产生的归档日志。

所以会出现一个额外的只有一个归档日志的备份集。

RMAN> run {

2> allocate channel a1 device type disk;

3> allocate channel a2 device type disk;

4> backup database plus archivelog;

5> }

allocated channel: a1

channel a1: SID=58 device type=DISK

allocated channel: a2

channel a2: SID=45 device type=DISK

Starting backup at 06-NOV-2012 03:54:55

current log archived

channel a1: starting archived log backup set

channel a1: specifying archived log(s) in backup set

input archived log thread=1 sequence=40 RECID=1 STAMP=798598856

channel a1: starting piece 1 at 06-NOV-2012 03:54:56

channel a2: starting archived log backup set

channel a2: specifying archived log(s) in backup set

input archived log thread=1 sequence=41 RECID=2 STAMP=798609295

channel a2: starting piece 1 at 06-NOV-2012 03:54:56

channel a1: finished piece 1 at 06-NOV-2012 03:54:57

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_annnn_TAG20121106T035455_89j6dj3d_.bkp tag=TAG20121106T035455 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

channel a2: finished piece 1 at 06-NOV-2012 03:54:57

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_annnn_TAG20121106T035455_89j6dj6o_.bkp tag=TAG20121106T035455 comment=NONE

channel a2: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:54:57

Starting backup at 06-NOV-2012 03:54:57

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

channel a1: starting piece 1 at 06-NOV-2012 03:54:57

channel a2: starting full datafile backup set

channel a2: specifying datafile(s) in backup set

input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel a2: starting piece 1 at 06-NOV-2012 03:54:58

channel a1: finished piece 1 at 06-NOV-2012 03:55:23

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T035457_89j6dkvy_.bkp tag=TAG20121106T035457 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:26

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

channel a2: finished piece 1 at 06-NOV-2012 03:55:23

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T035457_89j6dlhj_.bkp tag=TAG20121106T035457 comment=NONE

channel a2: backup set complete, elapsed time: 00:00:25

channel a2: starting full datafile backup set

channel a2: specifying datafile(s) in backup set

including current SPFILE in backup set

channel a2: starting piece 1 at 06-NOV-2012 03:55:23

including current control file in backup set

channel a1: starting piece 1 at 06-NOV-2012 03:55:24

channel a2: finished piece 1 at 06-NOV-2012 03:55:24

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsnf_TAG20121106T035457_89j6fcv2_.bkp tag=TAG20121106T035457 comment=NONE

channel a2: backup set complete, elapsed time: 00:00:01

channel a1: finished piece 1 at 06-NOV-2012 03:55:25

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnnf_TAG20121106T035457_89j6fdtd_.bkp tag=TAG20121106T035457 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:55:25

Starting backup at 06-NOV-2012 03:55:25

current log archived

channel a1: starting archived log backup set

channel a1: specifying archived log(s) in backup set

input archived log thread=1 sequence=42 RECID=3 STAMP=798609326

channel a1: starting piece 1 at 06-NOV-2012 03:55:26

channel a1: finished piece 1 at 06-NOV-2012 03:55:27

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_annnn_TAG20121106T035526_89j6fgjc_.bkp tag=TAG20121106T035526 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 03:55:27

released channel: a1

released channel: a2

-- 这里一共产生了7个备份集,归档文件通过我配置两个通道生成两个备份集,数据文件通过两个通道生成了两个备份集,控制文件和参数文件各产生一个备份集,最后"plus archivelog"子句再生成了一个备份集。

-- 这些备份集也从产生的备份片中就可以知道。

多路传输

在备份时,一个通道中,RMAN同时读取多个输入文件的数据并将其写入同一个备份片的操作称为多路传输。

读取的输入文件的数量称为多路传输等级(Multiplexing Level),该等级等于以下3个数中的最小值:

1)通道的maxopenfiles;

2)通道的输入文件数;

3)64或backup命令的filesperset。

分析下面的示例:

RMAN> run {

2> allocate channel a1 device type disk maxopenfiles 2;

3> backup database;

4> }

allocated channel: a1

channel a1: SID=58 device type=DISK

Starting backup at 06-NOV-2012 04:41:40

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

input datafile file number=00001 name=+MSDATA/maa/datafile/system.260.792009857

input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

channel a1: starting piece 1 at 06-NOV-2012 04:41:41

channel a1: finished piece 1 at 06-NOV-2012 04:42:06

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnndf_TAG20121106T044140_89j9454l_.bkp tag=TAG20121106T044140 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:25

channel a1: starting full datafile backup set

channel a1: specifying datafile(s) in backup set

including current control file in backup set

including current SPFILE in backup set

channel a1: starting piece 1 at 06-NOV-2012 04:42:07

channel a1: finished piece 1 at 06-NOV-2012 04:42:08

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncsnf_TAG20121106T044140_89j94zfc_.bkp tag=TAG20121106T044140 comment=NONE

channel a1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 04:42:08

released channel: a1

– 其中maxopenfiles设置了2,filesperset没有设置,所以取64,通道输入的文件数是7,其中取最小值就是2,也就是多路传输等级为2.

RMAN每次只读两个数据文件,分三批写入备份片o1_mf_nnndf_TAG20121106T044140_89j9454l_.bkp,另外控制文件盒参数文件同时写入到

o1_mf_ncsnf_TAG20121106T044140_89j94zfc_.bkp备份片里面。

多路传输等级会影响通道在读阶段分配的输入缓冲的大小:

1)当等级小于或等于4时,输入缓冲由16个1MB的缓冲组成;

2)当等级大于4且小于或等于8时,输入缓冲由多个512KB的缓冲组成,但总大小小于16MB;

3)当等级大于8时,每个输入文件将分配4个128KB的缓冲,即总大小等于512KB与等级的积。

在备份时,RMAN给DISK通道的输出缓冲分配4个1MB总大小为4MB的缓冲。在还原时输出缓冲变成输入缓冲数量和大小不变。

在还原时,也就是执行restore命令时,RMAN会从备份片中提取出原始的输入文件。此时,每个通道的输入缓冲和输出缓冲同为4个1MB总大小为4MB的缓冲。

数据文件增量备份

增量备份只"关心"在前一次备份之后发生变化的数据块,其优点在于产生备份片较小及使用它们恢复的速度比使用归档日志快。

backup命令的incremental子句可以生成3种增量备份集:

1)等级0增量备份。这是增量备份的基准备份,其备份的量与全备份一样多,所以并不是真正的增量备份,但是作为真正的增量备份之前必须要存在的备份。

RMAN> backup incremental level 0 database;

Starting backup at 06-NOV-2012 11:15:37

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=45 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=34 device type=DISK

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=+MSDATA/maa/datafile/system.260.792009857

input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:15:39

channel ORA_DISK_2: starting incremental level 0 datafile backup set

channel ORA_DISK_2: specifying datafile(s) in backup set

input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:15:39

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:16:05

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd0_TAG20121106T111538_89k06vfh_.bkp tag=TAG20121106T111538 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26

channel ORA_DISK_1: starting incremental level 0 datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:16:05

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd0_TAG20121106T111538_89k06w01_.bkp tag=TAG20121106T111538 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:00:26

channel ORA_DISK_2: starting incremental level 0 datafile backup set

channel ORA_DISK_2: specifying datafile(s) in backup set

including current SPFILE in backup set

channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:16:05

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:16:06

channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:16:06

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsn0_TAG20121106T111538_89k07ovd_.bkp tag=TAG20121106T111538 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:16:07

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnn0_TAG20121106T111538_89k07pr5_.bkp tag=TAG20121106T111538 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 11:16:07

2)等级1累计增量备份。这种增量备份只与等级0增量备份比较。若当前数据文件中的数据块与前次等级0增量备份中的不同,则加以备份,否则既跳过此数据块。这种备份虽然产生的备份片不是最小,但回复的速度快。

SQL> grant dba to luocs identified by oracle;

Grant succeeded.

SQL> create table luocs.t1 as select * from dba_objects;

Table created.

RMAN> backup cumulative incremental level 1 database;

Starting backup at 06-NOV-2012 11:34:54

using channel ORA_DISK_1

using channel ORA_DISK_2

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=+MSDATA/maa/datafile/system.260.792009857

input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:34:55

channel ORA_DISK_2: starting incremental level 1 datafile backup set

channel ORA_DISK_2: specifying datafile(s) in backup set

input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:34:56

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:35:21

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd1_TAG20121106T113455_89k1c08z_.bkp tag=TAG20121106T113455 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26

channel ORA_DISK_1: starting incremental level 1 datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:35:21

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd1_TAG20121106T113455_89k1c4p7_.bkp tag=TAG20121106T113455 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:00:25

channel ORA_DISK_2: starting incremental level 1 datafile backup set

channel ORA_DISK_2: specifying datafile(s) in backup set

including current SPFILE in backup set

channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:35:21

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:35:22

channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:35:22

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsn1_TAG20121106T113455_89k1csxv_.bkp tag=TAG20121106T113455 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:35:23

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnn1_TAG20121106T113455_89k1cttp_.bkp tag=TAG20121106T113455 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 11:35:23

如果在执行上述命令的时候尚未创建等级0增量备份,则RMAN会自动将等级降为0。

3)等级1差异增量备份。这种增量备份可以与等级0连同等级1(不论是累计还是差异的)增量备份比较。这种备份产生的备份片相对来说最小。

RMAN> backup incremental level 1 database;

Starting backup at 06-NOV-2012 11:39:58

using channel ORA_DISK_1

using channel ORA_DISK_2

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=+MSDATA/maa/datafile/system.260.792009857

input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

input datafile file number=00003 name=+MSDATA/maa/datafile/undotbs1.262.792009883

channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:39:59

channel ORA_DISK_2: starting incremental level 1 datafile backup set

channel ORA_DISK_2: specifying datafile(s) in backup set

input datafile file number=00002 name=+MSDATA/maa/datafile/sysaux.261.792009871

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:39:59

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:40:25

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd1_TAG20121106T113958_89k1nhcc_.bkp tag=TAG20121106T113958 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:26

channel ORA_DISK_1: starting incremental level 1 datafile backup set

channel ORA_DISK_1: specifying datafile(s) in backup set

channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:40:25

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnnd1_TAG20121106T113958_89k1np4p_.bkp tag=TAG20121106T113958 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:00:26

channel ORA_DISK_2: starting incremental level 1 datafile backup set

channel ORA_DISK_2: specifying datafile(s) in backup set

including current SPFILE in backup set

channel ORA_DISK_2: starting piece 1 at 06-NOV-2012 11:40:25

including current control file in backup set

channel ORA_DISK_1: starting piece 1 at 06-NOV-2012 11:40:26

channel ORA_DISK_2: finished piece 1 at 06-NOV-2012 11:40:26

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsn1_TAG20121106T113958_89k1o9k2_.bkp tag=TAG20121106T113958 comment=NONE

channel ORA_DISK_2: backup set complete, elapsed time: 00:00:01

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 11:40:27

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_ncnn1_TAG20121106T113958_89k1obj0_.bkp tag=TAG20121106T113958 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 11:40:27

将来介质恢复时,执行recover命令会自动使用它们。

镜像复制备份

镜像复制备份是一种极为简单的备份方式,类似于直接使用操作系统的复制命令,备份文件就是输入文件的一份副本,与镜像复制相比,备份集备份好比一个压缩包。

镜像复制的数量和大小均与输入文件一模一样,这样做的缺点是空间的使用无法优化;优点是可大大缩减还原操作的时间,那就是用重命名代替restore还原命令。比如将来哪个数据文件损坏了就将其在控制文件中的路径修改成镜像复制的路径,还原操作即可完成,此操作需要时间极短,与文件的大小无关。

创建镜像复制备份,需要使用as copy子句,或者通过"configure device type"命令修改通道的默认属性,使backup命令默认使用镜像复制作为备份类型。

L表空间有三个数据文件,从备份输出可以看出三个数据文件各自产生3个镜像,都存放到了闪回恢复区。

RMAN> backup as copy tablespace l;

Starting backup at 06-NOV-2012 11:53:37

using channel ORA_DISK_1

using channel ORA_DISK_2

channel ORA_DISK_1: starting datafile copy

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

channel ORA_DISK_2: starting datafile copy

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2g1md_.dbf tag=TAG20121106T115337 RECID=1 STAMP=798638018

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting datafile copy

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2g1mj_.dbf tag=TAG20121106T115337 RECID=2 STAMP=798638018

channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:01

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2g2qk_.dbf tag=TAG20121106T115337 RECID=3 STAMP=798638018

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 11:53:39

RMAN> configure device type disk backup type to copy;

old RMAN configuration parameters:

CONFIGURE DEVICE TYPE DISK PARALLELISM 2 BACKUP TYPE TO BACKUPSET;

new RMAN configuration parameters:

CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COPY PARALLELISM 2;

Configure device type配置之后不加as copy子句也进行了镜像备份:

RMAN> backup tablespace l;

Starting backup at 06-NOV-2012 11:55:42

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=45 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=34 device type=DISK

channel ORA_DISK_1: starting datafile copy

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

channel ORA_DISK_2: starting datafile copy

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2kz89_.dbf tag=TAG20121106T115542 RECID=4 STAMP=798638143

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

channel ORA_DISK_1: starting datafile copy

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2kzfz_.dbf tag=TAG20121106T115542 RECID=5 STAMP=798638143

channel ORA_DISK_2: datafile copy complete, elapsed time: 00:00:01

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2l0gg_.dbf tag=TAG20121106T115542 RECID=6 STAMP=798638144

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 11:55:45

注意,镜像复制备份是不可以使用SBT设备的。鉴于只有当镜像复制在磁盘上时才能有效地缩短还原地时间,所以Oracle认为此类备份存放在SBT设备上没有意义。

RMAN> run {

2> allocate channel a1 device type sbt

3> parms 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=/u01/sbt1)';

4> backup as copy tablespace l;

5> }

released channel: ORA_DISK_1

released channel: ORA_DISK_2

allocated channel: a1

channel a1: SID=45 device type=SBT_TAPE

channel a1: WARNING: Oracle Test Disk API

Starting backup at 06-NOV-2012 11:59:15

released channel: a1

RMAN-00571: ===========================================================

RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============

RMAN-00571: ===========================================================

RMAN-03002: failure of backup command at 11/06/2012 11:59:15

RMAN-06583: at least 1 channel of TYPE DISK must be allocated to use AS COPY option

-- 注意最后一句:RMAN-06583: at least 1 channel of TYPE DISK must be allocated to use AS COPY option

下面示例是使用一个通道备份4到7号数据文件,镜像备份在闪回恢复区里

RMAN> run{

2> allocate channel a1 device type disk;

3> backup as copy datafile 4,5,6,7;

4> }

allocated channel: a1

channel a1: SID=45 device type=DISK

Starting backup at 06-NOV-2012 12:01:47

channel a1: starting datafile copy

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2xcx7_.dbf tag=TAG20121106T120147 RECID=7 STAMP=798638508

channel a1: datafile copy complete, elapsed time: 00:00:01

channel a1: starting datafile copy

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2xf4h_.dbf tag=TAG20121106T120147 RECID=8 STAMP=798638509

channel a1: datafile copy complete, elapsed time: 00:00:01

channel a1: starting datafile copy

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

output file name=/u01/recovery/MAA/datafile/o1_mf_l_89k2xg9f_.dbf tag=TAG20121106T120147 RECID=9 STAMP=798638510

channel a1: datafile copy complete, elapsed time: 00:00:01

channel a1: starting datafile copy

input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

output file name=/u01/recovery/MAA/datafile/o1_mf_users_89k2xhgn_.dbf tag=TAG20121106T120147 RECID=10 STAMP=798638511

channel a1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 12:01:52

released channel: a1

下面示例是使用两个通道备份4~7号数据文件,指定了非闪回恢复区作为目的地

RMAN> run {

2> allocate channel a1 device type disk to destination '/u01/bak/disk1';

3> allocate channel a2 device type disk to destination '/u01/bak/disk2';

4> backup as copy (datafile 4) (datafile 5,6,7);

5> }

allocated channel: a1

channel a1: SID=45 device type=DISK

allocated channel: a2

channel a2: SID=34 device type=DISK

Starting backup at 06-NOV-2012 12:04:23

channel a1: starting datafile copy

input datafile file number=00005 name=+MSDATA/maa/datafile/l.266.798569345

channel a2: starting datafile copy

input datafile file number=00006 name=+MSDATA/maa/datafile/l.267.798570165

output file name=/u01/bak/disk1/MAA/datafile/o1_mf_l_89k3286j_.dbf tag=TAG20121106T120423 RECID=11 STAMP=798638664

channel a1: datafile copy complete, elapsed time: 00:00:01

channel a1: starting datafile copy

input datafile file number=00007 name=+MSDATA/maa/datafile/l.268.798572257

output file name=/u01/bak/disk2/MAA/datafile/o1_mf_l_89k328dv_.dbf tag=TAG20121106T120423 RECID=12 STAMP=798638664

channel a2: datafile copy complete, elapsed time: 00:00:01

channel a2: starting datafile copy

input datafile file number=00004 name=+MSDATA/maa/datafile/users.264.792009897

output file name=/u01/bak/disk1/MAA/datafile/o1_mf_l_89k329fj_.dbf tag=TAG20121106T120423 RECID=13 STAMP=798638665

channel a1: datafile copy complete, elapsed time: 00:00:01

output file name=/u01/bak/disk2/MAA/datafile/o1_mf_users_89k329lg_.dbf tag=TAG20121106T120423 RECID=14 STAMP=798638665

channel a2: datafile copy complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 12:04:26

released channel: a1

released channel: a2

-- 从输出信息中可以看出,尽管我们用小括号绑了5,6,7号三个数据文件,但它们加上4号备份文件平均使用两个通道备份。

创建控制文件的镜像复制

RMAN> backup as copy current controlfile;

Starting backup at 06-NOV-2012 12:14:23

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=45 device type=DISK

allocated channel: ORA_DISK_2

channel ORA_DISK_2: SID=34 device type=DISK

channel ORA_DISK_1: starting datafile copy

copying current control file

output file name=/u01/recovery/MAA/controlfile/o1_mf_TAG20121106T121424_89k3o09m_.ctl tag=TAG20121106T121424 RECID=15 STAMP=798639264

channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 12:14:25

将所有归档日志复制一份到闪回恢复区

RMAN> backup as copy archivelog all;

Starting backup at 06-NOV-2012 12:15:09

current log archived

using channel ORA_DISK_1

using channel ORA_DISK_2

channel ORA_DISK_1: starting archived log copy

input archived log thread=1 sequence=40 RECID=1 STAMP=798598856

channel ORA_DISK_2: starting archived log copy

input archived log thread=1 sequence=41 RECID=2 STAMP=798609295

output file name=/u01/recovery/MAA/archivelog/2012_11_06/o1_mf_1_41_89k3pgbq_.arc RECID=5 STAMP=798639310

channel ORA_DISK_2: archived log copy complete, elapsed time: 00:00:01

channel ORA_DISK_2: starting archived log copy

input archived log thread=1 sequence=42 RECID=3 STAMP=798609326

output file name=/u01/recovery/MAA/archivelog/2012_11_06/o1_mf_1_40_89k3pg9o_.arc RECID=6 STAMP=798639312

channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:02

channel ORA_DISK_1: starting archived log copy

input archived log thread=1 sequence=43 RECID=4 STAMP=798639309

output file name=/u01/recovery/MAA/archivelog/2012_11_06/o1_mf_1_42_89k3phrs_.arc RECID=7 STAMP=798639312

channel ORA_DISK_2: archived log copy complete, elapsed time: 00:00:01

output file name=/u01/recovery/MAA/archivelog/2012_11_06/o1_mf_1_43_89k3pjwh_.arc RECID=8 STAMP=798639313

channel ORA_DISK_1: archived log copy complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 12:15:13

这里有个特殊的,参数文件尽管我们通过as copy做个镜像复制备份,但却依然产生了备份集,这表示RMAN不会对参数文件支持镜像复制备份

RMAN> backup as copy spfile;

Starting backup at 06-NOV-2012 12:16:03

using channel ORA_DISK_1

using channel ORA_DISK_2

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 06-NOV-2012 12:16:03

channel ORA_DISK_1: finished piece 1 at 06-NOV-2012 12:16:04

piece handle=/u01/recovery/MAA/backupset/2012_11_06/o1_mf_nnsnf_TAG20121106T121603_89k3r3m5_.bkp tag=TAG20121106T121603 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01

Finished backup at 06-NOV-2012 12:16:04

表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 数字20 设计师:CSDN官方博客 返回首页