Thursday, June 27, 2013

RMAN cloning in Oracle 11g

                                 RMAN cloning in Oracle 11g
Source db name: TEST
Target db name: TEST
First we have to run the RMAN Level 0 backup at source. After completion of RMAN Backup at source we will transfer the RMAN Backup to target.
Note:  I have given the same db name at source and target
On Target:-
 We have to copy the only Oracle Home from source to target
On Target we have to create the listener by using below command or Netca
-Bash-3.00$cd <ORACLE_HOME>/appsutil/clone/bin
-Bash-3.00$perl adcfgclone.pl dbTechStack
Here listener.ora and tnsnames.ora files are created under $ORACLE_HOME/network/admin/SID_<hostname>.
But sqlnet.ora is not created under the above location.
So that we have to copy the sqlnet.ora file from source to target
In Target database we have to set the only below parameters in initTEST.ora
 View   initTEST.ora
*.db_name=TEST
*.diagnostic_dest='/u01/oradb/db/tech_st/11.1.0/admin/TEST_<hostname>'
*.control _files='/u01/oradb/db/apps_st/data/control01.dbf'
*.COMPATIBLE= 11.1.0.0.0
:wq!
Note: The above parameters is enough in init<dbname>.ora level in target
-bash-3.00$ sqlplus / as sysdba  
SQL*Plus: Release 11.1.0.7.0 - Production on Fri Mar 8 16:30:07 2013
Copyright (c) 1982, 2008, U01.  All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='/u01/oradb/db/tech_st/11.1.0/dbs/initTEST.ora';
Oracle  instance started.
SQL> exit
Disconnected from U01 Database 11g Enterprise Edition Release 11.1.0.7.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-bash-3.00$ cd  /u01/oradb/rmanbackup/ (This RMAN backup has transferd from source)
-bash-3.00$ ls
TEST_RMAN_LVL0_20130626.log  
 contrl_861_1_819081694.bk     
db_845_1_819078611.bk                     
arc_857_1_819081319.bk                
-bash-3.00$ rman target /
Recovery Manager: Release 11.1.0.7.0 - Production on Wed Jun 26 15:01:42 2013
Copyright (c) 1982, 2007, U01.  All rights reserved.
connected to target database: TEST (not mounted)
RMAN> restore controlfile from '/u01/oradb/rmanbackup/contrl_861_1_819081694.bk';
Starting restore at 26-JUN-13
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=98 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/oradb/db/apps_st/data/control01.dbf
Finished restore at 26-JUN-13
RMAN> mount database;
database mounted
released channel: ORA_DISK_1
-bash-3.00$ rman target sys/SRINU
Recovery Manager: Release 11.1.0.7.0 - Production on Wed Jun 26 15:04:26 2013
Copyright (c) 1982, 2007, oracle.  All rights reserved.
connected to target database: TEST (DBID=4138996220, not open)
RMAN> catalog start with '/u01/oradb/rmanbackup';  (Here we have to provide the target RMAN Backup location )
using target database control file instead of recovery catalog
searching for all files that match the pattern /u01/oradb/rmanbackup
List of Files Unknown to the Database
=====================================
File Name: /u01/oradb/rmanbackup/TEST_RMAN_LVL0_20130626.log
File Name: /u01/oradb/rmanbackup/arc_857_1_819081319.bk
File Name: /u01/oradb/rmanbackup/contrl_861_1_819081694.bk
File Name: /u01/oradb/rmanbackup/db_850_1_819079929.bk

Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/oradb/rmanbackup/arc_857_1_819081319.bk
File Name: /u01/oradb/rmanbackup/arc_858_1_819081319.bk
File Name: /u01/oradb/rmanbackup/contrl_861_1_819081694.bk
File Name: /u01/oradb/rmanbackup/db_856_1_819081120.bk
List of Files Which Where Not Cataloged
=======================================
File Name: /u01/oradb/rmanbackup/TEST_RMAN_LVL0_20130626.log
 RMAN-07517: Reason: The file header is corrupted
Note: In the above Catalog script we have to provide the target rman backup location.
Note: Execute the select  file_id, file_name from dba_data_files order by file_id; query  in source location and according that the below script we have to mention which mount point to copy the datafiles.( Here we are transferring to u01 Mount point )
RMAN> run
 {
set newname for datafile 1 to '/u01/oradb/db/apps_st/data/system01.dbf';
set newname for datafile 2 to '/u01/oradb/db/apps_st/data/system02.dbf';
set newname for datafile 3 to '/u01/oradb/db/apps_st/data/system03.dbf';
set newname for datafile 4 to '/u01/oradb/db/apps_st/data/system04.dbf';
set newname for datafile 5 to '/u01/oradb/db/apps_st/data/system05.dbf';
set newname for datafile 6 to '/u01/oradb/db/apps_st/data/system06.dbf';
set newname for datafile 7 to '/u01/oradb/db/apps_st/data/system07.dbf';
set newname for datafile 8 to '/u01/oradb/db/apps_st/data/system08.dbf';
set newname for datafile 9 to '/u01/oradb/db/apps_st/data/system09.dbf';
set newname for datafile 10 to '/u01/oradb/db/apps_st/data/system10.dbf';
restore database;
switch datafile all;
recover database;
}
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 26-JUN-13
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 00040 to /u01/oradb/db/apps_st/data/sysaux02.dbf
channel ORA_DISK_1: restoring datafile 00051 to /u01/oradb/db/apps_st/data/users1.dbf
channel ORA_DISK_1: restoring datafile 00057 to /u01/oradb/db/apps_st/data/users2.dbf
channel ORA_DISK_1: reading from backup piece /u011/oradb/rmanbackup/db_841_1_819078609.bk
channel ORA_DISK_1: errors found reading piece handle=/u011/oradb/rmanbackup/db_841_1_819078609.bk
channel ORA_DISK_1: failover to piece handle=/u01/oradb/rmanbackup/db_841_1_819078609.bk tag=TAG20130626T015007
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:45
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: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:06:55
Finished restore at 26-JUN-13
datafile 1 switched to datafile copy
input datafile copy RECID=67 STAMP=819132122 file name=/u01/oradb/db/apps_st/data/system01.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=68 STAMP=819132122 file name=/u01/oradb/db/apps_st/data/system02.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=69 STAMP=819132123 file name=/u01/oradb/db/apps_st/data/system03.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=70 STAMP=819132123 file name=/u01/oradb/db/apps_st/data/system04.dbf
Starting recover at 26-JUN-13
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=237
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=238
channel ORA_DISK_1: reading from backup piece /u011/oradb/rmanbackup/arc_860_1_819081323.bk
channel ORA_DISK_1: errors found reading piece handle=/u011/oradb/rmanbackup/arc_860_1_819081323.bk
channel ORA_DISK_1: failover to piece handle=/u01/oradb/rmanbackup/arc_860_1_819081323.bk tag=TAG20130626T023518
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:05
archived log file name=/u01/oradb/db/tech_st/11.1.0/dbs/arch1_237_807868191.dbf thread=1 sequence=237
archived log file name=/u01/oradb/db/tech_st/11.1.0/dbs/arch1_238_807868191.dbf thread=1 sequence=238
unable to find archived log
archived log thread=1 sequence=239
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/26/2013 16:43:37
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 239 and starting SCN of 309516351
RMAN> alter database open RESETLOGS;
Database opened
                                                                                                                                             Srini

5 comments:

  1. Thank you for your documentation... It is very useful to me.

    ReplyDelete
  2. Hi Srinu ,

    this is type of information real helpful for appsdba beginners.

    please post few more topics like RAC,RAC usage in real env,how to develop new production instance.

    how to clone to existing dba instance data to new instance.

    Thank you sir for your efforts.

    ReplyDelete
  3. Very nice... it will be helpful

    ReplyDelete
  4. very nice information. it is very useful to me... thanks.. waiting for more docs...

    ReplyDelete