Start RMAN and take the following steps to copy the datafiles from the standby to the primary:
1. From Primary, connect to the standby database as the target database:
[oracle@dgprim primary /home/oracle]$ rman target sys@standby
2. Connect to the primary database as the auxiliary database:[oracle@dgprim primary /home/oracle]$ rman target sys@standby
Recovery Manager: Release 11.2.0.3.0 - Production on Sat Feb 16 17:46:31 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
target database Password:
connected to target database: PRIMARY (DBID=1637625361)
RMAN> CONNECT AUXILIARY sys@primary
3. Back up the datafile on the standby host across the network to a location on the primary host. Suppose data file 4: '+DATA/primary/datafile/users.286.807554911' is the corrupted datafile.RMAN> CONNECT AUXILIARY sys@primary
auxiliary database Password:
connected to auxiliary database: PRIMARY (DBID=1637625361, not open)
Note: The FORMAT NEW creates an image copy in the directory specified in the DB_CREATE_FILE_DEST initialization parameter of the auxiliary instance. The image copy is an Oracle-managed file.
SQL> show parameter DB_CREATE_FILE_DEST
RMAN> BACKUP AS COPY DATAFILE 4 AUXILIARY FORMAT NEW;SQL> show parameter DB_CREATE_FILE_DEST
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest string +DATA
If non-ASM, copy to a temporary location.RMAN> BACKUP AS COPY DATAFILE 4 AUXILIARY FORMAT NEW;
Starting backup at 16-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/standby/datafile/users.276.801162329
output file name=+DATA/primary/datafile/users.300.807560541 tag=TAG20130216T182214
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16
Finished backup at 16-FEB-13
RMAN> BACKUP AS COPY DATAFILE 4 AUXILIARY FORMAT '/tmp/users.276.801162329';
4. Exit the RMAN client.RMAN> BACKUP AS COPY DATAFILE 4 AUXILIARY FORMAT '/tmp/users.276.801162329';
Starting backup at 16-FEB-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=31 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=+DATA/standby/datafile/users.276.801162329
output file name=/tmp/users.276.801162329 tag=TAG20130216T175105
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
Finished backup at 16-FEB-13
RMAN> exit
5. From Primary, start RMAN and connect to the primary database as target, and to the recovery catalog:
[oracle@dgprim primary /home/oracle]$ rman target /
RMAN> connect catalog rman11/password@prim
6. Perform only this conversion if your database is in ASM to convert first the copied datafile from non-ASM no ASM.[oracle@dgprim primary /home/oracle]$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Sat Feb 16 17:52:46 2013
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: PRIMARY (DBID=1637625361, not open)
RMAN>
RMAN> connect catalog rman11/password@prim
connected to recovery catalog database
RMAN> CONVERT DATAFILE '/tmp/users.276.801162329' FORMAT '+DATA';
Code: Select all
RMAN> CONVERT DATAFILE '/tmp/users.276.801162329' FORMAT '+DATA';
Starting conversion at target at 16-FEB-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile conversion
input file name=/tmp/users.276.801162329
converted datafile=+DATA/primary/datafile/users.286.807559293
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
Finished conversion at target at 16-FEB-13
RMAN> CATALOG DATAFILECOPY '+DATA/primary/datafile/users.286.807559293';
8. Use the SWITCH DATAFILE command to switch the datafile copy so that +DATA/primary/datafile/users.286.807559293 becomes the current datafile:RMAN> CATALOG DATAFILECOPY '+DATA/primary/datafile/users.286.807559293';
cataloged datafile copy
datafile copy file name=+DATA/primary/datafile/users.286.807559293 RECID=20 STAMP=807559347
RMAN> RUN {
SET NEWNAME FOR DATAFILE 4 TO '+DATA/primary/datafile/users.286.807559293';
SWITCH DATAFILE 4;
}
9. Recover datafile.RMAN> RUN {
SET NEWNAME FOR DATAFILE 4 TO '+DATA/primary/datafile/users.286.807559293';
SWITCH DATAFILE 4;
}2> 3> 4>
executing command: SET NEWNAME
datafile 4 switched to datafile copy
input datafile copy RECID=20 STAMP=807559347 file name=+DATA/primary/datafile/users.286.807559293
starting full resync of recovery catalog
full resync complete
RMAN> recover datafile 4;
10. Open the database.RMAN> recover datafile 4;
Starting recover at 16-FEB-13
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:02
Finished recover at 16-FEB-13
RMAN> sql 'alter database open';