In Oracle Database 12c, it is possible to use the DUPLICATE command at the PDB level. However, there is a limitation: a new CDB must also be created as part of the duplication process. Otherwise, the operation fails with an error.
[oracle@cdb2 ~]$ rman target sys/sys@cdb1 auxiliary sys/sys@cdb2
connected to target database: cdb1 (DBID=4178530773)
connected to auxiliary database: cdb2 (DBID=839691519)
RMAN> DUPLICATE DATABASE TO CDB2 PLUGGABLE DATABASE pdb12c;
RMAN-05500: the auxiliary database must be not mounted when issuing a DUPLICATE command
Starting with Oracle Database 18c, a PDB can be duplicated into an existing CDB. This is a new capability in Oracle Database 18c. The following example demonstrates how to perform this operation.
In this example, the PDB18C PDB in CDB1 is duplicated into CDB2.
During the duplication process, changes may occur in the source PDB (CDB1). At the end of the duplication, these changes are applied to the target PDB (CDB2) through archived redo logs.
Therefore, before starting the duplication, you must specify the location where the archived redo logs transferred from CDB1 to CDB2 will be stored. This can be configured using the REMOTE_RECOVERY_FILE_DEST parameter.
CDB2
[oracle@cdb2 ~]$ mkdir /18c/remote_arch
SQL> alter system set REMOTE_RECOVERY_FILE_DEST=’/18c/remote_arch’;
System altered.
After setting this parameter, use RMAN to duplicate PDB18C by running the DUPLICATE PLUGGABLE DATABASE command.
CDB2
[oracle@cdb2 ~]$ rman target sys/sys@CDB1 auxiliary sys/sys@cdb2
Recovery Manager: Release 18.0.0.0.0 – Production on Wed Jun 27 10:14:44 2018
Version 18.1.0.0.0
Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved.
connected to target database: CDB1 (DBID=961316182)
connected to auxiliary database: CDB2 (DBID=1453270123)
RMAN>DUPLICATE PLUGGABLE DATABASE Pdb18c TO CDB2 FROM ACTIVE DATABASE;
Starting Duplicate PDB at 27-JUN-18
contents of Memory Script:
{
set newname for clone datafile 60 to new;
set newname for clone datafile 61 to new;
set newname for clone datafile 62 to new;
restore from nonsparse clone foreign pluggable database “PDB18C” from service ‘CDB1’ ;
}
channel ORA_AUX_DISK_1: using network backup set from service CDB1
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring foreign file 62 to /u02/18c/base/oradata/CDB2/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_undotbs1_fjt6gfbd_.dbf
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 27-JUN-18
contents of Memory Script:
{
set archivelog destination to ‘/18c/remote_arch’;
restore clone force from service ‘CDB1’ foreign archivelog from scn 19590084;
}
executing command: SET ARCHIVELOG DESTINATION
Starting restore at 27-JUN-18
archived log destination=/18c/remote_arch
channel ORA_AUX_DISK_1: using network backup set from service CDB1
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=203
Finished Duplicate PDB at 27-JUN-18
Changes in the Source CDB
The alert log of CDB1 shows that redo was generated and archived while the PDB duplication was in progress:
CDB1 — Alert Log
2018-06-27T13:12:33.969208+04:30
ALTER SYSTEM ARCHIVE LOG
2018-06-27T13:13:10.553587+04:30
NET (PID:24220): Archived Log entry 263 added for T-1.S-202 ID 0x3959dcd8 LAD:1
2018-06-27T13:13:10.582768+04:30
ALTER SYSTEM ARCHIVE LOG
2018-06-27T13:13:10.588942+04:30
Thread 1 advanced to log sequence 204 (LGWR switch)
Current log# 2 seq# 204 mem# 0: /u01/18c_oradata/CDB1/onlinelog/o1_mf_2_fd0wlk11_.log
2018-06-27T13:13:10.591765+04:30
NET (PID:24220): Archived Log entry 264 added for T-1.S-203 ID 0x3959dcd8 LAD:1
These archived redo logs are transferred to CDB2 and used during the duplication process.
Changes in the Target CDB
The alert log of CDB2 shows the creation and initialization of the cloned PDB.
CDB2 — Alert Log
Full restore complete of datafile 62 to datafile copy /u02/18c/base/oradata/CDB2/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_undotbs1_fjt6gfbd_.dbf. Elapsed time: 0:00:00
checkpoint is 19590167
last deallocation scn is 19577386
Undo Optimization current scn is 19587396
2018-06-27T13:13:24.011604+04:30
CREATE PLUGGABLE DATABASE Pdb18c AS CLONE USING ‘/u02/18c/home/dbs/_rm_pdb_pitr_7_cdb2.xml’ SOURCE_FILE_NAME_CONVERT = ( ‘/u01/18c_oradata/CDB1/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_temp_fm67zx39_.dbf’ , ‘/u02/18c/base/oradata/CDB2/6F99DAD756624AF9E0530488200A4A05/datafile/cl_Bm_mf_temp_fm67zx39_.dbf’,‘/u01/18c_oradata/CDB1/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_system_fm67zx30_.dbf’ , ‘/u02/18c/base/oradata/CDB2/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_system_l0t6gfam_.dbf’ , ‘/u01/18c_oradata/CDB1/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_sysaux_fm67zx38_.dbf’ , ‘/u02/18c/base/oradata/CDB2/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_sysaux_lvt6gfau_.dbf’ , ‘/u01/18c_oradata/CDB1/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_undotbs1_fm67zx39_.dbf’ , ‘/u02/18c/base/oradata/CDB2/6F99DAD756624AF9E0530488200A4A05/datafile/o1_mf_undotbs1_fjt6gfbd_.dbf’ ) NOCOPY REFRESH MODE MANUAL
2018-06-27T13:13:24.226142+04:30
PDB18C(5):ALTER SYSTEM SET remote_recovery_file_dest=’/18c/remote_arch’ SCOPE=SPFILE PDB=’PDB18C’;
PDB18C(5):alter pluggable database refresh
PDB18C(5):Completed: alter pluggable database refresh
PDB18C(5):alter pluggable database refresh mode none
PDB18C(5):Undo initialization recovery: err:0 start: 351874245 end: 351874276 diff: 31 ms (0.0 seconds)
PDB18C(5):[7385] Successfully onlined Undo Tablespace 2.
PDB18C(5):Undo initialization online undo segments: err:0 start: 351874276 end: 351874287 diff: 11 ms (0.0 seconds)
PDB18C(5):Database Characterset for PDB18C is AL32UTF8
PDB18C(5):JIT: pid 7385 requesting stop
PDB18C(5):While transitioning the pdb 5 to clean state, clearing all its abort bits in the control file.
PDB18C(5):Completed: alter pluggable database refresh mode none
PDB18C(5):alter pluggable database open
PDB18C(5):Undo initialization recovery: err:0 start: 351875056 end: 351875060 diff: 4 ms (0.0 seconds)
PDB18C(5):[7385] Successfully onlined Undo Tablespace 2.
PDB18C(5):Undo initialization online undo segments: err:0 start: 351875061 end: 351875085 diff: 24 ms (0.0 seconds)
PDB18C(5):Undo initialization finished serial:0 start:351875056 end:351875086 diff:30 ms (0.0 seconds)
Opatch validation is skipped for PDB PDB18C (con_id=5)
PDB18C(5):Adding new file#37 to file$(old file#60). fopr-0, newblks-32000, oldblks-19200
PDB18C(5):Adding new file#38 to file$(old file#61). fopr-0, newblks-47360, oldblks-15360
PDB18C(5):Adding new file#39 to file$(old file#62). fopr-0, newblks-12800, oldblks-12800
PDB18C(5):Successfully created internal service PDB18C at open
Pluggable database PDB18C opened in upgrade mode
PDB18C(5):Completed: alter pluggable database open
PDB18C(5):alter pluggable database close immediate
Pluggable database PDB18C closed
PDB18C(5):Completed: alter pluggable database close immediate
PDB18C(5):alter pluggable database open
PDB18C(5):[7385] Successfully onlined Undo Tablespace 2.
PDB18C(5):Database Characterset for PDB18C is AL32UTF8
Pluggable database PDB18C opened read write
PDB18C(5):Completed: alter pluggable database open
Verify the Duplicated PDB
You can connect to CDB2 and verify that PDB18C has been created successfully and is open in read/write mode:
CDB2
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
———- —————————— ———- ———-
2 PDB$SEED READ ONLY NO
5 PDB18C READ WRITE NO
As shown above, PDB18C is available in CDB2 and is open in READ WRITE mode.
Remove the Archived Redo Logs
After the duplication is complete, you can remove the archived redo logs that were transferred to CDB2 for the duplication operation.
[root@cdb2 ~]# cd /18c/remote_arch
[root@cdb2 remote_arch]# ls -l
-rw-r—– 1 oracle oinstall 24064 Jun 27 13:13 1_202_972296216.dbf
-rw-r—– 1 oracle oinstall 1024 Jun 27 13:13 1_203_972296216.dbf
[root@cdb2 remote_arch]# rm -rf /18c/remote_arch/*
Changing the PDB Name During Duplication
You can also specify a different name for the duplicated PDB in CDB2.
For example, the following command duplicates PDB18C from CDB1 and creates the PDB as PDB18C_NEW in CDB2:
DUPLICATE PLUGGABLE DATABASE Pdb18c as pdb18c_new TO CDB2 FROM ACTIVE DATABASE;
Top comments (0)