Wednesday, January 28, 2015

Recovering the primary database using the backup taken from the Standby Database

Recovering the primary database using the backup taken from the Standby Database
===============================================================================

1) Take the backup from the standby database.

[oracle@standalone2 bkp]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jan 29 03:49:35 2015

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

connected to target database: SOURCE (DBID=2931643800)

RMAN> backup as compressed backupset full database format '/u01/app/oracle/bkp/full_bkp_%T_%U.bkp' ;

Starting backup at 29-JAN-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=34 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=/u01/app/oracle/oradata/source/undotbs01.dbf
input datafile file number=00001 name=/u01/app/oracle/oradata/source/system01.dbf
input datafile file number=00002 name=/u01/app/oracle/oradata/source/sysaux01.dbf
input datafile file number=00005 name=/u01/app/oracle/oradata/source/test_tbls_01.dbf
input datafile file number=00004 name=/u01/app/oracle/oradata/source/users01.dbf
channel ORA_DISK_1: starting piece 1 at 29-JAN-15
channel ORA_DISK_1: finished piece 1 at 29-JAN-15
piece handle=/u01/app/oracle/bkp/full_bkp_20150129_16pttekb_1_1.bkp tag=TAG20150129T035243 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:03:06
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 29-JAN-15
channel ORA_DISK_1: finished piece 1 at 29-JAN-15
piece handle=/u01/app/oracle/bkp/full_bkp_20150129_17ptteq5_1_1.bkp tag=TAG20150129T035243 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02
Finished backup at 29-JAN-15

RMAN> exit


Recovery Manager complete.


-- Now copy the backup pieces to the primary site.

[oracle@standalone2 bkp]$ ls -lrt
total 284192
-rw-r----- 1 oracle oinstall 289587200 Jan 29 03:55 full_bkp_20150129_16pttekb_1_1.bkp
-rw-r----- 1 oracle oinstall   1130496 Jan 29 03:55 full_bkp_20150129_17ptteq5_1_1.bkp

[oracle@standalone2 bkp]$ scp * oracle@rhel11gr2rac1:/oracle/bkp/
oracle@rhel11gr2rac1's password:
full_bkp_20150129_16pttekb_1_1.bkp                                                                                                    100%  276MB   6.4MB/s   00:43
full_bkp_20150129_17ptteq5_1_1.bkp                                                                                                    100% 1104KB   1.1MB/s   00:00


-- Now in primary database remove one datafile (Test case)


SQL> select name from V$datafile;

NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/source/system01.dbf
/u01/app/oracle/oradata/source/sysaux01.dbf
/u01/app/oracle/oradata/source/undotbs01.dbf
/u01/app/oracle/oradata/source/users01.dbf
/u01/app/oracle/oradata/source/test_tbls_01.dbf


SQL> ! rm -f /u01/app/oracle/oradata/source/test_tbls_01.dbf

SQL> alter system checkpoint;
alter system checkpoint
*
ERROR at line 1:
ORA-03113: end-of-file on communication channel
Process ID: 12508
Session ID: 37 Serial number: 57


SQL> startup
ORACLE instance started.

Total System Global Area  313159680 bytes
Fixed Size                  2227944 bytes
Variable Size             289407256 bytes
Database Buffers           16777216 bytes
Redo Buffers                4747264 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/u01/app/oracle/oradata/source/test_tbls_01.dbf'


-- Now lets recover the datafile.


[oracle@rhel11gr2rac1 bkp]$ rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Thu Jan 29 12:29:16 2015

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

connected to target database: SOURCE (DBID=2931643800, not open)

RMAN> catalog start with '/oracle/bkp/';

using target database control file instead of recovery catalog
searching for all files that match the pattern /oracle/bkp/

List of Files Unknown to the Database
=====================================
File Name: /oracle/bkp/full_bkp_20150129_16pttekb_1_1.bkp
File Name: /oracle/bkp/full_bkp_20150129_17ptteq5_1_1.bkp

Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /oracle/bkp/full_bkp_20150129_16pttekb_1_1.bkp
File Name: /oracle/bkp/full_bkp_20150129_17ptteq5_1_1.bkp


RMAN> restore datafile 5;

Starting restore at 29-JAN-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 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 00005 to /u01/app/oracle/oradata/source/test_tbls_01.dbf
channel ORA_DISK_1: reading from backup piece /oracle/bkp/full_bkp_20150129_16pttekb_1_1.bkp
channel ORA_DISK_1: piece handle=/oracle/bkp/full_bkp_20150129_16pttekb_1_1.bkp tag=TAG20150129T035243
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 29-JAN-15

RMAN> recover datafile 5;

Starting recover at 29-JAN-15
using channel ORA_DISK_1

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

Finished recover at 29-JAN-15

RMAN> exit;

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


SQL> select status from V$instance;

STATUS
------------
MOUNTED



SQL> alter database open;

Database altered.


SQL> alter database datafile 5 online;

Database altered.

SQL> select tablespace_name, status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
TEST_TBLS                      ONLINE

6 rows selected.

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


No comments:

Post a Comment