Wednesday, 2 April 2014

Restore recover oracle Database with RMAN

Before restore the database or data file or table spase you should fulfill the following requirements 
1 Database running with archivelog  mode
2 Backup database with archive logs
   (Best practice rman backup should be daily)
 Restore and recover the whole Database:
 RMAN> STARTUP FORCE MOUNT;
 RMAN> RESTORE DATABASE;
 RMAN> RECOVER DATABASE;
 RMAN> ALTER DATABASE OPEN;
Restore and recover a Tablespace:
 RMAN> SQL 'ALTER TABLESPACE aai_tbs OFFLINE';
 RMAN> RESTORE TABLESPACE aai_tbs;
 RMAN> RECOVER TABLESPACE aai_tbs;
 RMAN> SQL 'ALTER TABLESPACE aai_tbs ONLINE';
Restore and recover a Data file: 
Note here you will need the data file number so you can find out the data file number using below command
RMAN> report schema;
Output should be
List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    1000     SYSTEM               ***     /u01/DEV/db/apps_st/data1/system01.dbf
2    1000     SYSTEM               ***     /u01/DEV/db/apps_st/data1/system02.dbf
3    1000     SYSTEM               ***     /u01/DEV/db/apps_st/data1/system03.dbf
4    1000     SYSTEM               ***     /u01/DEV/db/apps_st/data1/system04.dbf
5    1000     SYSTEM               ***     /u01/DEV/db/apps_st/data1/system05.dbf
6    40       CTXD                 ***     /u01/DEV/db/apps_st/data1/ctxd01.dbf
7    10       OWAPUB               ***     /u01/DEV/db/apps_st/data1/owad01.dbf
8    500      APPS_TS_QUEUES       ***     /u01/DEV/db/apps_st/data1/a_queue02.dbf
9    20       ODM                  ***     /u01/DEV/db/apps_st/data1/odm.dbf
10   17       OLAP                 ***     /u01/DEV/db/apps_st/data1/olap.dbf
11   7000     SYSAUX               ***     /u01/DEV/db/apps_st/data1/sysaux01.dbf
12   500      APPS_TS_TOOLS        ***     /u01/DEV/db/apps_st/data1/apps_ts_tools01.dbf
Method 1
 RMAN> SQL 'ALTER DATABASE DATAFILE 64 OFFLINE';
 RMAN> RESTORE DATAFILE 64;
 RMAN> RECOVER DATAFILE 64;
 RMAN> SQL 'ALTER DATABASE DATAFILE 64 ONLINE';
Method 2
SQL> alter database datafile ' /u01/finsys/db/apps_st/data1/aai_tbs02.dbf' offline;
RMAN> RESTORE DATAFILE '/u01/finsys/db/apps_st/data1/aai_tbs02.dbf’;
RMAN> RECOVER DATAFILE '/u01/finsys/db/apps_st/data1/aai_tbs02.dbf’;
SQL> alter database datafile ' /u01/finsys/db/apps_st/data1/aai_tbs02.dbf' online;
Additional command 
 
RMAN> RECOVER DATABASE SKIP TABLESPACE users;
RMAN> RECOVER TABLESPACE users, tools;
RMAN> RECOVER DATAFILE '/newdisk/users01.dbf','/newdisk/tools01.dbf';
RMAN> RECOVER DATAFILE 4;

No comments:

Post a Comment