参考手册:
25.5.3.4 Duplicating a PDB to a New CDB
初始化环境准备
克隆pdb01 到新的cdb test1.
1.配置test1静态监听
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = test1)
)
)
LISTENER =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = db02)(PORT = 1521))
2,配置test1 启动参数文件
//test1配置auxiliary instance
inittest1.ora
*.db_name='test1'
*.enable_pluggable_database=true
3,启动test1到nomount状态
[oracle@db02 dbs]$ export ORACLE_SID=test1
[oracle@db02 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jul 26 22:09:48 2021
Version 19.11.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.11.0.0.0
SQL> startup nomount
ORACLE instance started.
Total System Global Area 524287104 bytes
Fixed Size 9137280 bytes
Variable Size 373293056 bytes
Database Buffers 134217728 bytes
Redo Buffers 7639040 bytes
4,启动数据库duplicat
[oracle@db02 dbs]$ rman
Recovery Manager: Release 19.0.0.0.0 - Production on Mon Jul 26 22:09:07 2021
Version 19.11.0.0.0
Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.
RMAN> connect target sys/oracle@cdb
connect auxiliary sys/oracle@test1
connected to target database: CDB (DBID=2195211038)
RMAN>
RMAN>
connected to auxiliary database: TEST1 (not mounted)
RMAN>
RMAN> RUN
2> {
3> DUPLICATE DATABASE TO test1 PLUGGABLE DATABASE pdb01
4> DB_FILE_NAME_CONVERT ('/u01/app/oracle/oradata/CDB/','/u01/app/oracle/oradata/test1/')
logfile
5> 6> GROUP 1 ('/u01/app/oracle/oradata/test1/log1_1.log') SIZE 100M,
7> GROUP 2 ('/u01/app/oracle/oradata/test1/log2_1.log') SIZE 100M,
8> GROUP 3 ('/u01/app/oracle/oradata/test1/log3_1.log') SIZE 100M;
9> }
Starting Duplicate Db at 26-JUL-21
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=660 device type=DISK
current log archived
contents of Memory Script:
{
sql clone "create spfile from memory";
}
executing Memory Script
sql statement: create spfile from memory
contents of Memory Script:
{
shutdown clone immediate;
startup clone nomount;
}
executing Memory Script
Oracle instance shut down
connected to auxiliary database (not started)
Oracle instance started
Total System Global Area 524287104 bytes
Fixed Size 9137280 bytes
Variable Size 373293056 bytes
Database Buffers 134217728 bytes
Redo Buffers 7639040 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''CDB'' comment=
''Modified by RMAN duplicate'' scope=spfile";
sql clone "alter system set db_unique_name =
''test1'' comment=
''Modified by RMAN duplicate'' scope=spfile";
shutdown clone immediate;
startup clone force nomount
restore clone primary controlfile;
alter clone database mount;
}
executing Memory Script
sql statement: alter system set db_name = ''CDB'' comment= ''Modified by RMAN duplicate'' scope=spfile
sql statement: alter system set db_unique_name = ''test1'' comment= ''Modified by RMAN duplicate'' scope=spfile
Oracle instance shut down
Oracle instance started
Total System Global Area 524287104 bytes
Fixed Size 9137280 bytes
Variable Size 373293056 bytes
Database Buffers 134217728 bytes
Redo Buffers 7639040 bytes
Starting restore at 26-JUL-21
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=398 device type=DISK
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/19.3/dbs/c-2195211038-20210726-03
channel ORA_AUX_DISK_1: piece handle=/u01/app/19.3/dbs/c-2195211038-20210726-03 tag=TAG20210726T220843
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/19.3/dbs/cntrltest1.dbf
Finished restore at 26-JUL-21
database mounted
Skipping pluggable database PDB001
Skipping pluggable database PDB008
Automatically adding tablespace SYSTEM
Automatically adding tablespace SYSAUX
Automatically adding tablespace PDB$SEED:SYSTEM
Automatically adding tablespace PDB$SEED:SYSAUX
Automatically adding tablespace PDB001:SYSTEM
Automatically adding tablespace PDB008:SYSTEM
Automatically adding tablespace UNDOTBS1
Automatically adding tablespace PDB001:UNDOTBS1
Automatically adding tablespace PDB008:UNDOTBS1
Skipping tablespace USERS
contents of Memory Script:
{
set until scn 3139205;
set newname for datafile 1 to
"/u01/app/oracle/oradata/test1/system01.dbf";
set newname for datafile 3 to
"/u01/app/oracle/oradata/test1/sysaux01.dbf";
set newname for datafile 4 to
"/u01/app/oracle/oradata/test1/undotbs01.dbf";
set newname for datafile 5 to
"/u01/app/oracle/oradata/test1/pdbseed/system01.dbf";
set newname for datafile 6 to
"/u01/app/oracle/oradata/test1/pdbseed/sysaux01.dbf";
set newname for datafile 8 to
"/u01/app/oracle/oradata/test1/pdbseed/undotbs01.dbf";
set newname for datafile 16 to
"/u01/app/oracle/oradata/test1/pdb01/system01.dbf";
set newname for datafile 17 to
"/u01/app/oracle/oradata/test1/pdb01/sysaux01.dbf";
set newname for datafile 18 to
"/u01/app/oracle/oradata/test1/pdb01/undotbs01.dbf";
restore
clone database
skip forever tablespace "USERS",
"PDB001":"USERS",
"PDB001":"UNDOTBS1",
"PDB001":"SYSTEM",
"PDB001":"SYSAUX",
"PDB008":"USERS",
"PDB008":"UNDOTBS1",
"PDB008":"SYSTEM",
"PDB008":"SYSAUX" ;
}
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
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
Starting restore at 26-JUL-21
using channel ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/test1/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/test1/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/test1/undotbs01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/bak/1j04v4e3_51_1_1
channel ORA_AUX_DISK_1: piece handle=/u01/bak/1j04v4e3_51_1_1 tag=TAG20210726T220803
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00016 to /u01/app/oracle/oradata/test1/pdb01/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00017 to /u01/app/oracle/oradata/test1/pdb01/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00018 to /u01/app/oracle/oradata/test1/pdb01/undotbs01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/bak/1m04v4et_54_1_1
channel ORA_AUX_DISK_1: piece handle=/u01/bak/1m04v4et_54_1_1 tag=TAG20210726T220803
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/test1/pdbseed/system01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/test1/pdbseed/sysaux01.dbf
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/test1/pdbseed/undotbs01.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/bak/1n04v4f4_55_1_1
channel ORA_AUX_DISK_1: piece handle=/u01/bak/1n04v4f4_55_1_1 tag=TAG20210726T220803
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 26-JUL-21
contents of Memory Script:
{
switch clone datafile all;
}
executing Memory Script
datafile 1 switched to datafile copy
input datafile copy RECID=25 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/system01.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=26 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=27 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/undotbs01.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=28 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/pdbseed/system01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=29 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/pdbseed/sysaux01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=30 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/pdbseed/undotbs01.dbf
datafile 16 switched to datafile copy
input datafile copy RECID=31 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/pdb01/system01.dbf
datafile 17 switched to datafile copy
input datafile copy RECID=32 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/pdb01/sysaux01.dbf
datafile 18 switched to datafile copy
input datafile copy RECID=33 STAMP=1078956733 file name=/u01/app/oracle/oradata/test1/pdb01/undotbs01.dbf
contents of Memory Script:
{
set until scn 3139205;
recover
clone database
skip forever tablespace "USERS",
"PDB001":"USERS",
"PDB001":"UNDOTBS1",
"PDB001":"SYSTEM",
"PDB001":"SYSAUX",
"PDB008":"USERS",
"PDB008":"UNDOTBS1",
"PDB008":"SYSTEM",
"PDB008":"SYSAUX" delete archivelog
;
}
executing Memory Script
executing command: SET until clause
Starting recover at 26-JUL-21
using channel ORA_AUX_DISK_1
Executing: alter database datafile 7 offline drop
Executing: alter database datafile 26 offline drop
Executing: alter database datafile 25 offline drop
Executing: alter database datafile 23 offline drop
Executing: alter database datafile 24 offline drop
Executing: alter database datafile 30 offline drop
Executing: alter database datafile 29 offline drop
Executing: alter database datafile 27 offline drop
Executing: alter database datafile 28 offline drop
starting media recovery
archived log for thread 1 with sequence 15 is already on disk as file /u01/arc/1_15_1078619944.dbf
archived log file name=/u01/arc/1_15_1078619944.dbf thread=1 sequence=15
media recovery complete, elapsed time: 00:00:00
Finished recover at 26-JUL-21
Oracle instance started
Total System Global Area 524287104 bytes
Fixed Size 9137280 bytes
Variable Size 373293056 bytes
Database Buffers 134217728 bytes
Redo Buffers 7639040 bytes
contents of Memory Script:
{
sql clone "alter system set db_name =
''TEST1'' 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 = ''TEST1'' 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 524287104 bytes
Fixed Size 9137280 bytes
Variable Size 373293056 bytes
Database Buffers 134217728 bytes
Redo Buffers 7639040 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "TEST1" RESETLOGS ARCHIVELOG
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
MAXINSTANCES 8
MAXLOGHISTORY 292
LOGFILE
GROUP 1 ( '/u01/app/oracle/oradata/test1/log1_1.log' ) SIZE 100 M ,
GROUP 2 ( '/u01/app/oracle/oradata/test1/log2_1.log' ) SIZE 100 M ,
GROUP 3 ( '/u01/app/oracle/oradata/test1/log3_1.log' ) SIZE 100 M
DATAFILE
'/u01/app/oracle/oradata/test1/system01.dbf',
'/u01/app/oracle/oradata/test1/pdbseed/system01.dbf',
'/u01/app/oracle/oradata/test1/pdb01/system01.dbf'
CHARACTER SET AL32UTF8
contents of Memory Script:
{
set newname for tempfile 1 to
"/u01/app/oracle/oradata/test1/temp01.dbf";
set newname for tempfile 2 to
"/u01/app/oracle/oradata/test1/pdbseed/temp012021-07-22_21-20-23-752-PM.dbf";
set newname for tempfile 4 to
"/u01/app/oracle/oradata/test1/pdb01/temp012021-07-22_21-20-23-752-PM.dbf";
switch clone tempfile all;
catalog clone datafilecopy "/u01/app/oracle/oradata/test1/sysaux01.dbf",
"/u01/app/oracle/oradata/test1/undotbs01.dbf",
"/u01/app/oracle/oradata/test1/pdbseed/sysaux01.dbf",
"/u01/app/oracle/oradata/test1/pdbseed/undotbs01.dbf",
"/u01/app/oracle/oradata/test1/pdb01/sysaux01.dbf",
"/u01/app/oracle/oradata/test1/pdb01/undotbs01.dbf";
switch clone datafile all;
}
executing Memory Script
executing command: SET NEWNAME
executing command: SET NEWNAME
executing command: SET NEWNAME
renamed tempfile 1 to /u01/app/oracle/oradata/test1/temp01.dbf in control file
renamed tempfile 2 to /u01/app/oracle/oradata/test1/pdbseed/temp012021-07-22_21-20-23-752-PM.dbf in control file
renamed tempfile 4 to /u01/app/oracle/oradata/test1/pdb01/temp012021-07-22_21-20-23-752-PM.dbf in control file
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/test1/sysaux01.dbf RECID=1 STAMP=1078956758
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/test1/undotbs01.dbf RECID=2 STAMP=1078956758
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/test1/pdbseed/sysaux01.dbf RECID=3 STAMP=1078956758
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/test1/pdbseed/undotbs01.dbf RECID=4 STAMP=1078956758
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/test1/pdb01/sysaux01.dbf RECID=5 STAMP=1078956758
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/test1/pdb01/undotbs01.dbf RECID=6 STAMP=1078956758
datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=1078956758 file name=/u01/app/oracle/oradata/test1/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=1078956758 file name=/u01/app/oracle/oradata/test1/undotbs01.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=1078956758 file name=/u01/app/oracle/oradata/test1/pdbseed/sysaux01.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=4 STAMP=1078956758 file name=/u01/app/oracle/oradata/test1/pdbseed/undotbs01.dbf
datafile 17 switched to datafile copy
input datafile copy RECID=5 STAMP=1078956758 file name=/u01/app/oracle/oradata/test1/pdb01/sysaux01.dbf
datafile 18 switched to datafile copy
input datafile copy RECID=6 STAMP=1078956758 file name=/u01/app/oracle/oradata/test1/pdb01/undotbs01.dbf
contents of Memory Script:
{
sql clone 'alter system set "_system_trig_enabled"=FALSE';
Alter clone database open resetlogs;
sql clone 'alter system reset "_system_trig_enabled"';
}
executing Memory Script
sql statement: alter system set "_system_trig_enabled"=FALSE
database opened
sql statement: alter system reset "_system_trig_enabled"
Executing: drop pluggable database "PDB001" including datafiles
Executing: drop pluggable database "PDB008" including datafiles
contents of Memory Script:
{
sql clone "alter pluggable database all open";
}
executing Memory Script
sql statement: alter pluggable database all open
Dropping offline and skipped tablespaces
Executing: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Cannot remove created server parameter file
Finished Duplicate Db at 26-JUL-21
RMAN>
5,检查新的cdb test1状态
[oracle@db02 dbs]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jul 26 22:22:17 2021
Version 19.11.0.0.0
Copyright (c) 1982, 2020, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.11.0.0.0
SQL> show pdbs;
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
4 PDB01 READ WRITE NO
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




