Friday, June 28, 2013

RMAN 'Duplicate from Active Database' Feature in 11G

Source: DB name: TEST1
Target: DB name: TEST2
On Target:-
 We have to copy the only Oracle home from source to target
On Target we 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 initTEST2.ora
 Vi initTEST2.ora
*.db_name=TEST2
*.db_file_name_convert='/u01/oradb/db/apps_st/data','/u02/oradb/db/apps_st/data'
*.log_file_name_convert='/u01/oradb/db/apps_st/data','/u02/oradb/db/apps_st/data'
*.diagnostic_dest='/u02/oradb/db/tech_st/11.1.0/admin/TEST2_<hostname>'
*.control _files='/u02/oradb/db/apps_st/data/control01.dbf'
*.COMPATIBLE= 11.1.0.0.0
Here db_file_name_convert =<’source db file loc’>, < ‘target db file loc’>, < ’source db file loc’>, < ‘target db file loc’>, <’’>………………..;
  log_file_name_convert= ’<source log file loc>’,’< target log file loc>’;

Now we have to create the password file at $ORACLE_HOME/dbs Location in source and target like below
 bash-3.00$orapwd file=orapwTEST1   password=sys  force=y entries=5  (On source)   
bash-3.00$orapwd  file=orapwTEST2    password=sys  force=y entries=5  (On Target)
 Note: we have to provide the same password in source and target
On Target:-
We have to start the db in nomount state
-bash-3.00$ ps -ef|grep ora_
  oracle  4859  1718   0 16:29:48 pts/1       0:00 grep ora_
-bash-3.00$ ORACLE_SID=TEST2
-bash-3.00$ export ORACLE_SID
-bash-3.00$ sqlplus  sys/sys as sysdba
SQL*Plus: Release 11.1.0.7.0 - Production on Fri Mar 8 16:30:07 2013
Copyright (c) 1982, 2008, oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup nomount pfile='/u02/oradb/db/tech_st/11.1.0/dbs/initTEST2.ora';
oracle instance started.
Then We have to create spfile from pfile. Then we start the db no mount state.
After that we have to check tnsping is working on Source and target
Note:  we have set the source tns entries and target tns entries in source and target of tnsname.ora file. Then we check the tnsping
$tnsping   <source IP>
$tnsping    <Target IP>
$tnsping   <Source db name>
$tnsping   <target db name>
On Source:-
$tnsping   <source IP>
$tnsping    <Target IP>
$tnsping   <Source db name>
$tnsping   <target db name>
If  tnsping connection is fine. Then we will check the at sqlplus level
Bash-3.0sqlplus sys/sys@TEST2 as sysdba (From Source)
 Bash-3.0sqlplus sys/sys@TEST1 as sysdba (From Target)
If everything fine we can proceed next step
On Target:-
-bash-3.00$ rman target sys/sys@TEST1 nocatalog  auxiliary sys/sys@TEST2
Recovery Manager: Release 11.1.0.7.0 - Production on Fri Mar 8 16:48:06 2013
Copyright (c) 1982, 2007, oracle  All rights reserved.
connected to target database: TEST1 (DBID=4138996220)
using target database control file instead of recovery catalog
connected to auxiliary database: TEST2 (not mounted)
RMAN> duplicate target database to 'TEST2' from active database
 db_file_name_convert  ‘/u01/oradb/db/apps_st/data','/u02/oradb/db/apps_st/data';
Starting Duplicate Db at 08-MAR-13
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=98 device type=DISK
contents of Memory Script:
{
   set newname for datafile  1 to "/u02/oradb/db/apps_st/data/system01.dbf";
   set newname for datafile  2 to "/u02/oradb/db/apps_st/data/system02.dbf";
   set newname for datafile  3 to "/u02/oradb/db/apps_st/data/system03.dbf";
   set newname for datafile  4 to "/u02/oradb/db/apps_st/data/system04.dbf";
   set newname for datafile  5 to  "/u02/oradb/db/apps_st/data/system05.dbf";
   backup as copy reuse
   datafile  1 auxiliary format "/u02/oradb/db/apps_st/data/system01.dbf"   datafile
 2 auxiliary format  "/u02/oradb/db/apps_st/data/system02.dbf"   datafile
 3 auxiliary format "/u02/oradb/db/apps_st/data/system03.dbf"   datafile
 4 auxiliary format  "/u02/oradb/db/apps_st/data/system04.dbf"   datafile
 5 auxiliary format "/u02/oradb/db/apps_st/data/system05.dbf"   datafile
 sql 'alter system archive log current';
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting backup at 08-MAR-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=334 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00045 name=/u01/oradb/db/apps_st/data/a_txn_data08.dbf
output file name=/u02/oradb/db/apps_st/data/a_txn_data08.dbf tag=TAG20130308T075928 RECID=0 STAMP=0
STAMP=809551448cataloged datafile copy
cataloged datafile copy
input datafile copy RECID=1 STAMP=809551447 file name=/u02/oradb/db/apps_st/data/system02.dbf
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 08-MAR-13.
RMAN>
********database will open automatically on target******
 Error 1:-
RMAN> duplicate target database to 'TEST2' from active database
 db_file_name_convert  ‘/u01/oradb/db/apps_st/data','/u02/oradb/db/apps_st/data';
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 03/08/2013 17:38:49
RMAN-06136: oracle error from auxiliary database: ORA-01503: CREATE CONTROLFILE failed
ORA-01130: database file version 11.1.0.0.0 incompatible with version 11.0.0.0.0
ORA-01110: data file 1: '/u02/oradb/db/apps_st/data/system01.dbf'
We will get the above yellow marked error while creation of Control file level
 we can resolve the above issue by providing below solution
Solution: - we add the COMPATIBLE= 11.1.0.0.0 parameter in initTEST2.ora file.
Error 2:-
Contents of Memory Script:
{
   shutdown clone immediate;
   startup clone nomount ;
}
executing Memory Script
database dismounted
oracle instance shut down
connected to auxiliary database (not started)
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/09/2013 13:04:28
RMAN-03015: error occurred in stored script Memory Script
RMAN-04014: startup failed: ORA-48141: error creating directory during ADR initialization [/u02/oradb/db/tech_st/11.1.0/admin/SID_<hostname>/diag/rdbms//u01/oradb/db/apps_st/dat]
ORA-48189: OS command to create directory failed
SVR4 Error: 2: No such file or directory
Additional information: 2

Solution: - create the spfile from pfile then we need to execute the same script

No comments:

Post a Comment