Oracle 11g RMAN 备份异机恢复并创建新DBID


实验环境

Oracle Version:11gR2                    SystemIBM AIX 5L

Target Database:orcl                     Auxiliary Database:orcl

NOTE

(1)RMAN 异机恢复的时候,db_name必须相同。如果说要想改成其他的实例名,可以在恢复成功后,用nid 命令修改。实例名的信息会记录到控制文件里,所以如果在恢复的时候,如果实例名不一致,恢复的时候会报错。                               

(2)如果恢复的路径和源库不一致,就需要在restore时用set 命令指定新位置。并且使用switch datafile all将信息更新到控制文件

在做duplicate的时候RMAN 会自动根据pfile中的log_file_name_convert和db_file_name_convert来进行set 的转换。手工restore时,只能使用set 命令转换

(3)异机恢复对相同目录和不同目录都做了说明。

(4)最后测试了NID 修改DBID 和DBNAME.

 

实验步骤:

一. Target库准备工作:

1. 查询DBID

$ sqlplus /nolog

SQL*Plus: Release 11.2.0.1.0 Production on Mon Apr 11 19:56:08 2011

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

idle> conn /as sysdba

Connected.

sys@ORCL> select name,dbid from v$database;

NAME                                                     DBID

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

ORCL                                               1275959622

2. 备份Target Database

rman target sys/oracle@orcl

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Apr 11 19:59:34 2011

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

connected to target database: ORCL (DBID=1275959622)

准备一个0级和1级备份:

RMAN> RUN {

2> allocate channel c1 type disk;

3> allocate channel c2 type disk;

4> backup incremental level=0 skip inaccessible filesperset 5 database format='/u02/backup/orcl_lev0_%U_%T' tag='orcl_lev0';

5> sql 'alter system archive log current';

6> backup archivelog all tag='arc_bak' format='/u02/backup/arch_%U_%T' skip inaccessible filesperset 5 not backed up 1 times delete input;

7> backup current controlfile tag='bak_ctlfile' format='/u02/backup/ctl_file_%U_%T';

8> backup spfile tag='spfile' format='/u02/backup/ORCL_spfile_%U_%T';

9> release channel c2;

10> release channel c1;

11> }

allocated channel: c1

channel c1: SID=198 device type=DISK

allocated channel: c2

channel c2: SID=10 device type=DISK

Starting backup at 11-APR-11

channel c1: starting incremental level 0 datafile backup set

channel c1: specifying datafile(s) in backup set

input datafile file number=00002 name=/u01/app/oracle/oradata/orcl/sysaux01.dbf

input datafile file number=00005 name=/u01/app/oracle/oradata/orcl/example01.dbf

input datafile file number=00003 name=/u01/app/oracle/oradata/orcl/undotbs01.dbf

channel c1: starting piece 1 at 11-APR-11

channel c2: starting incremental level 0 datafile backup set

channel c2: specifying datafile(s) in backup set

input datafile file number=00001 name=/u01/app/oracle/oradata/orcl/system01.dbf

input datafile file number=00004 name=/u01/app/oracle/oradata/orcl/users01.dbf

channel c2: starting piece 1 at 11-APR-11

channel c1: finished piece 1 at 11-APR-11

piece handle=/u02/backup/orcl_lev0_0km9hi1b_1_1_20110411 tag=ORCL_LEV0 comment=NONE

channel c1: backup set complete, elapsed time: 00:00:03

channel c2: finished piece 1 at 11-APR-11

piece handle=/u02/backup/orcl_lev0_0lm9hi1b_1_1_20110411 tag=ORCL_LEV0 comment=NONE

channel c2: backup set complete, elapsed time: 00:00:03

Finished backup at 11-APR-11

Starting Control File and SPFILE Autobackup at 11-APR-11

piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748210222_6t79my7k_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 11-APR-11

sql statement: alter system archive log current

Starting backup at 11-APR-11

current log archived

channel c1: starting archived log backup set

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

input archived log thread=1 sequence=11 RECID=6 STAMP=748188047

channel c1: starting piece 1 at 11-APR-11

channel c2: starting archived log backup set

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

input archived log thread=1 sequence=12 RECID=7 STAMP=748210223

input archived log thread=1 sequence=13 RECID=8 STAMP=748210223

channel c2: starting piece 1 at 11-APR-11

channel c1: finished piece 1 at 11-APR-11

piece handle=/u02/backup/arch_0nm9hi1f_1_1_20110411 tag=ARC_BAK comment=NONE

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

channel c1: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_11_6t6myz6m_.arc RECID=6 STAMP=748188047

channel c2: finished piece 1 at 11-APR-11

piece handle=/u02/backup/arch_0om9hi1f_1_1_20110411 tag=ARC_BAK comment=NONE

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

channel c2: deleting archived log(s)

archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_12_6t79mzb6_.arc RECID=7 STAMP=748210223

archived log file name=/u01/app/oracle/flash_recovery_area/ORCL/archivelog/2011_04_11/o1_mf_1_13_6t79mzg7_.arc RECID=8 STAMP=748210223

Finished backup at 11-APR-11

Starting backup at 11-APR-11

channel c1: starting full datafile backup set

channel c1: specifying datafile(s) in backup set

including current control file in backup set

channel c1: starting piece 1 at 11-APR-11

channel c1: finished piece 1 at 11-APR-11

piece handle=/u02/backup/ctl_file_0pm9hi1h_1_1_20110411 tag=BAK_CTLFILE comment=NONE

channel c1: backup set complete, elapsed time: 00:00:03

Finished backup at 11-APR-11

Starting backup at 11-APR-11

channel c1: starting full datafile backup set

channel c1: specifying datafile(s) in backup set

including current SPFILE in backup set

channel c1: starting piece 1 at 11-APR-11

channel c1: finished piece 1 at 11-APR-11

piece handle=/u02/backup/ORCL_spfile_0qm9hi1l_1_1_20110411 tag=SPFILE comment=NONE

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

Finished backup at 11-APR-11

Starting Control File and SPFILE Autobackup at 11-APR-11

piece handle=/u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748210230_6t79n67d_.bkp comment=NONE

Finished Control File and SPFILE Autobackup at 11-APR-11

released channel: c2

released channel: c1

RMAN> list backup;

List of Backup Sets

===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

13      Incr 0  444.11M    DISK        00:00:02     11-APR-11      

        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: ORCL_LEV0

        Piece Name: /u02/backup/orcl_lev0_0km9hi1b_1_1_20110411

  List of Datafiles in backup set 13

  File LV Type Ckp SCN    Ckp Time  Name

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

  2    0  Incr 1108663    11-APR-11 /u01/app/oracle/oradata/orcl/sysaux01.dbf

  3    0  Incr 1108663    11-APR-11 /u01/app/oracle/oradata/orcl/undotbs01.dbf

  5    0  Incr 1108663    11-APR-11 /u01/app/oracle/oradata/orcl/example01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

14      Incr 0  595.57M    DISK        00:00:02     11-APR-11      

        BP Key: 14   Status: AVAILABLE  Compressed: NO  Tag: ORCL_LEV0

        Piece Name: /u02/backup/orcl_lev0_0lm9hi1b_1_1_20110411

  List of Datafiles in backup set 14

  File LV Type Ckp SCN    Ckp Time  Name

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

  1    0  Incr 1108664    11-APR-11 /u01/app/oracle/oradata/orcl/system01.dbf

  4    0  Incr 1108664    11-APR-11 /u01/app/oracle/oradata/orcl/users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

15      Full    7.42M      DISK        00:00:00     11-APR-11      

        BP Key: 15   Status: AVAILABLE  Compressed: NO  Tag: TAG20110411T201022

        Piece Name: /u01/app/oracle/flash_recovery_area/ORCL/autobackup/2011_04_11/o1_mf_s_748210222_6t79my7k_.bkp

  SPFILE Included: Modification time: 10-APR-11

  SPFILE db_unique_name: ORCL

  Control File Included: Ckp SCN: 1108671      Ckp time: 11-APR-11

BS Key  Size       Device Type Elapsed Time Completion Time

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

16      7.23M      DISK        00:00:00     11-APR-11      

        BP Key: 16   Status: AVAILABLE  Compressed: NO  Tag: ARC_BAK

        Piece Name: /u02/backup/arch_0om9hi1f_1_1_20110411

  List of Archived Logs in backup set 16

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

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

  1    12      1098341    11-APR-11 1108687    11-APR-11

  1    13      1108687    11-APR-11 1108695    11-APR-11

BS Key  Size       Device Type Elapsed Time Completion Time

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

17      29.52M     DISK        00:00:00     11-APR-11      

        BP Key: 17   Status: AVAILABLE  Compressed: NO  Tag: ARC_BAK

        Piece Name: /u02/backup/arch_0nm9hi1f_1_1_20110411

  List of Archived Logs in backup set 17

  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time

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

  1    11      1081833    11-APR-11 1098341    11-APR-11

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

18      Full    7.39M      DISK        00:00:03     11-APR-11      

        BP Key: 18   Status: AVAILABLE  Compressed: NO  Tag: BAK_CTLFILE

        Piece Name: /u02/backup/ctl_file_0pm9hi1h_1_1_20110411

  Control File Included: Ckp SCN: 1108711      Ckp time: 11-APR-11

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

19      Full    80.00K     DISK        00:00:00     11-APR-11      

        BP Key: 19   Status: AVAILABLE  Compressed: NO  Tag: SPFILE

        Piece Name: /u02/backup/ORCL_spfile_0qm9hi1l_1_1_20110411

  SPFILE Included: Modification time: 10-APR-11

  SPFILE db_unique_name: ORCL

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 下一页

相关内容