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

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

1275

编者按:

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

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

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

现在,我真的开始进行两台机器之间的备份、恢复试验了。

    首先,在source 端,进行第一次备份(level 0 增分备份 +  控制文件备份+ SPFILE 增分备份):

    RMAN> backup incremental level 0 database format '/refresh/home/bak00/%U';

    Starting backup at 20210404_02:13:32
    using target database control file instead of recovery catalog
    allocated channel: ORA_DISK_1
    channel ORA_DISK_1: SID=39 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=/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 20210404_02:13:32
    channel ORA_DISK_1: finished piece 1 at 20210404_02:13:39
    piece handle=/refresh/home/bak00/0cvrdnac_1_1 tag=TAG20210404T021332 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
    channel ORA_DISK_1: starting incremental level 0 datafile backup set
    channel ORA_DISK_1: specifying datafile(s) in backup set
    including current control file in backup set
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 20210404_02:13:40
    channel ORA_DISK_1: finished piece 1 at 20210404_02:13:41
    piece handle=/refresh/home/bak00/0dvrdnaj_1_1 tag=TAG20210404T021332 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 20210404_02:13:42

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

    Starting backup at 20210404_02:16:07
    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_02:16:08
    channel ORA_DISK_1: finished piece 1 at 20210404_02:16:09
    piece handle=/refresh/home/bak00/control.bks tag=TAG20210404T021607 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 20210404_02:16:09

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

    Starting backup at 20210404_02:16: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
    including current SPFILE in backup set
    channel ORA_DISK_1: starting piece 1 at 20210404_02:16:31
    channel ORA_DISK_1: finished piece 1 at 20210404_02:16:32
    piece handle=/refresh/home/bak00/spfile.bks tag=TAG20210404T021631 comment=NONE
    channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
    Finished backup at 20210404_02:16:32

    RMAN>

     接下来,拷贝这些备份到新数据库:

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

       登录到 dest 端,进行初步的恢复动作:

        RMAN> restore spfile from '/refresh/home/bak00/spfile.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 spfile from AUTOBACKUP refresh/home/bak00/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/bak00/spfile.bks';

        Starting restore at 04-APR-21
        using channel ORA_DISK_1

        channel ORA_DISK_1: restoring spfile from AUTOBACKUP refresh/home/bak00/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$

           如果各目录已经建立好了,那么就可以进行 restore 操作:

            -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/bak00/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>

            利用 level 0 的增量备份,进行 restore 操作:

              RMAN> restore database;

              Starting restore at 04-APR-21
              using channel ORA_DISK_1

              channel ORA_DISK_1: starting datafile backup set restore
              channel ORA_DISK_1: specifying datafile(s) to restore from backup set
              channel ORA_DISK_1: restoring datafile 00001 to refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
              channel ORA_DISK_1: restoring datafile 00002 to refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
              channel ORA_DISK_1: restoring datafile 00003 to refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
              channel ORA_DISK_1: restoring datafile 00004 to refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf
              channel ORA_DISK_1: reading from backup piece refresh/home/bak00/0cvrdnac_1_1
              channel ORA_DISK_1: piece handle=/refresh/home/bak00/0cvrdnac_1_1 tag=TAG20210404T021332
              channel ORA_DISK_1: restored backup piece 1
              channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
              Finished restore at 04-APR-21

              RMAN>

              回到 source 端,进行 level 1 增分备份:

                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$ rman target

                Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 02:46:19 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 database format '/refresh/home/bak01/%U';

                Starting backup at 20210404_02:46:48
                using target database control file instead of recovery catalog
                allocated channel: ORA_DISK_1
                channel ORA_DISK_1: SID=39 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 20210404_02:46:48
                channel ORA_DISK_1: finished piece 1 at 20210404_02:46:51
                piece handle=/refresh/home/bak01/0gvrdp8o_1_1 tag=TAG20210404T024648 comment=NONE
                channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
                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_02:46:52
                channel ORA_DISK_1: finished piece 1 at 20210404_02:46:53
                piece handle=/refresh/home/bak01/0hvrdp8r_1_1 tag=TAG20210404T024648 comment=NONE
                channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
                Finished backup at 20210404_02:46:53

                RMAN> exit

                 将第一次 level 1 增分备份,拷贝到 dest 端:

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

                   在 dest 端,进行第一次 recover 操作:

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

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

                    List of Files Unknown to the Database
                    =====================================
                    File Name: /refresh/home/bak01/0gvrdp8o_1_1
                    File Name: /refresh/home/bak01/0hvrdp8r_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/bak01/0gvrdp8o_1_1
                    File Name: /refresh/home/bak01/0hvrdp8r_1_1

                    RMAN> recover database;

                    Starting recover at 04-APR-21
                    using channel ORA_DISK_1
                    channel ORA_DISK_1: starting incremental datafile backup set restore
                    channel ORA_DISK_1: specifying datafile(s) to restore from backup set
                    destination for restore of datafile 00001: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
                    destination for restore of datafile 00002: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
                    destination for restore of datafile 00003: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
                    destination for restore of datafile 00004: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf
                    channel ORA_DISK_1: reading from backup piece /refresh/home/bak01/0gvrdp8o_1_1
                    channel ORA_DISK_1: piece handle=/refresh/home/bak01/0gvrdp8o_1_1 tag=TAG20210404T024648
                    channel ORA_DISK_1: restored backup piece 1
                    channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

                    starting media recovery

                    unable to find archived log
                    archived log thread=1 sequence=3
                    RMAN-00571: ===========================================================
                    RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
                    RMAN-00571: ===========================================================
                    RMAN-03002: failure of recover command at 04/04/2021 02:56:50
                    RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 3 and starting SCN of 1034598

                    RMAN>

                    对出现的错误不用管。


                    回到 source 端,进行第二次的 level 1 增分备份:

                      SQL> create table tab002 as select * from dba_objects;

                      Table created.

                      SQL> exit


                      RMAN> backup incremental level 1 database format '/refresh/home/bak02/%U';

                      Starting backup at 20210404_03:02:46
                      using channel ORA_DISK_1
                      channel ORA_DISK_1: starting incremental level 1 datafile backup set
                      channel ORA_DISK_1: specifying datafile(s) in backup set
                      input datafile file number=00001 name=/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 20210404_03:02:46
                      channel ORA_DISK_1: finished piece 1 at 20210404_03:02:49
                      piece handle=/refresh/home/bak02/0jvrdq6m_1_1 tag=TAG20210404T030246 comment=NONE
                      channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
                      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_03:02:51
                      channel ORA_DISK_1: finished piece 1 at 20210404_03:02:52
                      piece handle=/refresh/home/bak02/0kvrdq6q_1_1 tag=TAG20210404T030246 comment=NONE
                      channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
                      Finished backup at 20210404_03:02:52

                      RMAN>

                       再次拷贝第二次的level 1 增分备份到 dest 端去。


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

                         回到 dest 端,执行第二次 recover:


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

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

                          List of Files Unknown to the Database
                          =====================================
                          File Name: /refresh/home/bak02/0kvrdq6q_1_1
                          File Name: /refresh/home/bak02/0jvrdq6m_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/bak02/0kvrdq6q_1_1
                          File Name: /refresh/home/bak02/0jvrdq6m_1_1

                          RMAN> recover database;

                          Starting recover at 04-APR-21
                          using channel ORA_DISK_1
                          channel ORA_DISK_1: starting incremental datafile backup set restore
                          channel ORA_DISK_1: specifying datafile(s) to restore from backup set
                          destination for restore of datafile 00001: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf
                          destination for restore of datafile 00002: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf
                          destination for restore of datafile 00003: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf
                          destination for restore of datafile 00004: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf
                          channel ORA_DISK_1: reading from backup piece /refresh/home/bak02/0jvrdq6m_1_1
                          channel ORA_DISK_1: piece handle=/refresh/home/bak02/0jvrdq6m_1_1 tag=TAG20210404T030246
                          channel ORA_DISK_1: restored backup piece 1
                          channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

                          starting media recovery

                          unable to find archived log
                          archived log thread=1 sequence=3
                          RMAN-00571: ===========================================================
                          RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
                          RMAN-00571: ===========================================================
                          RMAN-03002: failure of recover command at 04/04/2021 03:07:16
                          RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 3 and starting SCN of 1034598

                          RMAN>

                           对错误不必在意。


                          现在到了最关键的一步了。我要从 source端,获得最新的 controlfile 备份,拷贝到 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$ rman target /

                            Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 03:09:20 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/bak03/newcontrol.bks';

                            Starting backup at 20210404_03:09:49
                            using target database control file instead of recovery catalog
                            allocated channel: ORA_DISK_1
                            channel ORA_DISK_1: SID=41 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 20210404_03:09:51
                            channel ORA_DISK_1: finished piece 1 at 20210404_03:09:52
                            piece handle=/refresh/home/bak03/newcontrol.bks tag=TAG20210404T030950 comment=NONE
                            channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
                            Finished backup at 20210404_03:09:52

                            RMAN> exit


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

                            SQL*Plus: Release 11.2.0.4.0 Production on Sun Apr 4 03:09:59 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
                            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 03:10:21 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
                            ------- ---- ------- - -----------------
                            12 1 3 A 20210404_02:04:27
                            Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_3_1068881903.dbf

                            13 1 4 A 20210404_03:09:14
                            Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_4_1068881903.dbf


                            RMAN>

                             拷贝我刚才生成的archive log 和 controlfile 备份到 dest端:


                              -bash-4.1$ scp /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch* <anotherhost>:/refresh/home/bak03
                              -bash-4.1$ scp /refresh/home/bak03/* <anotherhost>:/refresh/home/bak03/

                               回到 dest 端,先恢复 control file,再重新注册这些备份和 archivelog:


                                -bash-4.1$ rman target /

                                Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 4 03:17:23 2021

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

                                connected to target database: ORCL1120 (DBID=3640541495, not open)

                                RMAN> shutdown immediate

                                using target database control file instead of recovery catalog
                                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/bak03/newcontrol.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> crosscheck copy;

                                allocated channel: ORA_DISK_1
                                channel ORA_DISK_1: SID=19 device type=DISK
                                specification does not match any datafile copy in the repository
                                specification does not match any control file copy in the repository
                                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_3_1068881903.dbf RECID=12 STAMP=1068952155
                                Crosschecked 1 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 datafile copy in the repository
                                specification does not match any control file copy in the repository
                                List of Archived Log Copies for database with db_unique_name ORCL11204
                                =====================================================================

                                Key Thrd Seq S Low Time
                                ------- ---- ------- - ---------
                                12 1 3 X 04-APR-21
                                Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_3_1068881903.dbf


                                Do you really want to delete the above objects (enter YES or NO)? yes
                                deleted archived log
                                archived log file name=/refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_3_1068881903.dbf RECID=12 STAMP=1068952155
                                Deleted 1 EXPIRED objects


                                RMAN> crosscheck backup;

                                using channel ORA_DISK_1
                                crosschecked backup piece: found to be 'AVAILABLE'
                                backup piece handle=/refresh/home/bak00/0cvrdnac_1_1 RECID=18 STAMP=1068948812
                                crosschecked backup piece: found to be 'AVAILABLE'
                                backup piece handle=/refresh/home/bak00/0dvrdnaj_1_1 RECID=19 STAMP=1068948820
                                crosschecked backup piece: found to be 'AVAILABLE'
                                backup piece handle=/refresh/home/bak00/control.bks RECID=20 STAMP=1068948968
                                crosschecked backup piece: found to be 'AVAILABLE'
                                backup piece handle=/refresh/home/bak00/spfile.bks RECID=21 STAMP=1068948991
                                crosschecked backup piece: found to be 'AVAILABLE'
                                backup piece handle=/refresh/home/bak01/0gvrdp8o_1_1 RECID=22 STAMP=1068950808
                                crosschecked backup piece: found to be 'AVAILABLE'
                                backup piece handle=/refresh/home/bak01/0hvrdp8r_1_1 RECID=23 STAMP=1068950812
                                crosschecked backup piece: found to be 'AVAILABLE'
                                backup piece handle=/refresh/home/bak02/0jvrdq6m_1_1 RECID=24 STAMP=1068951767
                                crosschecked backup piece: found to be 'AVAILABLE'
                                backup piece handle=/refresh/home/bak02/0kvrdq6q_1_1 RECID=25 STAMP=1068951771
                                Crosschecked 8 objects


                                RMAN> delete expired backup;

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

                                RMAN> catalog start with '/refres/home/bak00';

                                searching for all files that match the pattern /refres/home/bak00
                                no files found to be unknown to the database


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

                                searching for all files that match the pattern /refresh/home/bak00
                                no files found to be unknown to the database

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

                                searching for all files that match the pattern /refresh/home/bak01
                                no files found to be unknown to the database

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

                                searching for all files that match the pattern /refresh/home/bak02
                                no files found to be unknown to the database

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

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

                                List of Files Unknown to the Database
                                =====================================
                                File Name: /refresh/home/bak03/arch1_3_1068881903.dbf
                                File Name: /refresh/home/bak03/newcontrol.bks
                                File Name: /refresh/home/bak03/arch1_4_1068881903.dbf

                                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/bak03/arch1_3_1068881903.dbf
                                File Name: /refresh/home/bak03/newcontrol.bks
                                File Name: /refresh/home/bak03/arch1_4_1068881903.dbf

                                 然后,执行最后的 recover 操作:


                                  RMAN> recover database;

                                  Starting recover at 04-APR-21
                                  using channel ORA_DISK_1

                                  starting media recovery

                                  archived log for thread 1 with sequence 3 is already on disk as file /refresh/home/bak03/arch1_3_1068881903.dbf
                                  archived log for thread 1 with sequence 4 is already on disk as file /refresh/home/bak03/arch1_4_1068881903.dbf
                                  archived log file name=/refresh/home/bak03/arch1_3_1068881903.dbf thread=1 sequence=3
                                  archived log file name=/refresh/home/bak03/arch1_4_1068881903.dbf thread=1 sequence=4
                                  unable to find archived log
                                  archived log thread=1 sequence=5
                                  RMAN-00571: ===========================================================
                                  RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
                                  RMAN-00571: ===========================================================
                                  RMAN-03002: failure of recover command at 04/04/2021 03:20:16
                                  RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 5 and starting SCN of 1036145


                                  RMAN> alter database open resetlogs;

                                  database opened

                                  RMAN>

                                   可以看到,已经成功恢复了。


                                  也就是说,可以在 source 端和 target 端,多次传递备份,进行多次的 recover 操作,这样,对用户而言,down time 只发生在 source 端停机后,直到 dest 端最后一次 recover 后 alter database open resetlogs 结束为止。


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

                                  ——End——

                                  专注于技术不限于技术!

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

                                  欢迎关注!



                                  备份恢复系列:

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



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

                                  评论