2024. 9. 23. 22:32 오라클
rman duplicate skip tablespace
특정 Tablspace 를 제외시키고 duplicate 가 가능한지 테스트 해봄
원본에 TEST 라는 tablespace 를 만들고 복제를 진행한다.
SQL> create tablespace TEST datafile '/oracle/app/oracle/oradata/ORCL/test01.dbf' size 100M;
RMAN> DUPLICATE DATABASE TO ORCL2 skip tablespace 'TEST' 
2> FROM ACTIVE DATABASE 
3> SPFILE 
4> parameter_value_convert ('ORCL','ORCL2') 
5> set db_file_name_convert='/oracle/app/oracle/oradata/ORCL/','/oracle/app/oracle/oradata/ORCL2/' 
6> set log_file_name_convert='/oracle/app/oracle/oradata/ORCL/','/oracle/app/oracle/oradata/ORCL2/' 
7> set control_files='/oracle/app/oracle/oradata/ORCL2/control01.ctl','/oracle/app/oracle/oradata/ORCL2/control02.ctl' 
8> set log_archive_dest_1='location=/oracle/archive2' 
9> ; 
10> 
Starting Duplicate Db at 2024-09-23:22:05:56 
using target database control file instead of recovery catalog 
allocated channel: ORA_AUX_DISK_1 
channel ORA_AUX_DISK_1: SID=38 device type=DISK 
current log archived 
contents of Memory Script: 
{ 
   restore clone from service  'ORCL' spfile to 
 '/oracle/app/oracle/product/19.0.0/dbs/spfileORCL2.ora'; 
   sql clone "alter system set spfile= ''/oracle/app/oracle/product/19.0.0/dbs/spfileORCL2.ora''"; 
} 
executing Memory Script 
Starting restore at 2024-09-23:22:05:58 
using channel ORA_AUX_DISK_1 
channel ORA_AUX_DISK_1: starting datafile backup set restore 
channel ORA_AUX_DISK_1: using network backup set from service ORCL 
channel ORA_AUX_DISK_1: restoring SPFILE 
output file name=/oracle/app/oracle/product/19.0.0/dbs/spfileORCL2.ora 
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 
Finished restore at 2024-09-23:22:06:02 
sql statement: alter system set spfile= ''/oracle/app/oracle/product/19.0.0/dbs/spfileORCL2.ora'' 
contents of Memory Script: 
{ 
   sql clone "alter system set  db_name = 
 ''ORCL2'' comment= 
 ''duplicate'' scope=spfile"; 
   sql clone "alter system set  audit_file_dest = 
 ''/oracle/app/oracle/admin/ORCL2/adump'' comment= 
 '''' scope=spfile"; 
   sql clone "alter system set  db_name = 
 ''ORCL2'' comment= 
 '''' scope=spfile"; 
   sql clone "alter system set  dispatchers = 
 ''(PROTOCOL=TCP) (SERVICE=ORCL2XDB)'' comment= 
 '''' scope=spfile"; 
   sql clone "alter system set  local_listener = 
 ''LISTENER_ORCL2'' comment= 
 '''' scope=spfile"; 
   sql clone "alter system set  db_file_name_convert = 
 ''/oracle/app/oracle/oradata/ORCL/'', ''/oracle/app/oracle/oradata/ORCL2/'' comment= 
 '''' scope=spfile"; 
   sql clone "alter system set  log_file_name_convert = 
 ''/oracle/app/oracle/oradata/ORCL/'', ''/oracle/app/oracle/oradata/ORCL2/'' comment= 
 '''' scope=spfile"; 
   sql clone "alter system set  control_files = 
 ''/oracle/app/oracle/oradata/ORCL2/control01.ctl'', ''/oracle/app/oracle/oradata/ORCL2/control02.ctl'' comment= 
 '''' scope=spfile"; 
   sql clone "alter system set  log_archive_dest_1 = 
 ''location=/oracle/archive2'' comment= 
 '''' scope=spfile"; 
   shutdown clone immediate; 
   startup clone nomount; 
} 
executing Memory Script 
sql statement: alter system set  db_name =  ''ORCL2'' comment= ''duplicate'' scope=spfile 
sql statement: alter system set  audit_file_dest =  ''/oracle/app/oracle/admin/ORCL2/adump'' comment= '''' scope=spfile 
sql statement: alter system set  db_name =  ''ORCL2'' comment= '''' scope=spfile 
sql statement: alter system set  dispatchers =  ''(PROTOCOL=TCP) (SERVICE=ORCL2XDB)'' comment= '''' scope=spfile 
sql statement: alter system set  local_listener =  ''LISTENER_ORCL2'' comment= '''' scope=spfile 
sql statement: alter system set  db_file_name_convert =  ''/oracle/app/oracle/oradata/ORCL/'', ''/oracle/app/oracle/oradata/ORCL2/'' comment= '''' scope=spfile 
sql statement: alter system set  log_file_name_convert =  ''/oracle/app/oracle/oradata/ORCL/'', ''/oracle/app/oracle/oradata/ORCL2/'' comment= '''' scope=spfile 
sql statement: alter system set  control_files =  ''/oracle/app/oracle/oradata/ORCL2/control01.ctl'', ''/oracle/app/oracle/oradata/ORCL2/control02.ctl'' comment= '''' scope=spfile 
sql statement: alter system set  log_archive_dest_1 =  ''location=/oracle/archive2'' comment= '''' scope=spfile 
Oracle instance shut down 
connected to auxiliary database (not started) 
Oracle instance started 
Total System Global Area    3690983864 bytes 
Fixed Size                     8946104 bytes 
Variable Size                721420288 bytes 
Database Buffers            2952790016 bytes 
Redo Buffers                   7827456 bytes 
contents of Memory Script: 
{ 
   sql clone "alter system set  db_name = 
 ''ORCL'' comment= 
 ''Modified by RMAN duplicate'' scope=spfile"; 
   sql clone "alter system set  db_unique_name = 
 ''ORCL2'' comment= 
 ''Modified by RMAN duplicate'' scope=spfile"; 
   shutdown clone immediate; 
   startup clone force nomount 
   restore clone from service  'ORCL' primary controlfile; 
   alter clone database mount; 
} 
executing Memory Script 
sql statement: alter system set  db_name =  ''ORCL'' comment= ''Modified by RMAN duplicate'' scope=spfile 
sql statement: alter system set  db_unique_name =  ''ORCL2'' comment= ''Modified by RMAN duplicate'' scope=spfile 
Oracle instance shut down 
Oracle instance started 
Total System Global Area    3690983864 bytes 
Fixed Size                     8946104 bytes 
Variable Size                721420288 bytes 
Database Buffers            2952790016 bytes 
Redo Buffers                   7827456 bytes 
Starting restore at 2024-09-23:22:06:54 
allocated channel: ORA_AUX_DISK_1 
channel ORA_AUX_DISK_1: SID=35 device type=DISK 
channel ORA_AUX_DISK_1: starting datafile backup set restore 
channel ORA_AUX_DISK_1: using network backup set from service ORCL 
channel ORA_AUX_DISK_1: restoring control file 
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 
output file name=/oracle/app/oracle/oradata/ORCL2/control01.ctl 
output file name=/oracle/app/oracle/oradata/ORCL2/control02.ctl 
Finished restore at 2024-09-23:22:06:59 
database mounted 
Checking that duplicated tablespaces are self-contained 
Datafile 5 skipped by request 
contents of Memory Script: 
{ 
   set newname for datafile  1 to 
 "/oracle/app/oracle/oradata/ORCL2/system01.dbf"; 
   set newname for datafile  2 to 
 "/oracle/app/oracle/oradata/ORCL2/sysaux01.dbf"; 
   set newname for datafile  3 to 
 "/oracle/app/oracle/oradata/ORCL2/undotbs01.dbf"; 
   set newname for datafile  4 to 
 "/oracle/app/oracle/oradata/ORCL2/users01.dbf"; 
   restore 
   from  nonsparse   from service 
 'ORCL'   clone database 
   skip forever tablespace  "TEST"   ; 
   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 2024-09-23:22:07:09 
using channel ORA_AUX_DISK_1 
channel ORA_AUX_DISK_1: starting datafile backup set restore 
channel ORA_AUX_DISK_1: using network backup set from service ORCL 
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set 
channel ORA_AUX_DISK_1: restoring datafile 00001 to /oracle/app/oracle/oradata/ORCL2/system01.dbf 
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03 
channel ORA_AUX_DISK_1: starting datafile backup set restore 
channel ORA_AUX_DISK_1: using network backup set from service ORCL 
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set 
channel ORA_AUX_DISK_1: restoring datafile 00002 to /oracle/app/oracle/oradata/ORCL2/sysaux01.dbf 
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03 
channel ORA_AUX_DISK_1: starting datafile backup set restore 
channel ORA_AUX_DISK_1: using network backup set from service ORCL 
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set 
channel ORA_AUX_DISK_1: restoring datafile 00003 to /oracle/app/oracle/oradata/ORCL2/undotbs01.dbf 
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 
channel ORA_AUX_DISK_1: starting datafile backup set restore 
channel ORA_AUX_DISK_1: using network backup set from service ORCL 
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set 
channel ORA_AUX_DISK_1: restoring datafile 00004 to /oracle/app/oracle/oradata/ORCL2/users01.dbf 
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 
Finished restore at 2024-09-23:22:07:18 
sql statement: alter system archive log current 
current log archived 
contents of Memory Script: 
{ 
   restore clone force from service  'ORCL' 
           archivelog from scn  1346295; 
   switch clone datafile all; 
} 
executing Memory Script 
Starting restore at 2024-09-23:22:07:19 
using channel ORA_AUX_DISK_1 
channel ORA_AUX_DISK_1: starting archived log restore to default destination 
channel ORA_AUX_DISK_1: using network backup set from service ORCL 
channel ORA_AUX_DISK_1: restoring archived log 
archived log thread=1 sequence=71 
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 
channel ORA_AUX_DISK_1: starting archived log restore to default destination 
channel ORA_AUX_DISK_1: using network backup set from service ORCL 
channel ORA_AUX_DISK_1: restoring archived log 
archived log thread=1 sequence=72 
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 
Finished restore at 2024-09-23:22:07:21 
datafile 1 switched to datafile copy 
input datafile copy RECID=5 STAMP=1180476441 file name=/oracle/app/oracle/oradata/ORCL2/system01.dbf 
datafile 2 switched to datafile copy 
input datafile copy RECID=6 STAMP=1180476441 file name=/oracle/app/oracle/oradata/ORCL2/sysaux01.dbf 
datafile 3 switched to datafile copy 
input datafile copy RECID=7 STAMP=1180476441 file name=/oracle/app/oracle/oradata/ORCL2/undotbs01.dbf 
datafile 4 switched to datafile copy 
input datafile copy RECID=8 STAMP=1180476441 file name=/oracle/app/oracle/oradata/ORCL2/users01.dbf 
contents of Memory Script: 
{ 
   set until scn  1346449; 
   recover 
   clone database 
   skip forever tablespace  "TEST"    delete archivelog 
   ; 
} 
executing Memory Script 
executing command: SET until clause 
Starting recover at 2024-09-23:22:07:21 
using channel ORA_AUX_DISK_1 
Executing: alter database datafile 5 offline drop 
starting media recovery 
archived log for thread 1 with sequence 71 is already on disk as file /oracle/archive2/arch_1_1151767787_71.arc 
archived log for thread 1 with sequence 72 is already on disk as file /oracle/archive2/arch_1_1151767787_72.arc 
archived log file name=/oracle/archive2/arch_1_1151767787_71.arc thread=1 sequence=71 
archived log file name=/oracle/archive2/arch_1_1151767787_72.arc thread=1 sequence=72 
media recovery complete, elapsed time: 00:00:00 
Finished recover at 2024-09-23:22:07:22 
contents of Memory Script: 
{ 
   delete clone force archivelog all; 
} 
executing Memory Script 
released channel: ORA_AUX_DISK_1 
allocated channel: ORA_DISK_1 
channel ORA_DISK_1: SID=85 device type=DISK 
deleted archived log 
archived log file name=/oracle/archive2/arch_1_1151767787_71.arc RECID=1 STAMP=1180476439 
deleted archived log 
archived log file name=/oracle/archive2/arch_1_1151767787_72.arc RECID=2 STAMP=1180476440 
Deleted 2 objects 
Oracle instance started 
Total System Global Area    3690983864 bytes 
Fixed Size                     8946104 bytes 
Variable Size                721420288 bytes 
Database Buffers            2952790016 bytes 
Redo Buffers                   7827456 bytes 
contents of Memory Script: 
{ 
   sql clone "alter system set  db_name = 
 ''ORCL2'' 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 =  ''ORCL2'' 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    3690983864 bytes 
Fixed Size                     8946104 bytes 
Variable Size                721420288 bytes 
Database Buffers            2952790016 bytes 
Redo Buffers                   7827456 bytes 
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "ORCL2" RESETLOGS ARCHIVELOG 
  MAXLOGFILES     16 
  MAXLOGMEMBERS      3 
  MAXDATAFILES      100 
  MAXINSTANCES     8 
  MAXLOGHISTORY      292 
 LOGFILE 
  GROUP     1 ( '/oracle/app/oracle/oradata/ORCL2/redo01.log' ) SIZE 200 M  REUSE, 
  GROUP     2 ( '/oracle/app/oracle/oradata/ORCL2/redo02.log' ) SIZE 200 M  REUSE, 
  GROUP     3 ( '/oracle/app/oracle/oradata/ORCL2/redo03.log' ) SIZE 200 M  REUSE 
 DATAFILE 
  '/oracle/app/oracle/oradata/ORCL2/system01.dbf' 
 CHARACTER SET AL32UTF8 
contents of Memory Script: 
{ 
   set newname for tempfile  1 to 
 "/oracle/app/oracle/oradata/ORCL2/temp01.dbf"; 
   switch clone tempfile all; 
   catalog clone datafilecopy  "/oracle/app/oracle/oradata/ORCL2/sysaux01.dbf", 
 "/oracle/app/oracle/oradata/ORCL2/undotbs01.dbf", 
 "/oracle/app/oracle/oradata/ORCL2/users01.dbf"; 
   switch clone datafile all; 
} 
executing Memory Script 
executing command: SET NEWNAME 
renamed tempfile 1 to /oracle/app/oracle/oradata/ORCL2/temp01.dbf in control file 
cataloged datafile copy 
datafile copy file name=/oracle/app/oracle/oradata/ORCL2/sysaux01.dbf RECID=1 STAMP=1180476479 
cataloged datafile copy 
datafile copy file name=/oracle/app/oracle/oradata/ORCL2/undotbs01.dbf RECID=2 STAMP=1180476479 
cataloged datafile copy 
datafile copy file name=/oracle/app/oracle/oradata/ORCL2/users01.dbf RECID=3 STAMP=1180476479 
datafile 2 switched to datafile copy 
input datafile copy RECID=1 STAMP=1180476479 file name=/oracle/app/oracle/oradata/ORCL2/sysaux01.dbf 
datafile 3 switched to datafile copy 
input datafile copy RECID=2 STAMP=1180476479 file name=/oracle/app/oracle/oradata/ORCL2/undotbs01.dbf 
datafile 4 switched to datafile copy 
input datafile copy RECID=3 STAMP=1180476479 file name=/oracle/app/oracle/oradata/ORCL2/users01.dbf 
contents of Memory Script: 
{ 
   Alter clone database open resetlogs; 
} 
executing Memory Script 
database opened 
Dropping offline and skipped tablespaces 
Executing: drop tablespace "TEST" including contents cascade constraints 
Finished Duplicate Db at 2024-09-23:22:08:14 
Recovery Manager complete.
- Source
TABLESPACE_NAME      FILE_NAME                                           TOT_KB      FREE_KB USAGE_P 
-------------------- --------------------------------------------- ------------ ------------ ------- 
SYSAUX               /oracle/app/oracle/oradata/ORCL/sysaux01.dbf       563,200      181,056    67.9 
SYSTEM               /oracle/app/oracle/oradata/ORCL/system01.dbf       716,800      101,888    85.8 
TEST                 /oracle/app/oracle/oradata/ORCL/test01.dbf         102,400      101,376     1.0 
UNDOTBS1             /oracle/app/oracle/oradata/ORCL/undotbs01.dbf      261,120       79,680    69.5 
USERS                /oracle/app/oracle/oradata/ORCL/users01.dbf          5,120        4,096    20.0
- Target
TABLESPACE_NAME      FILE_NAME                                           TOT_KB      FREE_KB USAGE_P 
-------------------- --------------------------------------------- ------------ ------------ ------- 
SYSAUX               /oracle/app/oracle/oradata/ORCL2/sysaux01.dbf      563,200      175,488    68.8 
SYSTEM               /oracle/app/oracle/oradata/ORCL2/system01.dbf      716,800      101,888    85.8 
UNDOTBS1             /oracle/app/oracle/oradata/ORCL2/undotbs01.dbf     261,120       78,656    69.9 
USERS                /oracle/app/oracle/oradata/ORCL2/users01.dbf         5,120        4,096    20.0