Monday 11 May 2015

RMAN STEP BY STEP RESTORE AND RECOVER DATABASE IN ORACLE :


--Take a backup of database from RMAN before proceeding :

=====================

SQL> shut immediate
SQL> startup mount
SQL> alter database archivelog;
SQL> alter database open;
C:\Documents and Settings\USERPRO>rman target 'sys/sys@orcl_new as sysdba'
RMAN> backup database plus archivelog;

After the backup, few rman files(4 OR many) will be created at location 'D:\app\USERPRO\product\11.2.0\dbhome_1\database\' like '03Q2D3UN_1_1' which consists of a control file.

=====================

1)

C:\Documents and Settings\USERPRO>sqlplus sys/sys@orcl as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Sat Mar 21 15:45:46 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

2) Now, take a backup of control files and drop the control files from oradata.Now the database would not connect.

3) 

C:\Documents and Settings\USERPRO>rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Sat Mar 21 15:48:04 2015

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

connected to target database (not started)

RMAN> set DBID 1402635108

executing command: SET DBID

RMAN> startup nomount

Oracle instance started

Total System Global Area     778387456 bytes

Fixed Size                     1374808 bytes
Variable Size                343934376 bytes
Database Buffers             427819008 bytes
Redo Buffers                   5259264 bytes

RMAN> RESTORE CONTROLFILE FROM "D:\app\USERPRO\product\11.2.0\dbhome_1\database\03Q2D3UN_1_1";

Starting restore at 21-MAR-15
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output file name=D:\APP\USERPRO\ORADATA\ORCL\CONTROL01.CTL
output file name=D:\APP\USERPRO\ORADATA\ORCL\CONTROL02.CTL
Finished restore at 21-MAR-15


RMAN> alter database mount
2> ;

database mounted
released channel: ORA_DISK_1

RMAN> restore database
2> ;

Starting restore at 21-MAR-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 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 00001 to D:\APP\USERPRO\ORADATA\ORCL\SYSTEM01.DBF
channel ORA_DISK_1: restoring datafile 00002 to D:\APP\USERPRO\ORADATA\ORCL\SYSAUX01.DBF
channel ORA_DISK_1: restoring datafile 00003 to D:\APP\USERPRO\ORADATA\ORCL\UNDOTBS01.DBF
channel ORA_DISK_1: restoring datafile 00004 to D:\APP\USERPRO\ORADATA\ORCL\USERS01.DBF
channel ORA_DISK_1: reading from backup piece D:\APP\USERPRO\PRODUCT\11.2.0\DBHOME_1\DATABASE\02Q2D3R1_1_1
channel ORA_DISK_1: piece handle=D:\APP\USERPRO\PRODUCT\11.2.0\DBHOME_1\DATABASE\02Q2D3R1_1_1 tag=TAG20150321T153143
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 21-MAR-15

RMAN> recover database;

Starting recover at 21-MAR-15
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 10 is already on disk as file D:\APP\USERPRO\ORADATA\ORCL\REDO01.LOG
archived log for thread 1 with sequence 11 is already on disk as file D:\APP\USERPRO\ORADATA\ORCL\REDO02.LOG
archived log file name=D:\APP\USERPRO\ORADATA\ORCL\REDO01.LOG thread=1 sequence=10
archived log file name=D:\APP\USERPRO\ORADATA\ORCL\REDO02.LOG thread=1 sequence=11
media recovery complete, elapsed time: 00:00:04
Finished recover at 21-MAR-15

RMAN> alter database open resetlogs;

database opened

RMAN> exit

No comments:

Post a Comment