ITPub博客

首页 > 数据库 > 数据库开发技术 > Oracle数据库工程师手记:备份恢复双城记(一)

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

原创 数据库开发技术 作者:lukeunique 时间:2021-04-26 08:08:00 0 删除 编辑

编者按:

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


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

       有的时候,客户会有这样一种需求:他需要把数据库整体移行(移植)到另外一个硬件服务器上,但是,客户希望,尽可能地减少对 数据库用户的影响,当新数据库启用之前,客户希望他的数据库用户仍然能够访问数据库。


         其实,最适合的方法,就是建立 Data Guard 了,无论原来的数据库有什么变更,都可以通过 redo 数据, 同步到新的数据库上。但是有的用户,对 Data Guard 的构筑过程不够熟悉,担心出现各种问题,那么就需要找到一些别的方法。


         有的客户,会期待用自己所熟悉的备份、恢复的方法,在两个数据库服务器硬件之间进行腾挪,实现利用全备份+ 增分备份的方式,实现最小化停机时间,来完成迁移。想象一下,普通的备份恢复是什么样子,比如:

rman>run{       restore database;<br>       recover database;}

 

        然而,我现在需要的,却是这么一种方式:


              在 dest 数据库,用第一次的备份,进行 restore。

              继续在 source 数据库 和 dest 数据库直接,不断传递备份文件。


               用第二次的备份,进行 recover,

               用第三次的备份,再进行 recover,

               ......

               用最后一次的备份,进行 recover,

               用最新的 archive log ,进行 recover。


        那么,在dest 端,从 rman 执行的就是类似这样的命令:


rman>restore database;rman>recover database;rman>recover database;

 

       能否可以实现呢,我把步骤细化一番,进行试验。在真正开始用在两个服务器之间进行腾挪之前,我先用一台机器模拟一下。我的设想是这样的:


首先,进行 level 0  的备份。紧接着,进行控制文件的备份。


然后,对数据库进行一些操作,然后,执行 level 1 增分备份。

然后,切换日志。


然后,对数据库进行一些操作,然后,再执行一轮 level 1 增分备份。

然后,切换日志。


然后,对数据库进行一些操作,然后,再执行一轮 level 1 增分备份。

然后,切换日志。


至此,备份完成。


然后,开始进行恢复测试,删除数据库的数据文件、online redo,并且把 archive log 挪走。

statup nomount 启动,恢复前面的 控制文件 (restore controlfile),将数据库设置为 mount 状态。


执行 restore database;

由于控制文件是比较陈旧的,所以,它没有上面三次 level 1 的增分备份的信息,


所以,

a)我用 catalog 命令,依次进行:catalog start with '增分备份所在的目录';

b)紧接着执行 recover database;


重复上述 a) b) 三次。


然后,还缺少最后的 archive log, 我再注册 archive log,然后执行最后一次的 recover database;


最后,执行 alter database open resetlogs;


具体的过程是这样的:

第一次,执行 level 0 备份:


RMAN> backup incremental level 0 database format '/refresh/home/bak00/%U';RMAN> backup current controlfile format '/refresh/home/bak00/control.bks';

得到的备份信息:

RMAN> list backup; List of Backup Sets=================== BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------7       Incr 0  1.00G      DISK        00:00:13     20210403_07:07:31        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/06vrbk56_1_1  List of Datafiles in backup set 7  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------8       Incr 0  9.36M      DISK        00:00:01     20210403_07:07:34        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/07vrbk5l_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991827       Ckp time: 20210403_07:07:33 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------9       Full    9.33M      DISK        00:00:01     20210403_07:08:09        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070808        Piece Name: /refresh/home/bak00/control.bks  Control File Included: Ckp SCN: 991848       Ckp time: 20210403_07:08:08 RMAN>


 注意这里得到的 level 0 增分备份的 checkpoint time:  20210403_07:07:18。


然后执行更新操作:


SQL> create table tab001 as select * from dba_objects;

这时,进行 level 1 增分备份(第一回):

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

然后,执行日志切换(这里是为了查看后来的恢复操作时需要哪些 archive log)(第一回):

SQL> alter system switch logfile;SQL> alter system switch logfile;


此时,得到的备份信息和 archive log 信息如下:

RMAN> list backup; using target database control file instead of recovery catalog List of Backup Sets=================== BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------7       Incr 0  1.00G      DISK        00:00:13     20210403_07:07:31        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/06vrbk56_1_1  List of Datafiles in backup set 7  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------8       Incr 0  9.36M      DISK        00:00:01     20210403_07:07:34        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/07vrbk5l_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991827       Ckp time: 20210403_07:07:33 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------9       Full    9.33M      DISK        00:00:01     20210403_07:08:09        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070808        Piece Name: /refresh/home/bak00/control.bks  Control File Included: Ckp SCN: 991848       Ckp time: 20210403_07:08:08 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------10      Incr 1  9.84M      DISK        00:00:00     20210403_07:09:37        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070936        Piece Name: /refresh/home/bak01/09vrbk9h_1_1  List of Datafiles in backup set 10  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------11      Incr 1  9.36M      DISK        00:00:01     20210403_07:09:39        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070936        Piece Name: /refresh/home/bak01/0avrbk9i_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991965       Ckp time: 20210403_07:09:37 RMAN> list archivelog all; List of Archived Log Copies for database with db_unique_name ORCL11204===================================================================== Key     Thrd Seq     S Low Time------- ---- ------- - -----------------3       1    1       A 20210403_06:50:09        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_1_1068879009.dbf 4       1    2       A 20210403_07:10:22        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_2_1068879009.dbf  RMAN>


 接下来,再进行第二次的 level 1 的增分备份:


对数据库进行一些变更(第二回):

SQL> create table tab002 as select * from dba_objects;

 执行level 1 增分备份(第二回):

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

 再次日志切换(第二回):

SQL> alter system switch logfile;SQL> alter system switch logfile;


 查看备份信息和 archive log 信息:

RMAN> list backup; List of Backup Sets=================== BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------7       Incr 0  1.00G      DISK        00:00:13     20210403_07:07:31        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/06vrbk56_1_1  List of Datafiles in backup set 7  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------8       Incr 0  9.36M      DISK        00:00:01     20210403_07:07:34        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/07vrbk5l_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991827       Ckp time: 20210403_07:07:33 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------9       Full    9.33M      DISK        00:00:01     20210403_07:08:09        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070808        Piece Name: /refresh/home/bak00/control.bks  Control File Included: Ckp SCN: 991848       Ckp time: 20210403_07:08:08 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------10      Incr 1  9.84M      DISK        00:00:00     20210403_07:09:37        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070936        Piece Name: /refresh/home/bak01/09vrbk9h_1_1  List of Datafiles in backup set 10  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------11      Incr 1  9.36M      DISK        00:00:01     20210403_07:09:39        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070936        Piece Name: /refresh/home/bak01/0avrbk9i_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991965       Ckp time: 20210403_07:09:37 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------12      Incr 1  9.93M      DISK        00:00:00     20210403_07:12:57        BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T071257        Piece Name: /refresh/home/bak02/0bvrbkfp_1_1  List of Datafiles in backup set 12  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    1  Incr 992145     20210403_07:12:57 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    1  Incr 992145     20210403_07:12:57 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    1  Incr 992145     20210403_07:12:57 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    1  Incr 992145     20210403_07:12:57 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------13      Incr 1  9.36M      DISK        00:00:01     20210403_07:12:59        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T071257        Piece Name: /refresh/home/bak02/0cvrbkfq_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 992145       Ckp time: 20210403_07:12:57RMAN> list archivelog all; using target database control file instead of recovery catalogList of Archived Log Copies for database with db_unique_name ORCL11204===================================================================== Key     Thrd Seq     S Low Time------- ---- ------- - -----------------3       1    1       A 20210403_06:50:09        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_1_1068879009.dbf 4       1    2       A 20210403_07:10:22        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_2_1068879009.dbf 5       1    3       A 20210403_07:10:28        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_3_1068879009.dbf 6       1    4       A 20210403_07:13:37        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_4_1068879009.dbf RMAN>


再来一回(第三回):


数据库变更(第三回):


SQL> create table tab003 as select * from dba_objects;

 level 1 增分备份(第三回):

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

 日志切换(第三回):

SQL> alter system switch logfile;SQL> alter system switch logfile;


 再次查看备份信息和 archive log 信息:

RMAN> list backup; List of Backup Sets===================  BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------7       Incr 0  1.00G      DISK        00:00:13     20210403_07:07:31        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/06vrbk56_1_1  List of Datafiles in backup set 7  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------8       Incr 0  9.36M      DISK        00:00:01     20210403_07:07:34        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/07vrbk5l_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991827       Ckp time: 20210403_07:07:33 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------9       Full    9.33M      DISK        00:00:01     20210403_07:08:09        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070808        Piece Name: /refresh/home/bak00/control.bks  Control File Included: Ckp SCN: 991848       Ckp time: 20210403_07:08:08 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------10      Incr 1  9.84M      DISK        00:00:00     20210403_07:09:37        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070936        Piece Name: /refresh/home/bak01/09vrbk9h_1_1  List of Datafiles in backup set 10  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------11      Incr 1  9.36M      DISK        00:00:01     20210403_07:09:39        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070936        Piece Name: /refresh/home/bak01/0avrbk9i_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991965       Ckp time: 20210403_07:09:37 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------12      Incr 1  9.93M      DISK        00:00:00     20210403_07:12:57        BP Key: 12   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T071257        Piece Name: /refresh/home/bak02/0bvrbkfp_1_1  List of Datafiles in backup set 12  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    1  Incr 992145     20210403_07:12:57 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    1  Incr 992145     20210403_07:12:57 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    1  Incr 992145     20210403_07:12:57 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    1  Incr 992145     20210403_07:12:57 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------13      Incr 1  9.36M      DISK        00:00:01     20210403_07:12:59        BP Key: 13   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T071257        Piece Name: /refresh/home/bak02/0cvrbkfq_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 992145       Ckp time: 20210403_07:12:57 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------14      Incr 1  9.82M      DISK        00:00:00     20210403_07:15:56        BP Key: 14   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T071555        Piece Name: /refresh/home/bak03/0dvrbklc_1_1  List of Datafiles in backup set 14  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    1  Incr 992322     20210403_07:15:56 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    1  Incr 992322     20210403_07:15:56 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    1  Incr 992322     20210403_07:15:56 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    1  Incr 992322     20210403_07:15:56 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------15      Incr 1  9.36M      DISK        00:00:01     20210403_07:15:58        BP Key: 15   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T071555        Piece Name: /refresh/home/bak03/0evrbkld_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 992323       Ckp time: 20210403_07:15:57 RMAN> RMAN> list archivelog all; using target database control file instead of recovery catalogList of Archived Log Copies for database with db_unique_name ORCL11204===================================================================== Key     Thrd Seq     S Low Time------- ---- ------- - -----------------3       1    1       A 20210403_06:50:09        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_1_1068879009.dbf 4       1    2       A 20210403_07:10:22        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_2_1068879009.dbf 5       1    3       A 20210403_07:10:28        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_3_1068879009.dbf 6       1    4       A 20210403_07:13:37        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_4_1068879009.dbf 7       1    5       A 20210403_07:13:41        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_5_1068879009.dbf 8       1    6       A 20210403_07:16:41        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_6_1068879009.dbf RMAN>


再作一点变更吧,并且把 online redo 切换出来,再记录一下 datafile 和 online redo 的位置,然后停机。

SQL> create table tab004 as select * from dba_objects; Table created. SQL> alter system switch logfile; System altered. SQL> select * from v$log;     GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE    MEMBERS ARC---------- ---------- ---------- ---------- ---------- ---------- ---STATUS           FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME---------------- ------------- --------- ------------ ---------         1          1          7   52428800        512          1 YESACTIVE                  992359 03-APR-21       992471 03-APR-21          2          1          8   52428800        512          1 NOCURRENT                 992471 03-APR-21   2.8147E+14          3          1          6   52428800        512          1 YESINACTIVE                992355 03-APR-21       992359 03-APR-21  SQL> select member from v$logfile; MEMBER--------------------------------------------------------------------------------/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/redo03.log/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/redo02.log/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/redo01.log SQL> select name from v$datafile; NAME--------------------------------------------------------------------------------/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf SQL> SQL> shutdown immediate;

 

好了,现在我可以开始进行恢复的试验了:


 把数据文件和online redo 统统挪走:

-bash-4.1$ pwd/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204-bash-4.1$ ls -lrttotal 1520276-rw-rw---- 1 oracle oracle  20979712 Apr  3 06:50 temp01.dbf-rw-rw---- 1 oracle oracle  52429312 Apr  3 07:16 redo03.log-rw-rw---- 1 oracle oracle  52429312 Apr  3 07:17 redo01.log-rw-rw---- 1 oracle oracle  52429312 Apr  3 07:20 redo02.log-rw-rw---- 1 oracle oracle 817897472 Apr  3 07:20 system01.dbf-rw-rw---- 1 oracle oracle  31465472 Apr  3 07:20 undotbs01.dbf-rw-rw---- 1 oracle oracle 524296192 Apr  3 07:20 sysaux01.dbf-rw-rw---- 1 oracle oracle   5251072 Apr  3 07:20 users01.dbf-rw-rw---- 1 oracle oracle   9748480 Apr  3 07:20 control02.ctl-rw-rw---- 1 oracle oracle   9748480 Apr  3 07:20 control01.ctl-bash-4.1$ cd ..-bash-4.1$ mv orcl11204 orcl11204.bak-bash-4.1$ mkdir orcl11204


 再把 archive log 挪走:

-bash-4.1$ mkdir -p /refresh/home/arc-bash-4.1$ mv  /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arc* /refresh/home/arc-bash-4.1$ ls -lrt /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbstotal 9544-rw-r--r-- 1 oracle oracle    2851 May 15  2009 init.ora-rw-r----- 1 oracle oracle      24 Aug 24  2017 lkORCL1120-rw-r----- 1 oracle oracle    1536 Aug 24  2017 orapworcl11204-rw-r----- 1 oracle oracle      24 Aug 24  2017 lkORCL11204-rw-r----- 1 oracle oracle    3584 Apr  3 06:50 spfileorcl11204.ora-rw-rw---- 1 oracle oracle 9748480 Apr  3 07:15 snapcf_orcl11204.f-rw-rw---- 1 oracle oracle    1544 Apr  3 07:20 hc_orcl11204.dat


 下面,nomount 模式启动,然后恢复出旧的控制文件,这是为了模拟将来在新机器上只有旧的控制文件的操作。

-bash-4.1$ rman target / Recovery Manager: Release 11.2.0.4.0 - Production on Sat Apr 3 07:22:59 2021 Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved. connected to target database (not started) RMAN> startup nomount;  RMAN> restore controlfile from '/refresh/home/bak00/control.bks'; Starting restore at 20210403_07:25:03using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=1 device type=DISK channel ORA_DISK_1: restoring control filechannel ORA_DISK_1: restore complete, elapsed time: 00:00:01output file name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/control01.ctloutput file name=/refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/control02.ctlFinished restore at 20210403_07:25:04 RMAN> alter database mount; database mountedreleased channel: ORA_DISK_1 RMAN>


 可以看到,因为控制文件的信息比较陈旧,它只有第一次level 0 备份的信息:

RMAN> list backup;  List of Backup Sets===================  BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------7       Incr 0  1.00G      DISK        00:00:13     20210403_07:07:31        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/06vrbk56_1_1  List of Datafiles in backup set 7  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------8       Incr 0  9.36M      DISK        00:00:01     20210403_07:07:34        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/07vrbk5l_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991827       Ckp time: 20210403_07:07:33 RMAN> list archivelog all; specification does not match any archived log in the repository RMAN>

 执行 restore 操作:


RMAN> restore database; Starting restore at 20210403_07:26:13allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=1 device type=DISK channel ORA_DISK_1: starting datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_DISK_1: restoring datafile 00001 to /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbfchannel ORA_DISK_1: restoring datafile 00002 to /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbfchannel ORA_DISK_1: restoring datafile 00003 to /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbfchannel ORA_DISK_1: restoring datafile 00004 to /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbfchannel ORA_DISK_1: reading from backup piece /refresh/home/bak00/06vrbk56_1_1channel ORA_DISK_1: piece handle=/refresh/home/bak00/06vrbk56_1_1 tag=TAG20210403T070718channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:07Finished restore at 20210403_07:26:21 RMAN>

然后,我开始把第一回的 level 1 增分备份信息注册回来,执行 recover database:


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/0avrbk9i_1_1File Name: /refresh/home/bak01/control.bksFile Name: /refresh/home/bak01/09vrbk9h_1_1 Do you really want to catalog the above files (enter YES or NO)? yescataloging files...cataloging done List of Cataloged Files=======================File Name: /refresh/home/bak01/0avrbk9i_1_1File Name: /refresh/home/bak01/control.bksFile Name: /refresh/home/bak01/09vrbk9h_1_1

 可以看到,备份的信息增加了:

RMAN> list backup; List of Backup Sets=================== BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------7       Incr 0  1.00G      DISK        00:00:13     20210403_07:07:31        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/06vrbk56_1_1  List of Datafiles in backup set 7  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------8       Incr 0  9.36M      DISK        00:00:01     20210403_07:07:34        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/07vrbk5l_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991827       Ckp time: 20210403_07:07:33 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------9       Incr 1  9.36M      DISK        00:00:00     20210403_07:09:38        BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070936        Piece Name: /refresh/home/bak01/0avrbk9i_1_1  SPFILE Included: Modification time: 20210403_06:50:46  SPFILE db_unique_name: ORCL11204  Control File Included: Ckp SCN: 991965       Ckp time: 20210403_07:09:37 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------10      Full    9.33M      DISK        00:00:00     20210403_06:29:06        BP Key: 10   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T062906        Piece Name: /refresh/home/bak01/control.bks  Control File Included: Ckp SCN: 989812       Ckp time: 20210403_06:29:06 BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------11      Incr 1  9.84M      DISK        00:00:00     20210403_07:09:37        BP Key: 11   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070936        Piece Name: /refresh/home/bak01/09vrbk9h_1_1  List of Datafiles in backup set 11  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    1  Incr 991965     20210403_07:09:37 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf RMAN> list archivelog all; specification does not match any archived log in the repository RMAN>

 那么,我可以进行第一次的 recover database 的操作了:

RMAN> recover database; Starting recover at 20210403_07:27:21using channel ORA_DISK_1channel ORA_DISK_1: starting incremental datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setdestination for restore of datafile 00001: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbfdestination for restore of datafile 00002: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbfdestination for restore of datafile 00003: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbfdestination for restore of datafile 00004: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbfchannel ORA_DISK_1: reading from backup piece /refresh/home/bak01/09vrbk9h_1_1channel ORA_DISK_1: piece handle=/refresh/home/bak01/09vrbk9h_1_1 tag=TAG20210403T070936channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 starting media recovery unable to find archived logarchived log thread=1 sequence=1RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 04/03/2021 07:27:23RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1 and starting SCN of 991848 RMAN>


出 warnnig 其实很正常,因为只要不是指定 set until time/scn/archive log, Oracle 肯定要往下一直找 archive log的。


recover database 的执行过程,确实用到了第一回 level 1 增分备份的备份集合:09vrbk9h_1_1。


但是注意看我的 level 0 的备份信息的 Ckp Time:

BS Key  Type LV Size       Device Type Elapsed Time Completion Time------- ---- -- ---------- ----------- ------------ -----------------7       Incr 0  1.00G      DISK        00:00:13     20210403_07:07:31        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20210403T070718        Piece Name: /refresh/home/bak00/06vrbk56_1_1  List of Datafiles in backup set 7  File LV Type Ckp SCN    Ckp Time          Name  ---- -- ---- ---------- ----------------- ----  1    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbf  2    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbf  3    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbf  4    0  Incr 991822     20210403_07:07:18 /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbf

 

Level 0 备份当时的 log 显示:

channel ORA_DISK_1: starting piece 1 at 20210403_07:07:18channel ORA_DISK_1: finished piece 1 at 20210403_07:07:33


可以近似地认为,Level 0 备份,包含了 07:07:18开始,截止至 07:07:33 的内容。


而 archive log 的信息显示:


Key     Thrd Seq     S Low Time------- ---- ------- - -----------------3       1    1       A 20210403_06:50:09        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_1_1068879009.dbf 4       1    2       A 20210403_07:10:22        Name: /refresh/home/app/11.2.0.4/oracle/product/11.2.0.4/dbhome_4/dbs/arch1_2_1068879009.dbf

 

thread 1 with sequence 1 的 archive log,它包含的变更内容的时间范围涵盖 06:50:09 -- 07:10:22。


我执行了 level 1 的增分备份所对应的那一部分 recover databse,然而 rman 似乎只记得 第一次 level 0 增分时的状况,它在向我要求:thread 1 with sequence 1 的 archive log !换句话说,数据库无视了已经利用Level 1 增分备份的执行成功的状况,它仍然在寻找用从 Level 0 备份执行 restore database 之后的 SCN 来计算的内容。


为了看得更清楚一些,再把第二回 level 1 增分备份注册,然后执行 restore database:

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/0bvrbkfp_1_1File Name: /refresh/home/bak02/0cvrbkfq_1_1 Do you really want to catalog the above files (enter YES or NO)? yescataloging files...cataloging done List of Cataloged Files=======================File Name: /refresh/home/bak02/0bvrbkfp_1_1File Name: /refresh/home/bak02/0cvrbkfq_1_1 RMAN> recover database; Starting recover at 20210403_07:28:26using channel ORA_DISK_1channel ORA_DISK_1: starting incremental datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setdestination for restore of datafile 00001: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbfdestination for restore of datafile 00002: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbfdestination for restore of datafile 00003: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbfdestination for restore of datafile 00004: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbfchannel ORA_DISK_1: reading from backup piece /refresh/home/bak02/0bvrbkfp_1_1channel ORA_DISK_1: piece handle=/refresh/home/bak02/0bvrbkfp_1_1 tag=TAG20210403T071257channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 starting media recovery unable to find archived logarchived log thread=1 sequence=1RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 04/03/2021 07:28:28RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1 and starting SCN of 991848 RMAN>

 仍然没有变化,还在要 archived log for thread 1 with sequence 1 !


再把第三回的 level 1 增分备份注册上来:

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/0evrbkld_1_1File Name: /refresh/home/bak03/0dvrbklc_1_1 Do you really want to catalog the above files (enter YES or NO)? yescataloging files...cataloging done List of Cataloged Files=======================File Name: /refresh/home/bak03/0evrbkld_1_1File Name: /refresh/home/bak03/0dvrbklc_1_1 RMAN> recover database; Starting recover at 20210403_07:30:19using channel ORA_DISK_1channel ORA_DISK_1: starting incremental datafile backup set restorechannel ORA_DISK_1: specifying datafile(s) to restore from backup setdestination for restore of datafile 00001: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/system01.dbfdestination for restore of datafile 00002: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/sysaux01.dbfdestination for restore of datafile 00003: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/undotbs01.dbfdestination for restore of datafile 00004: /refresh/home/app/11.2.0.4/oracle/oradata/orcl11204/users01.dbfchannel ORA_DISK_1: reading from backup piece /refresh/home/bak03/0dvrbklc_1_1channel ORA_DISK_1: piece handle=/refresh/home/bak03/0dvrbklc_1_1 tag=TAG20210403T071555channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:01 starting media recovery unable to find archived logarchived log thread=1 sequence=1RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 04/03/2021 07:30:20RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 1 and starting SCN of 991848 RMAN>

 结果仍然没有改变。通过 SQL ,看看 v$datafile,和 v$dataile_header,可以看出问题来:

SQL> alter session set nls_date_format='yyyymmdd_hh24:mi:ss'; Session altered. SQL> select file#,checkpoint_change#,checkpoint_time from v$datafile;      FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME---------- ------------------ -----------------         1             991822 20210403_07:07:18 ***         2             991822 20210403_07:07:18 ***         3             991822 20210403_07:07:18 ***         4             991822 20210403_07:07:18 *** SQL> SQL> select file#,checkpoint_change#,checkpoint_time from v$datafile_header;      FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME---------- ------------------ -----------------         1             992322 20210403_07:15:56         2             992322 20210403_07:15:56         3             992322 20210403_07:15:56         4             992322 20210403_07:15:56 SQL>

 

       v$datafile 反映的是 controlfile 中的结果,而 v$datafile_header 反映的是数据文件中的实际情况。虽然,我每一次的 recover database 都改变了 datafile,但是由于我已经执行过了 restore database,数据库就以执行 restore database 时,它的控制文件中记录的内容,来决定要哪些 archive log。没办法了,只好注册所有的 archive log, 再次执行 recover database。


RMAN> catalog start with '/refresh/home/arc'; using target database control file instead of recovery catalogsearching for all files that match the pattern /refresh/home/arc List of Files Unknown to the Database=====================================File Name: /refresh/home/arc/arch1_2_1068879009.dbfFile Name: /refresh/home/arc/arch1_7_1068879009.dbfFile Name: /refresh/home/arc/arch1_5_1068879009.dbfFile Name: /refresh/home/arc/arch1_4_1068879009.dbfFile Name: /refresh/home/arc/arch1_3_1068879009.dbfFile Name: /refresh/home/arc/arch1_1_1068879009.dbfFile Name: /refresh/home/arc/arch1_6_1068879009.dbf Do you really want to catalog the above files (enter YES or NO)? yescataloging files...cataloging done List of Cataloged Files=======================File Name: /refresh/home/arc/arch1_2_1068879009.dbfFile Name: /refresh/home/arc/arch1_7_1068879009.dbfFile Name: /refresh/home/arc/arch1_5_1068879009.dbfFile Name: /refresh/home/arc/arch1_4_1068879009.dbfFile Name: /refresh/home/arc/arch1_3_1068879009.dbfFile Name: /refresh/home/arc/arch1_1_1068879009.dbfFile Name: /refresh/home/arc/arch1_6_1068879009.dbf RMAN> list archivelog all; List of Archived Log Copies for database with db_unique_name ORCL11204===================================================================== Key     Thrd Seq     S Low Time------- ---- ------- - -----------------8       1    1       A 20210403_06:50:09        Name: /refresh/home/arc/arch1_1_1068879009.dbf 3       1    2       A 20210403_07:10:22        Name: /refresh/home/arc/arch1_2_1068879009.dbf 7       1    3       A 20210403_07:10:28        Name: /refresh/home/arc/arch1_3_1068879009.dbf 6       1    4       A 20210403_07:13:37        Name: /refresh/home/arc/arch1_4_1068879009.dbf 5       1    5       A 20210403_07:13:41        Name: /refresh/home/arc/arch1_5_1068879009.dbf 9       1    6       A 20210403_07:16:41        Name: /refresh/home/arc/arch1_6_1068879009.dbf 4       1    7       A 20210403_07:16:46        Name: /refresh/home/arc/arch1_7_1068879009.dbf  RMAN> recover database; Starting recover at 20210403_07:37:40allocated channel: ORA_DISK_1channel ORA_DISK_1: SID=19 device type=DISK starting media recovery archived log for thread 1 with sequence 1 is already on disk as file /refresh/home/arc/arch1_1_1068879009.dbfarchived log for thread 1 with sequence 2 is already on disk as file /refresh/home/arc/arch1_2_1068879009.dbfarchived log for thread 1 with sequence 3 is already on disk as file /refresh/home/arc/arch1_3_1068879009.dbfarchived log for thread 1 with sequence 4 is already on disk as file /refresh/home/arc/arch1_4_1068879009.dbfarchived log for thread 1 with sequence 5 is already on disk as file /refresh/home/arc/arch1_5_1068879009.dbfarchived log for thread 1 with sequence 6 is already on disk as file /refresh/home/arc/arch1_6_1068879009.dbfarchived log for thread 1 with sequence 7 is already on disk as file /refresh/home/arc/arch1_7_1068879009.dbfarchived log file name=/refresh/home/arc/arch1_1_1068879009.dbf thread=1 sequence=1archived log file name=/refresh/home/arc/arch1_2_1068879009.dbf thread=1 sequence=2archived log file name=/refresh/home/arc/arch1_3_1068879009.dbf thread=1 sequence=3archived log file name=/refresh/home/arc/arch1_4_1068879009.dbf thread=1 sequence=4archived log file name=/refresh/home/arc/arch1_5_1068879009.dbf thread=1 sequence=5archived log file name=/refresh/home/arc/arch1_6_1068879009.dbf thread=1 sequence=6archived log file name=/refresh/home/arc/arch1_7_1068879009.dbf thread=1 sequence=7unable to find archived logarchived log thread=1 sequence=8RMAN-00571: ===========================================================RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============RMAN-00571: ===========================================================RMAN-03002: failure of recover command at 04/03/2021 07:37:41RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 8 and starting SCN of 992471 RMAN>  RMAN> alter database open resetlogs; database opened RMAN>  SQL> alter session set nls_date_format='yyyymmdd_hh24:mi:ss'; Session altered. SQL> select file#,checkpoint_change#,checkpoint_time from v$datafile;      FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME---------- ------------------ -----------------         1             992475 20210403_07:38:25         2             992475 20210403_07:38:25         3             992475 20210403_07:38:25         4             992475 20210403_07:38:25 SQL> select file#,checkpoint_change#,checkpoint_time from v$datafile_header;      FILE# CHECKPOINT_CHANGE# CHECKPOINT_TIME---------- ------------------ -----------------         1             992475 20210403_07:38:25         2             992475 20210403_07:38:25         3             992475 20210403_07:38:25         4             992475 20210403_07:38:25 SQL>

我真的失败了吗?其实也没有,只要我保留最新的控制文件,再来多次执行 recover database, 不就可以成功了吗?换句话说,在两个机器之间,我执行最后一次 recover 之前,我把 source 端的控制文件备份出来,恢复到 dest 端,由于它包含了全部的备份新,我再执行 recover ,应该可以成功的。

请拭目以待我的下一次两个机器之间的备份恢复试验。


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

——End——


专注于技术不限于技术!

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

欢迎关注!


Hands On:(常用命令&小技巧)

手动创建数据库及创建过程遇到的错误(踩到的坑)

数据库管理和维护常用操作和命令

RMAN相关基础操作

【常用命令】修改数据库字符集(仅供测试使用)

【常用命令】监视数据库的用户登录和注销会话信息

【常用命令】自动统计收集的停止(无效)和启动(有效)

【常用命令】获取数据库对象的定义(DDL)

【常用命令】修改数据库字符集(仅供测试使用)

【怎么办001】DROP USER ... CASCADE特别慢怎么办?

【怎么办002】想要获取数据库对象的定义(DDL)怎么办

【怎么办】003 如何加强Oracle数据库安全--监控数据导入导出操作

【怎么办】004 如何找到删库跑路的人--监控数据库用户登录

SQL*PLUS技巧:生成易读的HTML报表


原文作者:SQL和数据库技术;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论

注册时间:2017-07-21

  • 博文量
    107
  • 访问量
    63572