Monday, July 21, 2014

Recover a datafile in primary db using catalog with dataguard environment


step 1: delete the datafile users01.dbf;
step 2: backup the users01.dbf datafile from standby database;
step 3: connect using the below line
[oracle@adgrptdb ~]$  rman target sys/sys123@stanrpt auxiliary sys/sys123@primdb
step 4: run the following script for backup that datafile
backup as copy datafile 4 auxiliary format ='/u01/app/oracle/oradata/users01.dbf';

Starting backup at 21-JUL-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/stanrpt/users01.dbf
output file name=/u01/app/oracle/oradata/users01.dbf tag=TAG20140721T090536
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
Finished backup at 21-JUL-14

step 5:

[oracle@catalogdb ~]$ rman catalog rcat/rcat@catdb target sys/sys123@primdb

Recovery Manager: Release 11.2.0.3.0 - Production on Mon Jul 21 09:29:37 2014

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: PRIMDB (DBID=527540791)
connected to recovery catalog database

RMAN> catalog datafilecopy '/u01/app/oracle/oradata/users01.dbf';

cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/users01.dbf RECID=3 STAMP=853516578

step 6: make the datafile 4 offline

sql>alter database datafile 4 offline;

step 7:

RMAN> run{
set newname for datafile 4 to '/u01/app/oracle/oradata/users01.dbf';
switch datafile 4 ;
}2> 3> 4>

executing command: SET NEWNAME

datafile 4 switched to datafile copy
input datafile copy RECID=3 STAMP=853516578 file name=/u01/app/oracle/oradata/users01.dbf
starting full resync of recovery catalog
full resync complete

RMAN> restore datafile 4;

Starting restore at 21-JUL-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/PRIMDB/backupset/2014_07_21/o1_mf_nnndf_TAG20140721T151938_9wspsc9n_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/PRIMDB/backupset/2014_07_21/o1_mf_nnndf_TAG20140721T151938_9wspsc9n_.bkp tag=TAG20140721T151938
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 21-JUL-14

RMAN> recover datafile 4;

Starting recover at 21-JUL-14
using channel ORA_DISK_1

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

Finished recover at 21-JUL-14

RMAN>


step 7: make the datafile 4 online

sql>alter database datafile 4 online;


No comments:

Post a Comment