ITPub博客

首页 > Linux操作系统 > Linux操作系统 > 冷备控制文件 & Using Backup Controlfile

冷备控制文件 & Using Backup Controlfile

原创 Linux操作系统 作者:westzq1984 时间:2013-06-25 19:49:59 0 删除 编辑

sqlplus命令的recover databaseusing backup controlfile子句的意义,就是告诉恢复进程,控制文件不是最新的,控制文件中也没有包含最新的日志信息,需要指定归档的位置给恢复进程,让其恢复,直到达到指定的位置或者其发现当前是最后的重做条目

 

rman的recover database原则上封装了using backup controlfile,其能够自动判断,但是有一个除外:冷备的控制文件

 

冷备份的控制文件在恢复上简直就是个坑,轻则报个莫名其妙的错误,重则少恢复数据,数据丢失。

 

情况一:

ABORT数据库,CP一个以前的冷备控制文件过来启库做恢复

当前 控制文件中SCN < 数据文件头SCN

 

SQL> recover database;

ORA-00283: recovery session canceled due to errors

ORA-01122: database file 1 failed verification check

ORA-01110: data file 1: '/u01/app/oracle/oradata/o11203/system01.dbf'

ORA-01207: file is more recent than control file - old control file

 

RMAN> recover database;

 

Starting recover at 2013-06-25 15:47:52

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=96 device type=DISK

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

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

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

RMAN-03002: failure of recover command at 06/25/2013 15:47:54

RMAN-06094: datafile 1 must be restored

 

这个时候,就算从以前的备份中RESTORE了数据库,还是无法RECOVER,一样的报错。

这种情况下,很容易让人产生困惑

 

情况二:

ABORT数据库,CP以前数据库&控制文件冷备恢复,企图外加后面的归档恢复到最近状态

当前 控制文件中SCN = 数据文件头SCN

 

SQL> recover database;

ORA-00283: recovery session canceled due to errors

ORA-00264: no recovery required

 

RMAN> recover database;

 

Starting recover at 2013-06-25 15:52:28

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=96 device type=DISK

 

starting media recovery

media recovery complete, elapsed time: 00:00:02

 

Finished recover at 2013-06-25 15:52:30

 

Tue Jun 25 15:52:28 2013

alter database recover datafile list clear

Completed: alter database recover datafile list clear

alter database recover datafile list

 1 , 2 , 3 , 4 , 5

Completed: alter database recover datafile list

 1 , 2 , 3 , 4 , 5

alter database recover if needed

 start

Media Recovery Start

 started logmerger process

Tue Jun 25 15:52:28 2013

Slave exiting with ORA-264 exception

Errors in file /u01/app/oracle/diag/rdbms/o11203/o11203/trace/o11203_pr00_14769.trc:

ORA-00264: no recovery required

Recovery Slave PR00 previously exited with exception 264

ORA-264 signalled during: alter database recover if needed

 start

...

 

SQL恢复报错提示无需恢复,RMAN恢复正常,但是ALERT日志也显示无需恢复

就算把后续的归档catalog进去,也不会去进行恢复

这种情况下,RMAN没有任何报错,很容易让人以为已经成功以用了归档,如果没有监控alert日志,一旦open resetlogs了,后果就比较严重了

 

情况三

先创建一张表,然后abort

CP一个冷备的控制文件,以及在备份控制文件前一次备份的数据文件

看能否恢复到最新

当前 控制文件中SCN > 数据文件头SCN

 

SQL> recover database;

ORA-00279: change 4154720 generated at 06/25/2013 15:41:52 needed for thread 1

ORA-00289: suggestion :

/u01/app/oracle/fast_recovery_area/O11203/archivelog/2013_06_25/o1_mf_1_1_8wlp1v

72_.arc

ORA-00280: change 4154720 for thread 1 is in sequence #1

 

 

Specify log: {=suggested | filename | AUTO | CANCEL}

auto

ORA-00279: change 4154848 generated at 06/25/2013 15:43:39 needed for thread 1

ORA-00289: suggestion :

/u01/app/oracle/fast_recovery_area/O11203/archivelog/2013_06_25/o1_mf_1_2_8wlp1v

79_.arc

ORA-00280: change 4154848 for thread 1 is in sequence #2

 

Log applied.

Media recovery complete.

 

SQL>  alter database open read only;

 

Database altered.

 

SQL> select *from ctais2.test_reco1;

select *from ctais2.test_reco1

                    *

ERROR at line 1:

ORA-00942: table or view does not exist

 

可以看到,表是没有恢复出来的。

再次执行recover

SQL> recover database;

ORA-00283: recovery session canceled due to errors

ORA-01124: cannot recover data file 1 - file is in use or recovery

ORA-01110: data file 1: '/u01/app/oracle/oradata/o11203/system01.dbf'

 

RMAN> recover database;

 

Starting recover at 2013-06-25 18:13:42

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: SID=222 device type=DISK

 

starting media recovery

media recovery failed

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

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

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

RMAN-03002: failure of recover command at 06/25/2013 18:13:44

ORA-00283: recovery session canceled due to errors

RMAN-11003: failure during parse/execution of SQL statement: alter database recover if needed

 start

ORA-00283: recovery session canceled due to errors

ORA-01124: cannot recover data file 1 - file is in use or recovery

ORA-01110: data file 1: '/u01/app/oracle/oradata/o11203/system01.dbf'

 

在使用了冷备控制文件来恢复的情况下,要完成恢复,解决的办法只有一个:

recover database using backup controlfile;

 

否则,就要考虑重建控制文件,或者找一个热备的控制文件副本

 

从实验的结果来看:

1.   冷备的控制文件,如果不使用using backup controlfilerecover,那么控制文件中的db ckpt scn就是恢复的终点

2.   RMAN的RECOVER无法绕过冷备控制文件的这种限制

 

如何判断一个控制文件备份,是否是一个正常shutdown情况下的副本?很简单,看线程是否都CLOSED

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/8242091/viewspace-764803/,如需转载,请注明出处,否则将追究法律责任。

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

注册时间:2009-04-06

  • 博文量
    251
  • 访问量
    965371