Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1278306
  • 博文数量: 1211
  • 博客积分: 10010
  • 博客等级: 上将
  • 技术积分: 14340
  • 用 户 组: 普通用户
  • 注册时间: 2008-06-09 11:20
文章分类

全部博文(1211)

文章存档

2011年(1)

2008年(1210)

我的朋友

分类: 服务器与存储

2008-06-16 19:04:00

在Nocatalog的情况下,硬盘上的Rman备份集在使用一次后,控制文件发生了变化。

不但备份集中控制文件的文件时间发生了变化,我猜想内容也发生了变化。

之后再次使用这个备份集进行恢复操作,遇到错误。

本文记录了这个过程,以及如何解决。



恢复orapw文件 :

[@shdemo1 dbs]$ orapwd file=orapwdevb password=123456 entries=20
[@shdemo1 dbs]$
[@shdemo1 dbs]$ sqlplus /nolog

SQL*Plus: Release 9.2.0.4.0 - Production on Wed May 10 15:54:49 2006

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

SQL> conn sys/123456@devb as sysdba
Connected to an idle instance.
SQL> startup nomount
ORA-01031: insufficient privileges
SQL>
SQL> disc
Disconnected
SQL> conn / as sysdba
Connected to an idle instance.
SQL>
SQL> startup nomount
ORACLE instance started.

Total System Global Area   42742804 bytes
Fixed Size                   451604 bytes
Variable Size              41943040 bytes
Database Buffers             204800 bytes
Redo Buffers                 143360 bytes
SQL>


恢复 spfile:

[@shdemo1 devb]$ rman nocatalog

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

RMAN> connect target

connected to target database: devb (not mounted)
using target database controlfile instead of recovery catalog

RMAN> set DBID=1179520070

executing command: SET DBID

RMAN> restore spfile from autobackup;

Starting restore at 10-MAY-06

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=10 devtype=DISK
channel ORA_DISK_1: looking for autobackup on day: 20060510
channel ORA_DISK_1: looking for autobackup on day: 20060509
channel ORA_DISK_1: looking for autobackup on day: 20060508
channel ORA_DISK_1: looking for autobackup on day: 20060507
channel ORA_DISK_1: looking for autobackup on day: 20060506
channel ORA_DISK_1: looking for autobackup on day: 20060505
channel ORA_DISK_1: looking for autobackup on day: 20060504
channel ORA_DISK_1: no autobackup in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/10/2006 15:57:57
RMAN-06172: no autobackup found or specified handle is not a valid copy or piece

RMAN> restore spfile from '/home//backup/devb/c-1179520070-20060510-05';

Starting restore at 10-MAY-06

using channel ORA_DISK_1
channel ORA_DISK_1: autobackup found: /home//backup/devb/c-1179520070-20060510-05
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 10-MAY-06

RMAN>
恢复control file:

SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup nomount
ORACLE instance started.

Total System Global Area  236000356 bytes
Fixed Size                   451684 bytes
Variable Size             201326592 bytes
Database Buffers           33554432 bytes
Redo Buffers                 667648 bytes
SQL>

[@shdemo1 devb]$
[@shdemo1 devb]$
[@shdemo1 devb]$ rman nocatalog

Recovery Manager: Release 9.2.0.4.0 - Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

RMAN> connect target

connected to target database: devb (not mounted)
using target database controlfile instead of recovery catalog

RMAN> set DBID=1179520070

executing command: SET DBID

RMAN> restore controlfile from '/home//backup/devb/c-1179520070-20060510-05';

Starting restore at 10-MAY-06

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=14 devtype=DISK
channel ORA_DISK_1: restoring controlfile
channel ORA_DISK_1: restore complete
replicating controlfile
input filename=/usr/app//oradata/devb/control01.ctl
output filename=/usr/app//oradata/devb/control02.ctl
output filename=/usr/app//oradata/devb/control03.ctl
Finished restore at 10-MAY-06

RMAN> restore database;
.....


RMAN>alter database open resetlogs;

数据库恢复完毕。


使用RMAN恢复,打开数据库使用alter database open resetlogs;

此备份放在硬盘上,只有一份。
此时做试验,将数据库相关文件全部删除后试图用RMAN再次恢复,结果:

spfile 和 controlfile 可以恢复,但是数据文件无法恢复了:
如下所示:

RMAN> restore database;

Starting restore at 10-MAY-06

allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=14 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 05/10/2006 16:21:43
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 10 found to restore
RMAN-06023: no backup or copy of datafile 9 found to restore
RMAN-06023: no backup or copy of datafile 8 found to restore
RMAN-06023: no backup or copy of datafile 7 found to restore
RMAN-06023: no backup or copy of datafile 6 found to restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore

网上查了一下,原来在尝试恢复中使用了_allow_resetlogs_corruption参数,resetlogs之后,Oracle使用当前的控制文件不允许从这个历史备份集中进行恢复。
由于我没有使用catalog,所以尝试使用dbms_backup_restore进行恢复。



[@shdemo1 devb]$ sqlplus /nolog

SQL*Plus: Release 9.2.0.4.0 - Production on Wed May 10 16:29:26 2006

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

SQL>
SQL> shutdown immediate
ORA-01012: not logged on
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area  236000356 bytes
Fixed Size                   451684 bytes
Variable Size             201326592 bytes
Database Buffers           33554432 bytes
Redo Buffers                 667648 bytes
SQL> DECLARE
  2   devtype varchar2(256);
  3   done boolean;
  4   BEGIN
  5   devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');
  6   sys.dbms_backup_restore.restoreSetDatafile;
  7     sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>01,  toname=>'/usr/app//oradata/devb/system01.dbf');
  8    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>02,  toname=>'/usr/app//oradata/devb/undotbs01.dbf');
  9    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>03,  toname=>'/usr/app//oradata/devb/cwmlite01.dbf');
10    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>04,  toname=>'/usr/app//oradata/devb/drsys01.dbf');
11    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>05,  toname=>'/usr/app//oradata/devb/example01.dbf');
12    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>06,  toname=>'/usr/app//oradata/devb/indx01.dbf');
13    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>07,  toname=>'/usr/app//oradata/devb/odm01.dbf');
14    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>08,  toname=>'/usr/app//oradata/devb/tools01.dbf');
15    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>09,  toname=>'/usr/app//oradata/devb/users01.dbf');
16    sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>10,  toname=>'/usr/app//oradata/devb/xdb01.dbf');
17   sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/home//backup/devb/df_DEVB_43_1_1.bak', params=>null);
18   sys.dbms_backup_restore.deviceDeallocate;
19  END;
20  /

PL/SQL procedure successfully completed.

SQL> alter database mount;

Database altered.

SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done


SQL> recover database using backup controlfile until cancel;
ORA-00283: recovery session canceled due to errors
ORA-01190: controlfile or data file 1 is from before the last RESETLOGS
ORA-01110: data file 1: '/usr/app//oradata/devb/system01.dbf'


SQL>
SQL>
SQL>
SQL>      
SQL> alter database backup controlfile to trace;

Database altered.

SQL>

原来的controlfile 已不能使用,所以重建controlfile;

trace文件在 user_dump_desc 下。即 /usr/app//admin/devb/udump
                                                
找到最新的trc文件
                                                
SQL>
SQL> shutdown immediate
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area  236000356 bytes
Fixed Size                   451684 bytes
Variable Size             201326592 bytes
Database Buffers           33554432 bytes
Redo Buffers                 667648 bytes
SQL>
SQL> CREATE CONTROLFILE REUSE DATABASE "DEVB" RESETLOGS  ARCHIVELOG
  2  --  SET STANDBY TO MAXIMIZE PERFORMANCE
  3      MAXLOGFILES 50
  4      MAXLOGMEMBERS 5
  5      MAXDATAFILES 100
  6      MAXINSTANCES 1
  7      MAXLOGHISTORY 226
  8  LOGFILE
  9    GROUP 1 '/usr/app//oradata/devb/redo01.log'  SIZE 100M,
10    GROUP 2 '/usr/app//oradata/devb/redo02.log'  SIZE 100M,
11    GROUP 3 '/usr/app//oradata/devb/redo03.log'  SIZE 100M
12  -- STANDBY LOGFILE
13  DATAFILE
14    '/usr/app//oradata/devb/system01.dbf',
15    '/usr/app//oradata/devb/undotbs01.dbf',
16    '/usr/app//oradata/devb/cwmlite01.dbf',
17    '/usr/app//oradata/devb/drsys01.dbf',
18    '/usr/app//oradata/devb/example01.dbf',
19    '/usr/app//oradata/devb/indx01.dbf',
20    '/usr/app//oradata/devb/odm01.dbf',
21    '/usr/app//oradata/devb/tools01.dbf',
22    '/usr/app//oradata/devb/users01.dbf',
23    '/usr/app//oradata/devb/xdb01.dbf'
24  CHARACTER SET ZHS16GBK
25  ;

Control file created.

SQL> recover database;
ORA-00283: recovery session canceled due to errors
ORA-01610: recovery using the BACKUP CONTROLFILE option must be done


SQL> recover database using backup controlfile until cancel;
ORA-00279: change 20469549 generated at 05/10/2006 11:52:29 needed for thread 1
ORA-00289: suggestion : /usr/app//product/9.2.0.4/dbs/arch1_3.dbf
ORA-00280: change 20469549 for thread 1 is in sequence #3


Specify log: {=suggested | filename | AUTO | CANCEL}
CANCEL
Media recovery cancelled.
SQL>
SQL> alter database open resetlogs;

Database altered.

SQL>


阅读(552) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~