Monday 28 March 2016

How to recover database if system datafile lost using RMAN


If system datafile removed from disk then you can  recover system datafile only in mount  state of database.


SQL> alter tablespace system offline;
alter tablespace system offline
*
ERROR at line 1:
ORA-01541: system tablespace cannot be brought offline; shut down if necessary

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

Startup database mount stage and bring system datafile offline. And start recovery

SQL> startup mount
ORACLE instance started.

Total System Global Area  313860096 bytes
Fixed Size                                1336232 bytes
Variable Size                        197135448 bytes
Database Buffers               109051904 bytes
Redo Buffers                         6336512 bytes
Database mounted.

SQL> !rman target /

RMAN> restore datafile 1;

Starting restore at 16-MAR-16
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 00001 to /u01/app/oracle/oradata/rman/system01.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oracle/flash_recovery_area/RMAN/backupset/2016_03_16/o1_mf_nnndf_TAG20160316T141740_cgl7ffcx_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oracle/flash_recovery_area/RMAN/backupset/2016_03_16/o1_mf_nnndf_TAG20160316T141740_cgl7ffcx_.bkp tag=TAG20160316T141740
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:56
Finished restore at 16-MAR-16

RMAN> recover datafile 1;

Starting recover at 16-MAR-16
using channel ORA_DISK_1

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

Finished recover at 16-MAR-16

RMAN> exit
Recovery Manager complete.

SQL>
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-01147: SYSTEM tablespace file 1 is offline
ORA-01110: data file 1: '/u01/app/oracle/oradata/rman/system01.dbf'


SQL> alter database datafile 1 online;
Database altered.

SQL> alter database open;
Database altered.

SQL>


No comments:

Post a Comment