Duplicate database using RMAN duplicate oracle 12c
Target database : primdb
Duplicate database: dupdb
Step-1: Configure password file for duplicate database
export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db_1
cd $ORACLE_HOME/dbs
Step-2: Configure listener and TNS file for duplicate database
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle12c.localdomain)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = primdb)
)
)
DUPDB =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = oracle12c.localdomain)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = dupdb)
)
)
Step-3: Create pfile for duplicate database
[oracle@oracle12c dbs]$ cat initdupdb.ora
db_name=dupdb
db_unique_name=dupdb
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_unique_name string dupdb
SQL> show parameter db_name
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_name string dupdb
Step-6: Test the connection using TNS for duplicate database
TNS Ping Utility for Linux: Version 12.2.0.1.0 - Production on 08-APR-2022 19:39:44
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
/u01/app/oracle/product/12.2.0/db_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = oracle12c.localdomain)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = dupdb)))
OK (10 msec)
[oracle@oracle12c dbs]$ sqlplus sys@dupdb as sysdba
SQL*Plus: Release 12.2.0.1.0 Production on Fri Apr 8 19:40:46 2022
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Enter password:
Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL>
Step-7: Connect Target and Auxiliary instance using RMAN
Recovery Manager: Release 12.2.0.1.0 - Production on Fri Apr 8 19:51:16 2022
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
target database Password:
connected to target database: PRIMDB (DBID=776018423)
RMAN> connect auxiliary sys@dupdb
auxiliary database Password:
connected to auxiliary database: DUPDB (not mounted)
Step-8: Run duplicate command to restore the database
Allocate channel c1 device type disk;
allocate auxiliary channel c2 device type disk ;
DUPLICATE TARGET DATABASE to dupdb
FROM ACTIVE DATABASE
SPFILE
SET DB_name='dupdb'
SET DB_UNIQUE_NAME='dupdb'
SET CONTROL_FILES='/u01/app/oracle/oradata/dupdb/dupdb.ctl'
SET LOG_FILE_NAME_CONVERT '/u01/app/oracle/oradata/primdb/','/u01/app/oracle/oradata/dupdb/'
SET DB_FILE_NAME_CONVERT '/u01/app/oracle/oradata/primdb/','/u01/app/oracle/oradata/dupdb/'
set db_recovery_file_dest_size '1G'
set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area/dupdb'
set SGA_TARGET '1024M'
SET diagnostic_dest='/u01/app/oracle/'
; }
Step-9: Add the database entry in /etc/oratab file
dupdb:/u01/app/oracle/product/12.2.0/db_1:N
Restore log:
Allocate channel c1 device type disk;
allocate auxiliary channel c2 device type disk ;
DUPLICATE TARGET DATABASE to dupdb
FROM ACTIVE DATABASE
SPFILE
SET DB_name='dupdb'
SET DB_UNIQUE_NAME='dupdb'
SET CONTROL_FILES='/u01/app/oracle/oradata/dupdb/dupdb.ctl'
SET LOG_FILE_NAME_CONVERT '/u01/app/oracle/oradata/primdb/','/u01/app/oracle/oradata/dupdb/'
SET DB_FILE_NAME_CONVERT '/u01/app/oracle/oradata/primdb/','/u01/app/oracle/oradata/dupdb/'
set db_recovery_file_dest_size '1G'
set db_recovery_file_dest='/u01/app/oracle/fast_recovery_area/dupdb'
set SGA_TARGET '1024M'
SET diagnostic_dest='/u01/app/oracle/'
; }2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16>
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: SID=60 device type=DISK
allocated channel: c2
channel c2: SID=35 device type=DISK
Starting Duplicate Db at 08-APR-22
current log archived
contents of Memory Script:
{
restore clone from service 'primdb' spfile to
'/u01/app/oracle/product/12.2.0/db_1/dbs/spfiledupdb.ora';
sql clone "alter system set spfile= ''/u01/app/oracle/product/12.2.0/db_1/dbs/spfiledupdb.ora''";
}
executing Memory Script
Starting restore at 08-APR-22
channel c2: starting datafile backup set restore
channel c2: using network backup set from service primdb
channel c2: restoring SPFILE
output file name=/u01/app/oracle/product/12.2.0/db_1/dbs/spfiledupdb.ora
channel c2: restore complete, elapsed time: 00:00:01
Finished restore at 08-APR-22
sql statement: alter system set spfile= ''/u01/app/oracle/product/12.2.0/db_1/dbs/spfiledupdb.ora''
contents of Memory Script:
{
sql clone "alter system set db_name =
''DUPDB'' comment=
''duplicate'' scope=spfile";
sql clone "alter system set db_name =
''dupdb'' comment=
'''' scope=spfile";
sql clone "alter system set db_unique_name =
''dupdb'' comment=
'''' scope=spfile";
sql clone "alter system set CONTROL_FILES =
''/u01/app/oracle/oradata/dupdb/dupdb.ctl'' comment=
'''' scope=spfile";
sql clone "alter system set LOG_FILE_NAME_CONVERT =
''/u01/app/oracle/oradata/primdb/'', ''/u01/app/oracle/oradata/dupdb/'' comment=
'''' scope=spfile";
sql clone "alter system set db_file_name_convert =
''/u01/app/oracle/oradata/primdb/'', ''/u01/app/oracle/oradata/dupdb/'' comment=
'''' scope=spfile";
sql clone "alter system set db_recovery_file_dest_size =
1G comment=
'''' scope=spfile";
sql clone "alter system set db_recovery_file_dest =
''/u01/app/oracle/fast_recovery_area/dupdb'' comment=
'''' scope=spfile";
sql clone "alter system set SGA_TARGET =
1024M comment=
'''' scope=spfile";
sql clone "alter system set diagnostic_dest =
''/u01/app/oracle/'' comment=
'''' scope=spfile";
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
sql statement: alter system set db_name = ''DUPDB'' comment= ''duplicate'' scope=spfile
sql statement: alter system set db_name = ''dupdb'' comment= '''' scope=spfile
sql statement: alter system set db_unique_name = ''dupdb'' comment= '''' scope=spfile
sql statement: alter system set CONTROL_FILES = ''/u01/app/oracle/oradata/dupdb/dupdb.ctl'' comment= '''' scope=spfile
sql statement: alter system set LOG_FILE_NAME_CONVERT = ''/u01/app/oracle/oradata/primdb/'', ''/u01/app/oracle/oradata/dupdb/'' comment= '''' scope=spfile
sql statement: alter system set db_file_name_convert = ''/u01/app/oracle/oradata/primdb/'', ''/u01/app/oracle/oradata/dupdb/'' comment= '''' scope=spfile
sql statement: alter system set db_recovery_file_dest_size = 1G comment= '''' scope=spfile
sql statement: alter system set db_recovery_file_dest = ''/u01/app/oracle/fast_recovery_area/dupdb'' comment= '''' scope=spfile
sql statement: alter system set SGA_TARGET = 1024M comment= '''' scope=spfile
sql statement: alter system set diagnostic_dest = ''/u01/app/oracle/'' comment= '''' scope=spfile
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 1073741824 bytes
Fixed Size 8628936 bytes
Variable Size 373294392 bytes
Database Buffers 687865856 bytes
Redo Buffers 3952640 bytes
allocated channel: c2
channel c2: SID=35 device type=DISK
contents of Memory Script:
{
sql clone "alter system set db_name =
''PRIMDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''dupdb'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone from service 'primdb' primary controlfile;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''PRIMDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''dupdb'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 1073741824 bytes
Fixed Size 8628936 bytes
Variable Size 373294392 bytes
Database Buffers 687865856 bytes
Redo Buffers 3952640 bytes
allocated channel: c2
channel c2: SID=34 device type=DISK
Starting restore at 08-APR-22
channel c2: starting datafile backup set restore
channel c2: using network backup set from service primdb
channel c2: restoring control file
channel c2: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/dupdb/dupdb.ctl
Finished restore at 08-APR-22
database mounted
contents of Memory Script:
{
set newname for datafile 1 to
"/u01/app/oracle/oradata/dupdb/system01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/dupdb/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/dupdb/undotbs01.dbf";
set newname for datafile 7 to
"/u01/app/oracle/oradata/dupdb/users01.dbf";
restore
from nonsparse from service
'primdb' clone database
;
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
Starting restore at 08-APR-22
channel c2: starting datafile backup set restore
channel c2: using network backup set from service primdb
channel c2: specifying datafile(s) to restore from backup set
channel c2: restoring datafile 00001 to /u01/app/oracle/oradata/dupdb/system01.dbf
channel c2: restore complete, elapsed time: 00:00:15
channel c2: starting datafile backup set restore
channel c2: using network backup set from service primdb
channel c2: specifying datafile(s) to restore from backup set
channel c2: restoring datafile 00003 to /u01/app/oracle/oradata/dupdb/sysaux01.dbf
channel c2: restore complete, elapsed time: 00:00:08
channel c2: starting datafile backup set restore
channel c2: using network backup set from service primdb
channel c2: specifying datafile(s) to restore from backup set
channel c2: restoring datafile 00004 to /u01/app/oracle/oradata/dupdb/undotbs01.dbf
channel c2: restore complete, elapsed time: 00:00:03
channel c2: starting datafile backup set restore
channel c2: using network backup set from service primdb
channel c2: specifying datafile(s) to restore from backup set
channel c2: restoring datafile 00007 to /u01/app/oracle/oradata/dupdb/users01.dbf
channel c2: restore complete, elapsed time: 00:00:01
Finished restore at 08-APR-22
sql statement: alter system archive log current
current log archived
contents of Memory Script:
{
restore clone force from service 'primdb'
archivelog from scn 1524187;
switch clone datafile all;
}
executing Memory Script
Starting restore at 08-APR-22
channel c2: starting archived log restore to default destination
channel c2: using network backup set from service primdb
channel c2: restoring archived log
archived log thread=1 sequence=4
channel c2: restore complete, elapsed time: 00:00:00
channel c2: starting archived log restore to default destination
channel c2: using network backup set from service primdb
channel c2: restoring archived log
archived log thread=1 sequence=5
channel c2: restore complete, elapsed time: 00:00:01
Finished restore at 08-APR-22
datafile 1 switched to datafile copy
input datafile copy RECID=5 STAMP=1101498796 file name=/u01/app/oracle/oradata/dupdb/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=6 STAMP=1101498796 file name=/u01/app/oracle/oradata/dupdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=7 STAMP=1101498796 file name=/u01/app/oracle/oradata/dupdb/undotbs01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=8 STAMP=1101498796 file name=/u01/app/oracle/oradata/dupdb/users01.dbf
contents of Memory Script:
{
set until scn 1524309;
recover
clone database
delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 08-APR-22
starting media recovery
archived log for thread 1 with sequence 4 is already on disk as file /u01/app/oracle/fast_recovery_area/dupdb/DUPDB/archivelog/2022_04_08/o1_mf_1_4_k51lqct0_.arc
archived log for thread 1 with sequence 5 is already on disk as file /u01/app/oracle/fast_recovery_area/dupdb/DUPDB/archivelog/2022_04_08/o1_mf_1_5_k51lqd0p_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/dupdb/DUPDB/archivelog/2022_04_08/o1_mf_1_4_k51lqct0_.arc thread=1 sequence=4
archived log file name=/u01/app/oracle/fast_recovery_area/dupdb/DUPDB/archivelog/2022_04_08/o1_mf_1_5_k51lqd0p_.arc thread=1 sequence=5
media recovery complete, elapsed time: 00:00:00
Finished recover at 08-APR-22
released channel: c1
released channel: c2
Oracle instance started
Total System Global Area 1073741824 bytes
Fixed Size 8628936 bytes
Variable Size 373294392 bytes
Database Buffers 687865856 bytes
Redo Buffers 3952640 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''DUPDB'' comment=
''Reset to original value by RMAN'' scope=spfile";
sql clone "alter system reset db_unique_name scope=spfile";
}
executing Memory Script
sql statement: alter system set db_name = ''DUPDB'' comment= ''Reset to original value by RMAN'' scope=spfile
sql statement: alter system reset db_unique_name scope=spfile
Oracle instance started
Total System Global Area 1073741824 bytes
Fixed Size 8628936 bytes
Variable Size 373294392 bytes
Database Buffers 687865856 bytes
Redo Buffers 3952640 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUPDB" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 100
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/dupdb/redo01.log' ) SIZE 200 M REUSE,
GROUP 2 ( '/u01/app/oracle/oradata/dupdb/redo02.log' ) SIZE 200 M REUSE,
GROUP 3 ( '/u01/app/oracle/oradata/dupdb/redo03.log' ) SIZE 200 M REUSE
DATAFILE
'/u01/app/oracle/oradata/dupdb/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/dupdb/temp01.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/dupdb/sysaux01.dbf",
"/u01/app/oracle/oradata/dupdb/undotbs01.dbf",
"/u01/app/oracle/oradata/dupdb/users01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/dupdb/temp01.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/sysaux01.dbf RECID=1 STAMP=1101498825
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/undotbs01.dbf RECID=2 STAMP=1101498825
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupdb/users01.dbf RECID=3 STAMP=1101498825
datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=1101498825 file name=/u01/app/oracle/oradata/dupdb/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=1101498825 file name=/u01/app/oracle/oradata/dupdb/undotbs01.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=3 STAMP=1101498825 file name=/u01/app/oracle/oradata/dupdb/users01.dbf
contents of Memory Script:
{
Alter clone database open resetlogs;
}
executing Memory Script
database opened
Finished Duplicate Db at 08-APR-22
Comments
Post a Comment