Monday, January 11, 2016

Missing non system datafile recover using RMAN backup

Missing non system datafile recover using RMAN backup



Prerequisite: need to take full RMAN backup of the database. 

 
-Connect to RMAN commnad prompt.


[oracle@localhost trace]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Apr 1 12:06:44 2015

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

connected to target database: ORCL (DBID=1341150024)

-Put the data file in to offline, Here we can use missing datafile name or datafile number. I am using datafile number.


RMAN> sql 'alter database datafile 5 offline';
using target database control file instead of recovery catalog
sql statement: alter database datafile 5 offline

-Restore the datafile from backup.

RMAN> restore datafile 5;
Starting restore at 01-APR-15
using channel ORA_DISK_1

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 00005 to /u01/app/oracle/oradata/orcl/example01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/ORCL/backupset/2015_04_01/o1_mf_nnndf_TAG20150401T114744_bkq3dbcn_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/ORCL/backupset/2015_04_01/o1_mf_nnndf_TAG20150401T114744_bkq3dbcn_.bkp tag=TAG20150401T114744
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
Finished restore at 01-APR-15

-Recover datafile

RMAN> recover datafile 5;

Starting recover at 01-APR-15
using channel ORA_DISK_1

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

Finished recover at 01-APR-15

-put the datafile into online.

RMAN> sql 'alter database datafile 5 online';

sql statement: alter database datafile 5 online

RMAN> exit

-Recovery Manager complete. 

SQL> select status from v$datafile;

STATUS
-------
SYSTEM
ONLINE
ONLINE
ONLINE
ONLINE
ONLINE

6 rows selected.

No comments: