暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

Oracle数据库工程师手记:备份恢复双城记(三)

1095

编者按:

本文作者系大连健哥, POSTGRESQL、ORACLE 数据库资深从业人员、IT 技术的深度爱好者。相信科学改变人类、技术创造未来。个人主页:https://www.cnblogs.com/gaojian/,经其本人授权发布。

【免责声明】本公众号文章仅代表个人观点,与任何公司无关。

Oracle数据库工程师手记:备份恢复双城记(一)

Oracle数据库工程师手记:备份恢复双城记(二)

在两个数据库之间进行备份恢复同步,其实还有一个变形版本:就是利用增分更新备份方式,增分更新备份本身,就是每一次都对 image copy 执行 apply,这样会节省recover 执行的时间。

比如,如果我1月1日进行 level 0 的备份,1月2日进行 level 1 的备份,1月3日进行 level 1 的备份.... 1 月 31 日进行 level 1 的备份;2月1日我想恢复到 1月31日为止的状态时,我需要进行如下的操作:

        (1) restore 1月1日的备份

        (2) recover 1月2日的备份

        (3) recover 1月3日的备份

        .....

        (31) recover 1月31日的备份。

这样,recover 的时间就会比较长。

而采用 增分更新备份,我可以在每次备份时,顺手执行 recover copy 命令,把作为基础的 level 0 备份(image copy),变成apply 了昨天备份的状态。

典型的操作是这样的

    run
    {
    RECOVER COPY OF DATABASE WITH TAG 'incr_update';
    BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE format '/refresh/home/bak/%U';
    }
    复制

    我要执行的操作是这样的:

    首先,在 source 端,进行 第一次增分备份,以及控制文件和spfile的备份。

      -bash-4.1$ rman target 

      Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 08:04:34 2021

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

      connected to target database: ORCL1120 (DBID=3640541495)

      RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE format '/refresh/home/bak/%U';

      Starting backup at 20210404_08:04:52
      using target database control file instead of recovery catalog
      allocated channel: ORA_DISK_1
      channel ORA_DISK_1: SID=45 device type=DISK
      no parent backup or copy of datafile 1 found
      no parent backup or copy of datafile 2 found
      no parent backup or copy of datafile 3 found
      no parent backup or copy of datafile 4 found
      channel ORA_DISK_1: starting datafile copy
      input datafile file number=00001 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
      output file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4 tag=INCR_UPDATE RECID=20 STAMP=1068969896
      channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
      channel ORA_DISK_1: starting datafile copy
      input datafile file number=00002 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
      output file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb tag=INCR_UPDATE RECID=21 STAMP=1068969902
      channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
      channel ORA_DISK_1: starting datafile copy
      input datafile file number=00003 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
      output file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte tag=INCR_UPDATE RECID=22 STAMP=1068969903
      channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
      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 20210404_08:05:05
      channel ORA_DISK_1: finished piece 1 at 20210404_08:05:06
      piece handle=/refresh/home/bak/0tvrebtg_1_1 tag=INCR_UPDATE comment=NONE
      channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
      channel ORA_DISK_1: starting datafile copy
      input datafile file number=00004 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf
      output file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti tag=INCR_UPDATE RECID=23 STAMP=1068969906
      channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
      Finished backup at 20210404_08:05:07

      RMAN>
      复制

      对于增分更新备份,第一次执行时,相当于生成 level 0 的增分备份,它实际上会形成 image coy 。

        RMAN> list copy;

        specification does not match any control file copy in the repository
        specification does not match any archived log in the repository
        List of Datafile Copies
        =======================

        Key File S Completion Time Ckp SCN Ckp Time
        ------- ---- - ----------------- ---------- -----------------
        20 1 A 20210404_08:04:56 1047627 20210404_08:04:52
        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4
        Tag: INCR_UPDATE

        21 2 A 20210404_08:05:02 1047631 20210404_08:04:59
        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb
        Tag: INCR_UPDATE

        22 3 A 20210404_08:05:03 1047633 20210404_08:05:02
        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte
        Tag: INCR_UPDATE

        23 4 A 20210404_08:05:06 1047635 20210404_08:05:06
        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti
        Tag: INCR_UPDATE


        RMAN> list backup;


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


        BS Key Type LV Size Device Type Elapsed Time Completion Time
        ------- ---- -- ---------- ----------- ------------ -----------------
        27 Incr 1 9.36M DISK 00:00:01 20210404_08:05:05
        BP Key: 27 Status: AVAILABLE Compressed: NO Tag: INCR_UPDATE
        Piece Name: /refresh/home/bak/0tvrebtg_1_1
        SPFILE Included: Modification time: 20210403_07:39:00
        SPFILE db_unique_name: ORCL11204
        Control File Included: Ckp SCN: 1047633 Ckp time: 20210404_08:05:02

        RMAN>
        复制

        对控制文件和spfile的备份,方法与之前一样:

          RMAN> backup current controlfile format '/refresh/home/bak/control.bks';

          Starting backup at 20210404_08:11:01
          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 control file in backup set
          channel ORA_DISK_1: starting piece 1 at 20210404_08:11:02
          channel ORA_DISK_1: finished piece 1 at 20210404_08:11:03
          piece handle=/refresh/home/bak/control.bks tag=TAG20210404T081101 comment=NONE
          channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
          Finished backup at 20210404_08:11:03

          RMAN> backup spfile format '/refresh/home/bak/spfile.bks';

          Starting backup at 20210404_08:11:11
          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 20210404_08:11:11
          channel ORA_DISK_1: finished piece 1 at 20210404_08:11:12
          piece handle=/refresh/home/bak/spfile.bks tag=TAG20210404T081111 comment=NONE
          channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
          Finished backup at 20210404_08:11:12

          RMAN>
          复制

          第一次备份完成,我把这些备份内容拷贝到 dest 端,然后执行 restore 操作。

            -bash-4.1$ scp refresh/home/bak/* <anotherhost>:/refresh/home/bak/




            -bash-4.1$ rman target

            Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 08:14:26 2021

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

            connected to target database (not started)

            RMAN> startup nomount force;

            startup failed: ORA-01078: failure in processing system parameters
            LRM-00109: could not open parameter file '/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/initorcl11204.ora'

            starting Oracle instance without parameter file for retrieval of spfile
            Oracle instance started

            Total System Global Area 1068937216 bytes

            Fixed Size 2260088 bytes
            Variable Size 281019272 bytes
            Database Buffers 780140544 bytes
            Redo Buffers 5517312 bytes

            RMAN> restore spfile from '/refresh/home/bak/spfile.bks';

            Starting restore at 04-APR-21
            using target database control file instead of recovery catalog
            allocated channel: ORA_DISK_1
            channel ORA_DISK_1: SID=19 device type=DISK

            channel ORA_DISK_1: restoring spfile from AUTOBACKUP refresh/home/bak/spfile.bks
            channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
            Finished restore at 04-APR-21

            RMAN> restore spfile to pfile '/tmp/initnewdb.ora' from '/refresh/home/bak/spfile.bks';

            Starting restore at 04-APR-21
            using channel ORA_DISK_1

            channel ORA_DISK_1: restoring spfile from AUTOBACKUP refresh/home/bak/spfile.bks
            channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
            Finished restore at 04-APR-21

            RMAN> exit
            复制

            查看生成的 tmp/initnewdb.ora ,看看其中内容中有关于各个目录的,如果 dest 端没有这些目录,那么要建立好。特别是 audit 相关目录:

              -bash-4.1$ grep audit tmp/initnewdb.ora
              *.audit_file_dest='/refresh/home/app/11.2.0.4/oracle/admin/orcl11204/adump'
              *.audit_trail='db'
              -bash-4.1$
              复制

              如果各目录已经建立好了,那么就可以设置mount 状态:

                -bash-4.1$ rman target 

                Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 02:42:50 2021

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

                connected to target database: DUMMY (not mounted)

                RMAN> shutdown immediate

                using target database control file instead of recovery catalog
                Oracle instance shut down

                RMAN> startup nomount;

                connected to target database (not started)
                Oracle instance started

                Total System Global Area 1570009088 bytes

                Fixed Size 2253584 bytes
                Variable Size 452988144 bytes
                Database Buffers 1107296256 bytes
                Redo Buffers 7471104 bytes

                RMAN> restore controlfile from '/refresh/home/bak/control.bks';

                Starting restore at 04-APR-21
                allocated channel: ORA_DISK_1
                channel ORA_DISK_1: SID=19 device type=DISK

                channel ORA_DISK_1: restoring control file
                channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
                output file name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/control01.ctl
                output file name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/control02.ctl
                Finished restore at 04-APR-21

                RMAN> alter database mount;

                database mounted
                released channel: ORA_DISK_1

                RMAN>
                复制

                这里,我们不进行数据库本身的 restore/ recover, 而是进行 level 0 的增量备份(image copy) 的 appy:

                我在 source 端得到到第一次增分更新备份所得的,是 image copy:

                  RMAN> list copy;

                  specification does not match any control file copy in the repository
                  specification does not match any archived log in the repository
                  List of Datafile Copies
                  =======================

                  Key File S Completion Time Ckp SCN Ckp Time
                  ------- ---- - --------------- ---------- ---------------
                  20 1 A 04-APR-21 1047627 04-APR-21
                  Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4
                  Tag: INCR_UPDATE

                  21 2 A 04-APR-21 1047631 04-APR-21
                  Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb
                  Tag: INCR_UPDATE

                  22 3 A 04-APR-21 1047633 04-APR-21
                  Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte
                  Tag: INCR_UPDATE

                  23 4 A 04-APR-21 1047635 04-APR-21
                  Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti
                  Tag: INCR_UPDATE
                  复制

                  我把它们拷贝到 dest 端:

                    -bash-4.1$ scp refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data* \
                    > <anotherhost>:/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/
                    我可以在 dest 端执行第一次的 recover copy 命令,来对 image copy 进行 apply:


                    RMAN> RECOVER COPY OF DATABASE WITH TAG 'incr_update';

                    Starting recover at 20210404_09:40:30
                    using channel ORA_DISK_1
                    no copy of datafile 1 found to recover
                    no copy of datafile 2 found to recover
                    no copy of datafile 3 found to recover
                    no copy of datafile 4 found to recover
                    Finished recover at 20210404_09:40:30

                    RMAN>
                    复制

                    在 source 端,进行第一回 level 的增分更新备份:

                      SQL> create table tab001 as select * from dba_objects;

                      Table created.

                      SQL> exit
                      Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
                      With the Partitioning, OLAP, Data Mining and Real Application Testing options
                      -bash-4.1$
                      -bash-4.1$ rman target

                      Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 09:42:49 2021

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

                      connected to target database: ORCL1120 (DBID=3640541495)

                      RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE format '/refresh/home/bak/%U';

                      Starting backup at 04-APR-21
                      using target database control file instead of recovery catalog
                      allocated channel: ORA_DISK_1
                      channel ORA_DISK_1: SID=1 device type=DISK
                      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=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
                      input datafile file number=00002 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
                      input datafile file number=00003 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
                      input datafile file number=00004 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf
                      channel ORA_DISK_1: starting piece 1 at 04-APR-21
                      channel ORA_DISK_1: finished piece 1 at 04-APR-21
                      piece handle=/refresh/home/bak/11vrehl7_1_1 tag=INCR_UPDATE comment=NONE
                      channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
                      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 04-APR-21
                      channel ORA_DISK_1: finished piece 1 at 04-APR-21
                      piece handle=/refresh/home/bak/12vrehl8_1_1 tag=INCR_UPDATE comment=NONE
                      channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
                      Finished backup at 04-APR-21

                      RMAN> exit
                      复制

                      把这次产生的备份,也拷贝到 dest 端:

                        -bash-4.1$ scp refresh/home/bak/* <anotherhost>:/refresh/home/bak/
                        复制

                         回到 dest 端,注册新产生的备份,然后执行 recover copy 命令:

                          RMAN> catalog start with '/refresh/home/bak';

                          searching for all files that match the pattern refresh/home/bak

                          List of Files Unknown to the Database
                          =====================================
                          File Name: /refresh/home/bak/12vrehl8_1_1
                          File Name: /refresh/home/bak/11vrehl7_1_1
                          File Name: /refresh/home/bak/control.bks
                          File Name: /refresh/home/bak/spfile.bks

                          Do you really want to catalog the above files (enter YES or NO)? yes
                          cataloging files...
                          cataloging done

                          List of Cataloged Files
                          =======================
                          File Name: /refresh/home/bak/12vrehl8_1_1
                          File Name: /refresh/home/bak/11vrehl7_1_1
                          File Name: /refresh/home/bak/control.bks
                          File Name: /refresh/home/bak/spfile.bks

                          RMAN> RECOVER COPY OF DATABASE WITH TAG 'incr_update';

                          Starting recover at 20210404_09:47:23
                          using channel ORA_DISK_1
                          channel ORA_DISK_1: starting incremental datafile backup set restore
                          channel ORA_DISK_1: specifying datafile copies to recover
                          recovering datafile copy file number=00001 name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4
                          recovering datafile copy file number=00002 name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb
                          recovering datafile copy file number=00003 name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte
                          recovering datafile copy file number=00004 name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti
                          channel ORA_DISK_1: reading from backup piece refresh/home/bak/11vrehl7_1_1
                          channel ORA_DISK_1: piece handle=/refresh/home/bak/11vrehl7_1_1 tag=INCR_UPDATE
                          channel ORA_DISK_1: restored backup piece 1
                          channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
                          Finished recover at 20210404_09:47:24

                          RMAN-06497: WARNING: control file is not current, control file AUTOBACKUP skipped

                          RMAN>
                          复制

                          回到 source 端,执行第二次更新增分备份:

                            -bash-4.1$ sqlplus  as sysdba

                            SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 4 09:48:44 2021

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


                            Connected to:
                            Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
                            With the Partitioning, OLAP, Data Mining and Real Application Testing options

                            SQL> create table tab002 as select * from dba_objects;

                            Table created.

                            SQL> exit
                            Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
                            With the Partitioning, OLAP, Data Mining and Real Application Testing options
                            -bash-4.1$ rman target

                            Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 09:49:04 2021

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

                            connected to target database: ORCL1120 (DBID=3640541495)

                            RMAN> BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE format '/refresh/home/bak/%U';

                            Starting backup at 04-APR-21
                            using target database control file instead of recovery catalog
                            allocated channel: ORA_DISK_1
                            channel ORA_DISK_1: SID=42 device type=DISK
                            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=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
                            input datafile file number=00002 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
                            input datafile file number=00003 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
                            input datafile file number=00004 name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf
                            channel ORA_DISK_1: starting piece 1 at 04-APR-21
                            channel ORA_DISK_1: finished piece 1 at 04-APR-21
                            piece handle=/refresh/home/bak/13vrei16_1_1 tag=INCR_UPDATE comment=NONE
                            channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
                            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 04-APR-21
                            channel ORA_DISK_1: finished piece 1 at 04-APR-21
                            piece handle=/refresh/home/bak/14vrei17_1_1 tag=INCR_UPDATE comment=NONE
                            channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
                            Finished backup at 04-APR-21

                            RMAN> exit


                            Recovery Manager complete.
                            -bash-4.1$
                            复制

                             再次拷贝到 dest 端:把这次产生的备份,也拷贝到 dest 端。

                              -bash-4.1$ scp refresh/home/bak/* <anotherhost>:/refresh/home/bak/
                              复制

                               回到 dest 端,注册新产生的备份,然后执行 recover copy 命令:

                                RMAN> catalog start with '/refresh/home/bak';

                                searching for all files that match the pattern refresh/home/bak

                                List of Files Unknown to the Database
                                =====================================
                                File Name: /refresh/home/bak/13vrei16_1_1
                                File Name: /refresh/home/bak/14vrei17_1_1

                                Do you really want to catalog the above files (enter YES or NO)? yes
                                cataloging files...
                                cataloging done

                                List of Cataloged Files
                                =======================
                                File Name: /refresh/home/bak/13vrei16_1_1
                                File Name: /refresh/home/bak/14vrei17_1_1

                                RMAN> RECOVER COPY OF DATABASE WITH TAG 'incr_update';

                                Starting recover at 20210404_09:52:29
                                using channel ORA_DISK_1
                                channel ORA_DISK_1: starting incremental datafile backup set restore
                                channel ORA_DISK_1: specifying datafile copies to recover
                                recovering datafile copy file number=00001 name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4
                                recovering datafile copy file number=00002 name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb
                                recovering datafile copy file number=00003 name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte
                                recovering datafile copy file number=00004 name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti
                                channel ORA_DISK_1: reading from backup piece refresh/home/bak/13vrei16_1_1
                                channel ORA_DISK_1: piece handle=/refresh/home/bak/13vrei16_1_1 tag=INCR_UPDATE
                                channel ORA_DISK_1: restored backup piece 1
                                channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
                                Finished recover at 20210404_09:52:30

                                RMAN-06497: WARNING: control file is not current, control file AUTOBACKUP skipped

                                RMAN>
                                复制


                                好了,现在开始执行最重要的步骤,从source 端作出最新的控制文件备份和 archive log,拷贝到 dest 端:


                                  SQL> alter system switch logfile;

                                  System altered.

                                  SQL> exit
                                  Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
                                  With the Partitioning, OLAP, Data Mining and Real Application Testing options
                                  -bash-4.1$
                                  -bash-4.1$ rman target /

                                  Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 09:54:10 2021

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

                                  connected to target database: ORCL1120 (DBID=3640541495)

                                  RMAN> backup current controlfile format '/refresh/home/bak/newcontrol.bks';

                                  Starting backup at 04-APR-21
                                  using target database control file instead of recovery catalog
                                  allocated channel: ORA_DISK_1
                                  channel ORA_DISK_1: SID=42 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 04-APR-21
                                  channel ORA_DISK_1: finished piece 1 at 04-APR-21
                                  piece handle=/refresh/home/bak/newcontrol.bks tag=TAG20210404T095437 comment=NONE
                                  channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
                                  Finished backup at 04-APR-21

                                  RMAN> exit


                                  Recovery Manager complete.
                                  -bash-4.1$ sqlplus / as sysdba

                                  SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 4 09:54:47 2021

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


                                  Connected to:
                                  Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
                                  With the Partitioning, OLAP, Data Mining and Real Application Testing options

                                  SQL> alter system switch logfile;

                                  System altered.

                                  SQL> exit
                                  复制


                                  拷贝新生成的 archive log,到 dest 端:


                                    -bash-4.1$ rman target /

                                    Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 09:59:25 2021

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

                                    connected to target database: ORCL1120 (DBID=3640541495)

                                    RMAN> list archivelog all;

                                    using target database control file instead of recovery catalog
                                    List of Archived Log Copies for database with db_unique_name ORCL11204
                                    =====================================================================

                                    Key Thrd Seq S Low Time
                                    ------- ---- ------- - ---------
                                    14 1 5 A 04-APR-21
                                    Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_5_1068881903.dbf

                                    15 1 6 A 04-APR-21
                                    Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_6_1068881903.dbf

                                    16 1 7 A 04-APR-21
                                    Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_7_1068881903.dbf

                                    RMAN> exit

                                    -bash-4.1$ scp /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch* <annotherhost>:/refresh/home/bak/
                                    复制


                                    在拷贝最新的控制文件的备份,到 dest 端:


                                      -bash-4.1$ scp /refresh/home/bak/* <anotherhost>:/refresh/home/bak/
                                      复制


                                      回到 dest 端,我需要重新使得数据库从 nomount 启动:



                                        RMAN> shutdown immediate

                                        database dismounted
                                        Oracle instance shut down

                                        RMAN> startup nomount;

                                        connected to target database (not started)
                                        Oracle instance started

                                        Total System Global Area 1570009088 bytes

                                        Fixed Size 2253584 bytes
                                        Variable Size 452988144 bytes
                                        Database Buffers 1107296256 bytes
                                        Redo Buffers 7471104 bytes

                                        RMAN> restore controlfile from '/refresh/home/bak/newcontrol.bks';

                                        Starting restore at 20210404_10:05:15
                                        allocated channel: ORA_DISK_1
                                        channel ORA_DISK_1: SID=19 device type=DISK

                                        channel ORA_DISK_1: restoring control file
                                        channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
                                        output file name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/control01.ctl
                                        output file name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/control02.ctl
                                        Finished restore at 20210404_10:05:17

                                        RMAN> alter database mount;

                                        database mounted
                                        released channel: ORA_DISK_1

                                        RMAN>
                                        复制


                                        使得新引入的控制文件和实际情况相符:


                                          RMAN> crosscheck copy;

                                          allocated channel: ORA_DISK_1
                                          channel ORA_DISK_1: SID=19 device type=DISK
                                          specification does not match any control file copy in the repository
                                          validation failed for datafile copy
                                          datafile copy file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4 RECID=20 STAMP=1068969896
                                          validation failed for datafile copy
                                          datafile copy file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb RECID=21 STAMP=1068969902
                                          validation failed for datafile copy
                                          datafile copy file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte RECID=22 STAMP=1068969903
                                          validation failed for datafile copy
                                          datafile copy file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti RECID=23 STAMP=1068969906
                                          validation failed for archived log
                                          archived log file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_5_1068881903.dbf RECID=14 STAMP=1068976138
                                          validation failed for archived log
                                          archived log file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_6_1068881903.dbf RECID=15 STAMP=1068976445
                                          Crosschecked 6 objects


                                          RMAN> delete expired copy;

                                          released channel: ORA_DISK_1
                                          allocated channel: ORA_DISK_1
                                          channel ORA_DISK_1: SID=19 device type=DISK
                                          specification does not match any control file copy in the repository
                                          List of Datafile Copies
                                          =======================

                                          Key File S Completion Time Ckp SCN Ckp Time
                                          ------- ---- - ----------------- ---------- -----------------
                                          20 1 X 20210404_08:04:56 1047627 20210404_08:04:52
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4
                                          Tag: INCR_UPDATE

                                          21 2 X 20210404_08:05:02 1047631 20210404_08:04:59
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb
                                          Tag: INCR_UPDATE

                                          22 3 X 20210404_08:05:03 1047633 20210404_08:05:02
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte
                                          Tag: INCR_UPDATE

                                          23 4 X 20210404_08:05:06 1047635 20210404_08:05:06
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti
                                          Tag: INCR_UPDATE

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

                                          Key Thrd Seq S Low Time
                                          ------- ---- ------- - -----------------
                                          14 1 5 X 20210404_03:10:11
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_5_1068881903.dbf

                                          15 1 6 X 20210404_09:48:58
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_6_1068881903.dbf


                                          Do you really want to delete the above objects (enter YES or NO)? yes
                                          deleted datafile copy
                                          datafile copy file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4 RECID=20 STAMP=1068969896
                                          deleted datafile copy
                                          datafile copy file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb RECID=21 STAMP=1068969902
                                          deleted datafile copy
                                          datafile copy file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte RECID=22 STAMP=1068969903
                                          deleted datafile copy
                                          datafile copy file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti RECID=23 STAMP=1068969906
                                          deleted archived log
                                          archived log file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_5_1068881903.dbf RECID=14 STAMP=1068976138
                                          deleted archived log
                                          archived log file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_6_1068881903.dbf RECID=15 STAMP=1068976445
                                          Deleted 6 EXPIRED objects


                                          RMAN> crosscheck backup;

                                          using channel ORA_DISK_1
                                          crosschecked backup piece: found to be 'AVAILABLE'
                                          backup piece handle=/refresh/home/bak/0tvrebtg_1_1 RECID=27 STAMP=1068969905
                                          crosschecked backup piece: found to be 'AVAILABLE'
                                          backup piece handle=/refresh/home/bak/control.bks RECID=28 STAMP=1068970262
                                          crosschecked backup piece: found to be 'AVAILABLE'
                                          backup piece handle=/refresh/home/bak/spfile.bks RECID=29 STAMP=1068970271
                                          crosschecked backup piece: found to be 'AVAILABLE'
                                          backup piece handle=/refresh/home/bak/11vrehl7_1_1 RECID=30 STAMP=1068975783
                                          crosschecked backup piece: found to be 'AVAILABLE'
                                          backup piece handle=/refresh/home/bak/12vrehl8_1_1 RECID=31 STAMP=1068975785
                                          crosschecked backup piece: found to be 'AVAILABLE'
                                          backup piece handle=/refresh/home/bak/13vrei16_1_1 RECID=32 STAMP=1068976166
                                          crosschecked backup piece: found to be 'AVAILABLE'
                                          backup piece handle=/refresh/home/bak/14vrei17_1_1 RECID=33 STAMP=1068976168
                                          Crosschecked 7 objects


                                          RMAN> delete expired backup;

                                          using channel ORA_DISK_1
                                          specification does not match any backup in the repository

                                          RMAN> catalog start with '/refresh/home/bak';

                                          searching for all files that match the pattern /refresh/home/bak

                                          List of Files Unknown to the Database
                                          =====================================
                                          File Name: /refresh/home/bak/arch1_6_1068881903.dbf
                                          File Name: /refresh/home/bak/arch1_7_1068881903.dbf
                                          File Name: /refresh/home/bak/arch1_5_1068881903.dbf
                                          File Name: /refresh/home/bak/newcontrol.bks

                                          Do you really want to catalog the above files (enter YES or NO)? yes
                                          cataloging files...
                                          cataloging done

                                          List of Cataloged Files
                                          =======================
                                          File Name: /refresh/home/bak/arch1_6_1068881903.dbf
                                          File Name: /refresh/home/bak/arch1_7_1068881903.dbf
                                          File Name: /refresh/home/bak/arch1_5_1068881903.dbf
                                          File Name: /refresh/home/bak/newcontrol.bks

                                          RMAN> catalog start with '/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs';

                                          searching for all files that match the pattern /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs

                                          List of Files Unknown to the Database
                                          =====================================
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/cntrlorcl11204.dbf
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/lkORCL1120
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/hc_orcl11204.dat
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/init.ora
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/lkORCL11204
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/lkDUMMY
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/spfileorcl11204.ora
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/orapworcl11204

                                          Do you really want to catalog the above files (enter YES or NO)? yes
                                          cataloging files...
                                          cataloging done

                                          List of Cataloged Files
                                          =======================
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/cntrlorcl11204.dbf
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti

                                          List of Files Which Where Not Cataloged
                                          =======================================
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/lkORCL1120
                                          RMAN-07517: Reason: The file header is corrupted
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/hc_orcl11204.dat
                                          RMAN-07517: Reason: The file header is corrupted
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/init.ora
                                          RMAN-07517: Reason: The file header is corrupted
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/lkORCL11204
                                          RMAN-07517: Reason: The file header is corrupted
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/lkDUMMY
                                          RMAN-07517: Reason: The file header is corrupted
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/spfileorcl11204.ora
                                          RMAN-07518: Reason: Foreign database file DBID: 0 Database Name:
                                          File Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/orapworcl11204
                                          RMAN-07517: Reason: The file header is corrupted

                                          RMAN> list copy;

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

                                          Key File S Completion Time Ckp SCN Ckp Time
                                          ------- ---- - ----------------- ---------- -----------------
                                          26 1 A 20210404_10:07:49 1050660 20210404_09:49:26
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4
                                          Tag: INCR_UPDATE

                                          25 2 A 20210404_10:07:49 1050660 20210404_09:49:26
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb
                                          Tag: INCR_UPDATE

                                          27 3 A 20210404_10:07:49 1050660 20210404_09:49:26
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte
                                          Tag: INCR_UPDATE

                                          28 4 A 20210404_10:07:49 1050660 20210404_09:49:26
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti
                                          Tag: INCR_UPDATE

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

                                          Key S Completion Time Ckp SCN Ckp Time
                                          ------- - ----------------- ---------- -----------------
                                          24 A 20210404_10:07:49 1034598 20210404_02:16:07
                                          Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/cntrlorcl11204.dbf
                                          Tag: TAG20210404T021607

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

                                          Key Thrd Seq S Low Time
                                          ------- ---- ------- - -----------------
                                          18 1 5 A 20210404_03:10:11
                                          Name: /refresh/home/bak/arch1_5_1068881903.dbf

                                          16 1 6 A 20210404_09:48:58
                                          Name: /refresh/home/bak/arch1_6_1068881903.dbf

                                          17 1 7 A 20210404_09:54:05
                                          Name: /refresh/home/bak/arch1_7_1068881903.dbf


                                          RMAN> list backup;


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


                                          BS Key Type LV Size Device Type Elapsed Time Completion Time
                                          ------- ---- -- ---------- ----------- ------------ -----------------
                                          27 Incr 1 9.36M DISK 00:00:01 20210404_08:05:05
                                          BP Key: 27 Status: AVAILABLE Compressed: NO Tag: INCR_UPDATE
                                          Piece Name: /refresh/home/bak/0tvrebtg_1_1
                                          SPFILE Included: Modification time: 20210403_07:39:00
                                          SPFILE db_unique_name: ORCL11204
                                          Control File Included: Ckp SCN: 1047633 Ckp time: 20210404_08:05:02

                                          BS Key Type LV Size Device Type Elapsed Time Completion Time
                                          ------- ---- -- ---------- ----------- ------------ -----------------
                                          28 Full 9.33M DISK 00:00:01 20210404_08:11:02
                                          BP Key: 28 Status: AVAILABLE Compressed: NO Tag: TAG20210404T081101
                                          Piece Name: /refresh/home/bak/control.bks
                                          Control File Included: Ckp SCN: 1048038 Ckp time: 20210404_08:11:01

                                          BS Key Type LV Size Device Type Elapsed Time Completion Time
                                          ------- ---- -- ---------- ----------- ------------ -----------------
                                          29 Full 80.00K DISK 00:00:00 20210404_08:11:11
                                          BP Key: 29 Status: AVAILABLE Compressed: NO Tag: TAG20210404T081111
                                          Piece Name: /refresh/home/bak/spfile.bks
                                          SPFILE Included: Modification time: 20210403_07:39:00
                                          SPFILE db_unique_name: ORCL11204

                                          BS Key Type LV Size Device Type Elapsed Time Completion Time
                                          ------- ---- -- ---------- ----------- ------------ -----------------
                                          30 Incr 1 13.84M DISK 00:00:01 20210404_09:43:04
                                          BP Key: 30 Status: AVAILABLE Compressed: NO Tag: INCR_UPDATE
                                          Piece Name: /refresh/home/bak/11vrehl7_1_1
                                          List of Datafiles in backup set 30
                                          File LV Type Ckp SCN Ckp Time Name
                                          ---- -- ---- ---------- ----------------- ----
                                          1 1 Incr 1050428 20210404_09:43:03 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
                                          2 1 Incr 1050428 20210404_09:43:03 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
                                          3 1 Incr 1050428 20210404_09:43:03 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
                                          4 1 Incr 1050428 20210404_09:43:03 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf

                                          BS Key Type LV Size Device Type Elapsed Time Completion Time
                                          ------- ---- -- ---------- ----------- ------------ -----------------
                                          31 Incr 1 9.36M DISK 00:00:01 20210404_09:43:05
                                          BP Key: 31 Status: AVAILABLE Compressed: NO Tag: INCR_UPDATE
                                          Piece Name: /refresh/home/bak/12vrehl8_1_1
                                          SPFILE Included: Modification time: 20210403_07:39:00
                                          SPFILE db_unique_name: ORCL11204
                                          Control File Included: Ckp SCN: 1050429 Ckp time: 20210404_09:43:04

                                          BS Key Type LV Size Device Type Elapsed Time Completion Time
                                          ------- ---- -- ---------- ----------- ------------ -----------------
                                          32 Incr 1 10.21M DISK 00:00:01 20210404_09:49:27
                                          BP Key: 32 Status: AVAILABLE Compressed: NO Tag: INCR_UPDATE
                                          Piece Name: /refresh/home/bak/13vrei16_1_1
                                          List of Datafiles in backup set 32
                                          File LV Type Ckp SCN Ckp Time Name
                                          ---- -- ---- ---------- ----------------- ----
                                          1 1 Incr 1050660 20210404_09:49:26 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
                                          2 1 Incr 1050660 20210404_09:49:26 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
                                          3 1 Incr 1050660 20210404_09:49:26 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
                                          4 1 Incr 1050660 20210404_09:49:26 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf

                                          BS Key Type LV Size Device Type Elapsed Time Completion Time
                                          ------- ---- -- ---------- ----------- ------------ -----------------
                                          33 Incr 1 9.36M DISK 00:00:01 20210404_09:49:28
                                          BP Key: 33 Status: AVAILABLE Compressed: NO Tag: INCR_UPDATE
                                          Piece Name: /refresh/home/bak/14vrei17_1_1
                                          SPFILE Included: Modification time: 20210403_07:39:00
                                          SPFILE db_unique_name: ORCL11204
                                          Control File Included: Ckp SCN: 1050660 Ckp time: 20210404_09:49:26

                                          BS Key Type LV Size Device Type Elapsed Time Completion Time
                                          ------- ---- -- ---------- ----------- ------------ -----------------
                                          34 Full 9.33M DISK 00:00:00 20210404_09:54:37
                                          BP Key: 34 Status: AVAILABLE Compressed: NO Tag: TAG20210404T095437
                                          Piece Name: /refresh/home/bak/newcontrol.bks
                                          Control File Included: Ckp SCN: 1050826 Ckp time: 20210404_09:54:37

                                          RMAN>
                                          复制


                                          在我准备在 dest 端,进行数据库的真正的 recover之前,需要提到一点,有时候,客户环境的 image copy 很大,达到好几个TB,这时候,可以考虑用 switch copy 命令,这个命令跳过了 restore 过程,把 image copy 直接在当前的位置转换为数据文件。


                                            RMAN> switch database to copy;

                                            datafile 1 switched to datafile copy "/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4"
                                            datafile 2 switched to datafile copy "/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb"
                                            datafile 3 switched to datafile copy "/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte"
                                            datafile 4 switched to datafile copy "/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_I-3640541495_TS-USERS_FNO-4_0uvrebti"

                                            RMAN> list copy;

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

                                            Key File S Completion Time Ckp SCN Ckp Time
                                            ------- ---- - ----------------- ---------- -----------------
                                            29 1 A 20210404_10:11:36 1047627 20210404_08:04:52
                                            Name: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
                                            Tag: INCR_UPDATE

                                            30 2 A 20210404_10:11:36 1047631 20210404_08:04:59
                                            Name: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
                                            Tag: INCR_UPDATE

                                            31 3 A 20210404_10:11:36 1047633 20210404_08:05:02
                                            Name: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
                                            Tag: INCR_UPDATE

                                            32 4 A 20210404_10:11:36 1047635 20210404_08:05:06
                                            Name: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf
                                            Tag: INCR_UPDATE

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

                                            Key S Completion Time Ckp SCN Ckp Time
                                            ------- - ----------------- ---------- -----------------
                                            24 A 20210404_10:07:49 1034598 20210404_02:16:07
                                            Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/cntrlorcl11204.dbf
                                            Tag: TAG20210404T021607

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

                                            Key Thrd Seq S Low Time
                                            ------- ---- ------- - -----------------
                                            18 1 5 A 20210404_03:10:11
                                            Name: /refresh/home/bak/arch1_5_1068881903.dbf

                                            16 1 6 A 20210404_09:48:58
                                            Name: /refresh/home/bak/arch1_6_1068881903.dbf

                                            17 1 7 A 20210404_09:54:05
                                            Name: /refresh/home/bak/arch1_7_1068881903.dbf


                                            RMAN> recover database;

                                            Starting recover at 20210404_10:11:49
                                            using channel ORA_DISK_1

                                            starting media recovery

                                            archived log for thread 1 with sequence 6 is already on disk as file /refresh/home/bak/arch1_6_1068881903.dbf
                                            archived log for thread 1 with sequence 7 is already on disk as file /refresh/home/bak/arch1_7_1068881903.dbf
                                            archived log file name=/refresh/home/bak/arch1_6_1068881903.dbf thread=1 sequence=6
                                            archived log file name=/refresh/home/bak/arch1_7_1068881903.dbf thread=1 sequence=7
                                            unable to find archived log
                                            archived log thread=1 sequence=8
                                            RMAN-00571: ===========================================================
                                            RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
                                            RMAN-00571: ===========================================================
                                            RMAN-03002: failure of recover command at 04/04/2021 10:11:49
                                            RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 8 and starting SCN of 1050839

                                            RMAN> alter database open resetlogs;

                                            database opened

                                            RMAN>
                                            复制


                                            至此,数据库的 restore/recover 成功了,我们再看看新的数据库文件的数据文件状况:


                                              SQL> select name from v$datafile;

                                              NAME
                                              --------------------------------------------------------------------------------
                                              /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_
                                              I-3640541495_TS-SYSTEM_FNO-1_0qvrebt4

                                              /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_
                                              I-3640541495_TS-SYSAUX_FNO-2_0rvrebtb

                                              /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_
                                              I-3640541495_TS-UNDOTBS1_FNO-3_0svrebte

                                              /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/data_D-ORCL1120_
                                              I-3640541495_TS-USERS_FNO-4_0uvrebti

                                              NAME
                                              --------------------------------------------------------------------------------
                                               
                                              SQL>
                                              复制

                                              后续文章更加精彩,欢迎关注本公众号或访问【阅读原文】。

                                              ——End——

                                              专注于技术不限于技术!

                                              用碎片化的时间,一点一滴地提高数据库技术和个人能力。

                                              欢迎关注!


                                              备份恢复系列:

                                              Oracle数据库工程师手记:备份恢复双城记(一)

                                              Oracle数据库工程师手记:备份恢复双城记(二)


                                              文章转载自Oracle数据库技术,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

                                              评论