使用dbms_backup_restore进行全库恢复

在备份集无法restore的情况下,使用dbms_backup_restore包在nomount状态下restore数据文件,然后恢复数据库。[@more@]

[oracle@primary dbs]$ rman target /

Recovery Manager: Release 10.2.0.5.0 - Production on Sun Dec 2 15:18:58 2012

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

connected to target database: dbwdn (not mounted)

RMAN> run
2> {
3> allocate channel t1 device type disk;
4> restore database from '0vnrrptr_1_1.bak';
5> release channel t1;
6> }

using target database control file instead of recovery catalog
allocated channel: t1
channel t1: sid=156 devtype=DISK

Starting restore at 02-DEC-2012 15:20:18

released channel: t1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/02/2012 15:20:18
RMAN-06172: no autobackup found or specified handle is not a valid copy or piece

RMAN> run
2> allocate channel t1 device type disk;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "allocate": expecting one of: "{"
RMAN-01007: at line 2 column 1 file: standard input

RMAN> run
2> {
3> allocate channel t1 device type disk;
4> restore database from '0unrrps4_1_1.bak';
5> release channel t1;
6> }

allocated channel: t1
channel t1: sid=156 devtype=DISK

Starting restore at 02-DEC-2012 15:21:05

released channel: t1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 12/02/2012 15:21:06
RMAN-06172: no autobackup found or specified handle is not a valid copy or piece
竟然无法restore数据文件,从备份集中。

采用dbms_backup_restore 还原数据文件:

[oracle@primary dbwdn]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sun Dec 2 16:45:47 2012

Copyright (c) 1982, 2010, Oracle. All Rights Reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 285212672 bytes
Fixed Size 1273276 bytes
Variable Size 130024004 bytes
Database Buffers 150994944 bytes
Redo Buffers 2920448 bytes
SQL> DECLARE
devtype varchar2(256);
done boolean;
BEGIN
devtype:=sys.dbms_backup_restore.deviceAllocate (type=>'',ident=>'t1');
sys.dbms_backup_restore.restoreSetDatafile;
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>01,toname=>'/u01/app/oracle/oradata/dbwdn/system01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>02,toname=>'/u01/app/oracle/oradata/dbwdn/undotbs01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>03,toname=>'/u01/app/oracle/oradata/dbwdn/sysaux01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>04,toname=>'/u01/app/oracle/oradata/dbwdn/users01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>05,toname=>'/u01/app/oracle/oradata/dbwdn/test01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>06,toname=>'/u01/app/oracle/oradata/dbwdn/ggs01.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>07,toname=>'/u01/app/oracle/oradata/dbwdn/perfstat.dbf');
sys.dbms_backup_restore.restoreDatafileTo(dfnumber=>08,toname=>'/u01/app/oracle/oradata/dbwdn/shkz_data_01.dbf');
sys.dbms_backup_restore.restoreBackupPiece(done=>done,handle=>'/u01/bak/0unrrps4_1_1.bak', params=>null);
sys.dbms_backup_restore.deviceDeallocate;
END;
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 /

PL/SQL procedure successfully completed.

数据文件已经restore了。

查看alter.log信息:

Sun Dec 02 16:46:29 EST 2012
Full restore complete of datafile 8 to datafile copy /u01/app/oracle/oradata/dbwdn/shkz_data_01.dbf. Elapsed time: 0:00:02
checkpoint is 5045567

Full restore complete of datafile 6 to datafile copy /u01/app/oracle/oradata/dbwdn/ggs01.dbf. Elapsed time: 0:00:04
checkpoint is 5045567

Full restore complete of datafile 5 to datafile copy /u01/app/oracle/oradata/dbwdn/test01.dbf. Elapsed time: 0:00:04
checkpoint is 5045567

Full restore complete of datafile 4 to datafile copy /u01/app/oracle/oradata/dbwdn/users01.dbf. Elapsed time: 0:00:06
checkpoint is 5045567

last deallocation scn is 4728311
Full restore complete of datafile 2 to datafile copy /u01/app/oracle/oradata/dbwdn/undotbs01.dbf. Elapsed time: 0:00:10
checkpoint is 5045567

last deallocation scn is 5019187
Sun Dec 02 16:46:51 EST 2012
Full restore complete of datafile 3 to datafile copy /u01/app/oracle/oradata/dbwdn/sysaux01.dbf. Elapsed time: 0:00:26
checkpoint is 5045567

last deallocation scn is 4793031
Sun Dec 02 16:47:09 EST 2012
Full restore complete of datafile 1 to datafile copy /u01/app/oracle/oradata/dbwdn/system01.dbf. Elapsed time: 0:00:41
checkpoint is 5045567

last deallocation scn is 4847543
Full restore complete of datafile 7 to datafile copy /u01/app/oracle/oradata/dbwdn/perfstat.dbf. Elapsed time: 0:00:49
checkpoint is 5045567

Sun Dec 02 16:52:30 EST 2012

上面标示黑体的SCN,就是数据库备份集的备份时刻的SCN,数据库恢复从这里开始,SCN 5045567

因为控制文件也丢失,我这里是重建控制文件,这一步骤简单,我就略过了。

下面是恢复数据库:

[oracle@primary dbwdn]$ sqlplus "/as sysdba"

SQL*Plus: Release 10.2.0.5.0 - Production on Sun Dec 2 16:57:05 2012

Copyright (c) 1982, 2010, Oracle. All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> alter database mount;
alter database mount
*
ERROR at line 1:
ORA-01100: database already mounted


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 5045567 generated at 12/02/2012 12:58:44 needed for thread 1
ORA-00289: suggestion : /archivelog/1_5_800974340.dbf
ORA-00280: change 5045567 for thread 1 is in sequence #5


Specify log: {=suggested | filename | AUTO | CANCEL}
/archivelog/1_5_800974340.dbf
ORA-00279: change 5045811 generated at 12/02/2012 13:04:02 needed for thread 1
ORA-00289: suggestion : /archivelog/1_6_800974340.dbf
ORA-00280: change 5045811 for thread 1 is in sequence #6
ORA-00278: log file '/archivelog/1_5_800974340.dbf' no longer needed for this
recovery


Specify log: {=suggested | filename | AUTO | CANCEL}
AUTO
ORA-00279: change 5045817 generated at 12/02/2012 13:04:15 needed for thread 1
ORA-00289: suggestion : /archivelog/1_7_800974340.dbf
ORA-00280: change 5045817 for thread 1 is in sequence #7
ORA-00278: log file '/archivelog/1_6_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5045820 generated at 12/02/2012 13:04:21 needed for thread 1
ORA-00289: suggestion : /archivelog/1_8_800974340.dbf
ORA-00280: change 5045820 for thread 1 is in sequence #8
ORA-00278: log file '/archivelog/1_7_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5045822 generated at 12/02/2012 13:04:21 needed for thread 1
ORA-00289: suggestion : /archivelog/1_9_800974340.dbf
ORA-00280: change 5045822 for thread 1 is in sequence #9
ORA-00278: log file '/archivelog/1_8_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5045824 generated at 12/02/2012 13:04:24 needed for thread 1
ORA-00289: suggestion : /archivelog/1_10_800974340.dbf
ORA-00280: change 5045824 for thread 1 is in sequence #10
ORA-00278: log file '/archivelog/1_9_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5050999 generated at 12/02/2012 14:47:33 needed for thread 1
ORA-00289: suggestion : /archivelog/1_11_800974340.dbf
ORA-00280: change 5050999 for thread 1 is in sequence #11
ORA-00278: log file '/archivelog/1_10_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5051002 generated at 12/02/2012 14:47:35 needed for thread 1
ORA-00289: suggestion : /archivelog/1_12_800974340.dbf
ORA-00280: change 5051002 for thread 1 is in sequence #12
ORA-00278: log file '/archivelog/1_11_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5051006 generated at 12/02/2012 14:47:39 needed for thread 1
ORA-00289: suggestion : /archivelog/1_13_800974340.dbf
ORA-00280: change 5051006 for thread 1 is in sequence #13
ORA-00278: log file '/archivelog/1_12_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5051009 generated at 12/02/2012 14:47:39 needed for thread 1
ORA-00289: suggestion : /archivelog/1_14_800974340.dbf
ORA-00280: change 5051009 for thread 1 is in sequence #14
ORA-00278: log file '/archivelog/1_13_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5051012 generated at 12/02/2012 14:47:39 needed for thread 1
ORA-00289: suggestion : /archivelog/1_15_800974340.dbf
ORA-00280: change 5051012 for thread 1 is in sequence #15
ORA-00278: log file '/archivelog/1_14_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5051015 generated at 12/02/2012 14:47:40 needed for thread 1
ORA-00289: suggestion : /archivelog/1_16_800974340.dbf
ORA-00280: change 5051015 for thread 1 is in sequence #16
ORA-00278: log file '/archivelog/1_15_800974340.dbf' no longer needed for this
recovery


ORA-00279: change 5051018 generated at 12/02/2012 14:47:42 needed for thread 1
ORA-00289: suggestion : /archivelog/1_17_800974340.dbf
ORA-00280: change 5051018 for thread 1 is in sequence #17
ORA-00278: log file '/archivelog/1_16_800974340.dbf' no longer needed for this
recovery


ORA-00308: cannot open archived log '/archivelog/1_17_800974340.dbf'
ORA-27037: unable to obtain file status
Linux Error: 2: No such file or directory
Additional information: 3


SQL> ALTER DATABASE OPEN RESETLOGS;

Database altered.

SQL>

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

转载于:http://blog.itpub.net/28227905/viewspace-1059845/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值