ITPub博客

首页 > 数据库 > Oracle > 11g physical standby datafile lost, use standby database to recover

11g physical standby datafile lost, use standby database to recover

原创 Oracle 作者:sdusun 时间:2019-06-29 10:57:06 0 删除 编辑

主库数据文件丢失,有两种恢复方法。
1 利用RMAN备份恢复,参考 http://sdusun.itpub.net/post/7915/469735
2 利用物理备库恢复

在Oracle 11g,可以使用备库的数据文件去recover主库丢失的数据文件。
如果备库是up-to-date的,并且在拷贝文件的时候网络不会成为问题。

[@more@]

0
SQL> startup mount
ORACLE 例程已经启动。

Total System Global Area 535662592 bytes
Fixed Size 1334380 bytes
Variable Size 293602196 bytes
Database Buffers 234881024 bytes
Redo Buffers 5844992 bytes
数据库装载完毕。
SQL>
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01157: 无法标识/锁定数据文件 7 - 请参阅 DBWR 跟踪文件
ORA-01110: 数据文件 7: 'D:APPADMINISTRATORPRIMARYORADATAPRIMARYTEST_STDBY02.DBF'


SQL>


1 Connect to the standby database as the target database:

C:Documents and SettingsAdministrator>
C:Documents and SettingsAdministrator>rman

恢复管理器: Release 11.1.0.6.0 - Production on 星期四 8月 28 16:03:27 2008

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

RMAN> connect target sys@standby

目标数据库口令:
连接到目标数据库: PRIMARY (DBID=1498826162)

RMAN>


2 Connect to the primary database as the auxiliary database:

RMAN> connect auxiliary sys@primary

辅助数据库口令:
已连接到辅助数据库: PRIMARY (DBID=1498826162)

RMAN>

3 Back up the datafile on the standby host across the network to a location on the primary host.

RMAN>

RMAN> backup as copy datafile 7 auxiliary format 'D:APPADMINISTRATORPRIMARYORADATAPRIMARYTEST_STDBY02.DBF';

启动 backup 于 28-8月 -08
使用目标数据库控制文件替代恢复目录
分配的通道: ORA_DISK_1
通道 ORA_DISK_1: SID=120 设备类型=DISK
通道 ORA_DISK_1: 启动数据文件副本
输入数据文件: 文件号=00007 名称=/u01/app/oradata/standby/TEST_STDBY02.DBF
输出文件名=D:APPADMINISTRATORPRIMARYORADATAPRIMARYTEST_STDBY02.DBF 标记=TAG20080828T163105 RECID=0 STAMP=0
通道 ORA_DISK_1: 数据文件复制完毕, 经过时间: 00:00:01
完成 backup 于 28-8月 -08

RMAN>

4 Exit the RMAN client as follows:

察看主库目录,D:APPADMINISTRATORPRIMARYORADATAPRIMARYTEST_STDBY02.DB 的确已经copy过来。
EXIT;

如果使用RMAN备份之后,主库的归档日志还没有delete的话,可以简单的恢复(第五步);
反之,跳到第6步。


5
SQL>
SQL> alter database open;
alter database open
*
第 1 行出现错误:
ORA-01113: 文件 7 需要介质恢复
ORA-01110: 数据文件 7: 'D:APPADMINISTRATORPRIMARYORADATAPRIMARYTEST_STDBY02.DBF'


SQL>
SQL> recover datafile 7;
完成介质恢复。
SQL> alter database open;

数据库已更改。

6 Start RMAN and connect to the primary database as target, and to the recovery catalog:

C:Documents and SettingsAdministrator>rman

恢复管理器: Release 11.1.0.6.0 - Production on 星期四 8月 28 16:36:07 2008

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

RMAN> connect target sys@primary

目标数据库口令:
连接到目标数据库: PRIMARY (DBID=1498826162)

RMAN>

RMAN> connect catalog rman_bak@orabak

恢复目录数据库口令:
连接到恢复目录数据库

RMAN>


7 Use the CATALOG DATAFILECOPY command to catalog this datafile copy so that RMAN can use it.:

CATALOG DATAFILECOPY 'D:APPADMINISTRATORPRIMARYORADATAPRIMARYTEST_STDBY02.DBF';

Then use the SWITCH DATAFILE command to switch the datafile copy so that /disk9/df2copy.dbf becomes the current datafile:

RUN {
SET NEWNAME FOR DATAFILE 2 TO 'D:APPADMINISTRATORPRIMARYORADATAPRIMARYTEST_STDBY02.DBF';
SWITCH DATAFILE 2;
}

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

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

注册时间:2005-09-13

  • 博文量
    116
  • 访问量
    118267