Sunday, September 12, 2010

Clone database(10.2.0.1.0) using RMAN on same server:

Target db(swapna1):
[swapna@linux11 ~]$ vi .bash_profile
swapna()
{
export ORACLE_SID=swapna1
export ORACLE_HOME=/u02/ven
export PATH=$ORACLE_HOME/bin:$PATH:.
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
}
swapnadup()
{
export ORACLE_SID=rcdup
export ORACLE_HOME=/u02/ven
export PATH=$ORACLE_HOME/bin:$PATH:.
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
}
[swapna@linux11 swapna]$ pwd
/u02/ven/swapna
[swapna@linux11 swapna]$mkdir swapnadup
[swapna@linux11 swapna]$ cd swapnadup/
[swapna@linux11 swapnadup]$mkdir bdump  udump  cdump
[swapna@linux11 dbs]$ pwd
/u02/ven/dbs
[swapna@linux11 dbs]$cp initswapna1.ora initrcdup.ora
[swapna@linux11 dbs]$ vi initrcdup.ora
db_name=rcdup
log_archive_dest = /u02/ven/swapna/swapnadup/arch
control_files = /u02/ven/swapna/swapnadup/cnt1.ctl
compatible = 10.2.0.1.0
undo_management=auto
undo_tablespace=undotbs
undo_retention=300
background_dump_dest=/u02/ven/swapna/swapnadup/bdump
user_dump_dest=/u02/ven/swapna/swapnadup/udump
core_dump_dest=/u02/ven/swapna/swapnadup/cdump
remote_login_passwordfile=exclusive
:wq!
[swapna@linux11 dbs]$ orapwd file=orapwrcdup password=rcdup
[swapna@linux11 dbs]$ ls
07lbf4en_1_1  hc_rcdup.dat    init.ora         lkRCDUP     orapwswapna1
08lbf4gf_1_1  hc_swapna1.dat  initrcdup.ora    lkSWAPNA1   snapcf_swapna1.f
dump          initdw.ora      initswapna1.ora  orapwrcdup  sqlnet.log
[swapna@linux11 admin]$ pwd
/u02/ven/network/admin
[swapna@linux11 admin]$ vi listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = swapna1)
(ORACLE_HOME = /u02/ven)
(SID_NAME = swapna1)
)
(SID_DESC =
(GLOBAL_DBNAME = rcdup)
(ORACLE_HOME = /u02/ven)
(SID_NAME = rcdup)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = swapna1))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = rcdup))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = linux11.compucom.com)(PORT = 1521))
)
)
ADR_BASE_LISTENER = /u02/ven
:wq!
[swapna@linux11 admin]$ cd
[swapna@linux11 ~]$ . .bash_profile
[swapna@linux11 ~]$ swapna
[swapna@linux11 ~]$ sqlplus / as sysdba
SQL> startup mount
Clone db:
[swapna@linux11 ~]$ swapnadup
[swapna@linux11 admin]$ lsnrctl start LISTENER
[swapna@linux11 ~]$ sqlplus
SQL> startup nomount
Catalog or rman db:
Note:using uptodate targetdb backup clone the new db
[rman@linux11 admin]$ vi tnsnames.ora
swapna1 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = linux11.compucom.com)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = swapna1)
)
)
rcdup =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = linux11.compucom.com)(PORT = 1521))
(CONNECT_DATA =
(SERVICE_NAME = rcdup)
)
)
:wq!
[rman@linux11 admin]$ rman target sys/sys@swapna1 nocatalog auxiliary sys/rcdup@rcdup
Observation: (
Recovery Manager: Release 10.2.0.1.0 – Production on Tue Apr 20 12:34:28 2010
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database: SWAPNA1 (DBID=1030606802, not open)
using target database control file instead of recovery catalog
connected to auxiliary database: RCDUP (not mounted) )
RMAN> duplicate target database to rcdup;
Observation:(
Starting Duplicate Db at 20-APR-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=47 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/20/2010 12:35:14
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary filename /u02/ven/swapna/tsdatafile1.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u02/ven/swapna/userdata.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u02/ven/swapna/sysaux.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u02/ven/swapna/undotbs.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u02/ven/swapna/system.dbf conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u02/ven/swapna/redolog2a.log conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u02/ven/swapna/redolog1a.log conflicts with a file used by the target database )
RMAN> list backup;
RMAN> configure auxname for datafile ‘/u02/ven/swapna/system.dbf’ to ‘/u02/ven/swapna/swapnadup/system.dbf’;
auxiliary name for datafile 1 set to: /u02/ven/swapna/swapnadup/system.dbf
new RMAN configuration parameters are successfully stored
RMAN> configure auxname for datafile ‘/u02/ven/swapna/undotbs.dbf’ to ‘/u02/ven/swapna/swapnadup/undotbs.dbf’;   ——“do this step for all datafiles resides in list backup”
RMAN> run{
duplicate target database to rcdup logfile
group 1 (‘/u02/ven/swapna/swapnadup/redo1.log’) size 1m reuse,
group 2 (‘/u02/ven/swapna/swapnadup/redo2.log’) size 1m reuse;
}
Observation: (
Starting Duplicate Db at 20-APR-10
using channel ORA_AUX_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/20/2010 13:14:44
RMAN-00600: internal error, arguments [10019] [krmxcr] [] [] []
RMAN-00600: internal error, arguments [10019] [krmxcr] [] [] []    )
RMAN> duplicate target database to rcdup;
Observation: (
Starting Duplicate Db at 20-APR-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=47 devtype=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/20/2010 13:59:54
RMAN-05501: aborting duplication of target database
RMAN-05001: auxiliary filename /u02/ven/swapna/redolog2a.log conflicts with a file used by the target database
RMAN-05001: auxiliary filename /u02/ven/swapna/redolog1a.log conflicts with a file used by the target database    )
RMAN> run {
2>  duplicate target database to rcdup logfile
3> group 1 (‘/u02/ven/swapna/swapnadup/redolog1a.log’) size 50m reuse,
4> group 2 (‘/u02/ven/swapna/swapnadup/redolog2a.log’) size 50m reuse;
5> }
Observation: (
Starting Duplicate Db at 20-APR-10
using channel ORA_AUX_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/20/2010 14:02:30
RMAN-05501: aborting duplication of target database
RMAN-05517: temporary file /u02/ven/swapna/temp.dbf conflicts with file used by target database  )
RMAN> run {
2> set newname for tempfile ‘/u02/ven/swapna/temp.dbf’ to ‘/u02/ven/swapna/swapnadup/temp.dbf’;
3> duplicate target database to rcdup logfile
4>  group 1 (‘/u02/ven/swapna/swapnadup/redolog1a.log’) size 50m reuse,
5> group 2 (‘/u02/ven/swapna/swapnadup/redolog2a.log’) size 50m reuse;
6> }
Observation: (
executing command: SET NEWNAME
Starting Duplicate Db at 20-APR-10
using channel ORA_AUX_DISK_1
contents of Memory Script:
{
set until scn  230972;
set newname for datafile  1 to
“/u02/ven/swapna/swapnadup/system.dbf”;
set newname for datafile  2 to
“/u02/ven/swapna/swapnadup/undotbs.dbf”;
set newname for datafile  3 to
“/u02/ven/swapna/swapnadup/sysaux.dbf”;
set newname for datafile  4 to
“/u02/ven/swapna/swapnadup/userdata.dbf”;
set newname for datafile  5 to
“/u02/ven/swapna/swapnadup/tsdatafile1.dbf”;
restore
check readonly
clone database
;
}
executing Memory Script
executing command: SET until clause
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 20-APR-10
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backupset restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u02/ven/swapna/swapnadup/system.dbf
restoring datafile 00002 to /u02/ven/swapna/swapnadup/undotbs.dbf
restoring datafile 00003 to /u02/ven/swapna/swapnadup/sysaux.dbf
restoring datafile 00004 to /u02/ven/swapna/swapnadup/userdata.dbf
restoring datafile 00005 to /u02/ven/swapna/swapnadup/tsdatafile1.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u02/ven/dbs/07lbf4en_1_1
channel ORA_AUX_DISK_1: restored backup piece 1
piece handle=/u02/ven/dbs/07lbf4en_1_1 tag=TAG20100418T195815
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:37
Finished restore at 20-APR-10
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “RCDUP” RESETLOGS ARCHIVELOG
MAXLOGFILES     16
MAXLOGMEMBERS      2
MAXDATAFILES       30
MAXINSTANCES     1
MAXLOGHISTORY      292
LOGFILE
GROUP  1 ( ‘/u02/ven/swapna/swapnadup/redolog1a.log’ ) SIZE 50 M  REUSE,
GROUP  2 ( ‘/u02/ven/swapna/swapnadup/redolog2a.log’ ) SIZE 50 M  REUSE
DATAFILE
‘/u02/ven/swapna/swapnadup/system.dbf’
CHARACTER SET US7ASCII
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
released channel: ORA_AUX_DISK_1
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=716825797 filename=/u02/ven/swapna/swapnadup/undotbs.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=716825797 filename=/u02/ven/swapna/swapnadup/sysaux.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=716825797 filename=/u02/ven/swapna/swapnadup/userdata.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=716825797 filename=/u02/ven/swapna/swapnadup/tsdatafile1.dbf
contents of Memory Script:
{
set until scn  230972;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 20-APR-10
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: sid=49 devtype=DISK
starting media recovery
archive log thread 1 sequence 6 is already on disk as file /u02/ven/swapna/arch/1_6_713214409.dbf
archive log thread 1 sequence 7 is already on disk as file /u02/ven/swapna/arch/1_7_713214409.dbf
archive log filename=/u02/ven/swapna/arch/1_6_713214409.dbf thread=1 sequence=6
archive log filename=/u02/ven/swapna/arch/1_7_713214409.dbf thread=1 sequence=7
media recovery complete, elapsed time: 00:00:13
Finished recover at 20-APR-10
contents of Memory Script:
{
shutdown clone;
startup clone nomount ;
}
executing Memory Script
database dismounted
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area     138412032 bytes
Fixed Size                     1218124 bytes
Variable Size                130025908 bytes
Database Buffers               4194304 bytes
Redo Buffers                   2973696 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE “RCDUP” RESETLOGS ARCHIVELOG
MAXLOGFILES     16
MAXLOGMEMBERS      2
MAXDATAFILES       30
MAXINSTANCES     1
MAXLOGHISTORY      292
LOGFILE
GROUP  1 ( ‘/u02/ven/swapna/swapnadup/redolog1a.log’ ) SIZE 50 M  REUSE,
GROUP  2 ( ‘/u02/ven/swapna/swapnadup/redolog2a.log’ ) SIZE 50 M  REUSE
DATAFILE
‘/u02/ven/swapna/swapnadup/system.dbf’
CHARACTER SET US7ASCII
contents of Memory Script:
{
set newname for tempfile  1 to
“/u02/ven/swapna/swapnadup/temp.dbf”;
switch clone tempfile all;
catalog clone datafilecopy  “/u02/ven/swapna/swapnadup/undotbs.dbf”;
catalog clone datafilecopy  “/u02/ven/swapna/swapnadup/sysaux.dbf”;
catalog clone datafilecopy  “/u02/ven/swapna/swapnadup/userdata.dbf”;
catalog clone datafilecopy  “/u02/ven/swapna/swapnadup/tsdatafile1.dbf”;
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed temporary file 1 to /u02/ven/swapna/swapnadup/temp.dbf in control file
cataloged datafile copy
datafile copy filename=/u02/ven/swapna/swapnadup/undotbs.dbf recid=1 stamp=716825833
cataloged datafile copy
datafile copy filename=/u02/ven/swapna/swapnadup/sysaux.dbf recid=2 stamp=716825833
cataloged datafile copy
datafile copy filename=/u02/ven/swapna/swapnadup/userdata.dbf recid=3 stamp=716825834
cataloged datafile copy
datafile copy filename=/u02/ven/swapna/swapnadup/tsdatafile1.dbf recid=4 stamp=716825834
datafile 2 switched to datafile copy
input datafile copy recid=1 stamp=716825833 filename=/u02/ven/swapna/swapnadup/undotbs.dbf
datafile 3 switched to datafile copy
input datafile copy recid=2 stamp=716825833 filename=/u02/ven/swapna/swapnadup/sysaux.dbf
datafile 4 switched to datafile copy
input datafile copy recid=3 stamp=716825834 filename=/u02/ven/swapna/swapnadup/userdata.dbf
datafile 5 switched to datafile copy
input datafile copy recid=4 stamp=716825834 filename=/u02/ven/swapna/swapnadup/tsdatafile1.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 20-APR-10  )
RMAN>
Clone db: (testing after cloneing)
[swapna@linux11 admin]$ sqlplus
Enter user-name: /as sysdba
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 – Production
With the Partitioning, OLAP and Data Mining options
SQL> archive log list;
Observation: (
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /u02/ven/swapna/swapnadup/arch
Oldest online log sequence     0
Next log sequence to archive   1
Current log sequence           1    )
SQL> select name from v$datafile;
Observation: (
NAME
——————————————————————————–
/u02/ven/swapna/swapnadup/system.dbf
/u02/ven/swapna/swapnadup/undotbs.dbf
/u02/ven/swapna/swapnadup/sysaux.dbf
/u02/ven/swapna/swapnadup/userdata.dbf
/u02/ven/swapna/swapnadup/tsdatafile1.dbf    )
SQL> show sga
Observation: (
Total System Global Area  138412032 bytes
Fixed Size                  1218124 bytes
Variable Size             130025908 bytes
Database Buffers            4194304 bytes
Redo Buffers                2973696 bytes   )
SQL> conn swapna/swapna1
Connected.
SQL> select tname from tab;
Observation: (
TNAME
——————————
A
B
SQL> select * from a;
A ANAME             SAL
———- ———- ———-
1 a1              34345
2 a2              53432
3 a3              34234
4 a4              56443   )

Analysis:

1>cp init<sid>.ors file target clone database location and change db_name,files locations
2>create bdump,cdump,udump and datfiles locations directory on clone db
3>startup clone db in nomount satge
4>startup target db in mount stage
5>startup rman db
6>all db listeners must be up
7>use rman target  <tr_user>/<tr_user_passwd>@<tns_name_trdb> nocatalog  auxiliary   <cln_user_name>/<passwd>@<tns_name_clndb>
8>duplicate target database to <clone_db_name> in run command  (it will automatically create control file and database on clone db)

No comments:

Post a Comment