Starting with Oracle Database Release 18c, RMAN enables you to use the DUPLICATE command to duplicate a PDB to an existing CDB. This is very useful feature which will allow the CDBs in your environment to duplicate PDBs, instead of having to create additional CDBs for deduplication tasks.
There are some restrictions on PDB duplication to an existing CDB:
- Only active database duplication is supported.
- You can’t duplicate PDB to a standby CDB.
- One PDB can duplicated at a time.
- You can’t skip exclude specific tablespace during PDB duplications. Means partial duplication is not allowed.
- PDB with TDE- Encrypted tablespaces is not supported.
- Only few clauses of the duplicate commands are supported like DB_FILE_NAME_CONVERT, SECTION SIZE etc… some clauses like FARSYNC, LOG_FILE_NAME_CONVERT is not supported. Check oracle documentation for more detail.
Method:
My environment is set up as below and It’s all ready to test the scenario. Check my other blogs, how to install and create 18c database from here.
18c Env. |
CDB Name | PDB Name |
Source | CDB18 | PDB18 |
Destination | CDB_dest | PDB_dest |
The example assumes the following scenario:
- Both Source CDB, CDB18 and destination CDB, CDB_dest are on same VM machine and both CDB’s are 18c compatible.
- The PDB being duplicate PDB18, is in read-write mode.
- Both source and destination CDB’s are open in read write mode with archiving enabled.
1 2 3 4 5 6 7 8 9 10 11 12 |
# SOURCE CDB CDB$ROOT@CDB18> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB18 READ WRITE NO # Destination CDB CDB$ROOT@CDB_DEST> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO |
Now create the directories that will store the duplicate database files on the destination CDB.
1 |
mkdir /u01/app/oracle_base/oradata/CDB_dest/PDB_dest/ |
Set the initialization parameter REMOTE_RECOVERY_FILE_DEST which determines the location to which foreign archived redo log files are restored for the destination CDB.
1 |
CDB$ROOT@CDB_DEST> alter system set REMOTE_RECOVERY_FILE_DEST = '/u01/app/oracle_base/oradata/CDB18/arch' scope=both; |
RMAN duplicate the PDB by using the Duplicate pluggable database command where you connect as Target to the root of the source CDB and as auxiliary to the root of the destination CDB.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
rman target sys/OracL_18@CDB18 auxiliary sys/OracL_18@CDB_dest RMAN> run { allocate channel dx1 type disk; allocate auxiliary channel ax1 type disk; DUPLICATE PLUGGABLE DATABASE PDB18 as PDB_dest TO CDB_dest DB_FILE_NAME_CONVERT('/u01/app/oracle_base/oradata/CDB18/PDB18/','/u01/app/oracle_base/oradata/CDB_dest/PDB_dest/') FROM ACTIVE DATABASE SECTION SIZE 400M; release channel ax1; release channel dx1; } |
Here is the output of RMAN PDB duplication command.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
[oracle@oracle18c PDB_dest]$ rman target sys/OracL_18@CDB18 auxiliary sys/OracL_18@CDB_dest Recovery Manager: Release 18.0.0.0.0 - Production on Mon Mar 5 15:43:10 2018 Version 18.1.0.0.0 Copyright (c) 1982, 2018, Oracle and/or its affiliates. All rights reserved. connected to target database: CDB18 (DBID=1932186046) connected to auxiliary database: CDB_DEST (DBID=1256761197) RMAN> run { allocate channel dx1 type disk; allocate auxiliary channel ax1 type disk; DUPLICATE PLUGGABLE DATABASE PDB18 as PDB_dest TO CDB_dest DB_FILE_NAME_CONVERT('/u01/app/oracle_base/oradata/CDB18/PDB18/','/u01/app/oracle_base/oradata/CDB_dest/PDB_dest/') FROM ACTIVE DATABASE SECTION SIZE 400M; release channel ax1; release channel dx1; } using target database control file instead of recovery catalog allocated channel: dx1 channel dx1: SID=87 device type=DISK allocated channel: ax1 channel ax1: SID=65 device type=DISK Starting Duplicate PDB at 05-MAR-18 current log archived contents of Memory Script: { set newname for datafile 8 to "/u01/app/oracle_base/oradata/CDB_dest/PDB_dest/system01.dbf"; set newname for datafile 9 to "/u01/app/oracle_base/oradata/CDB_dest/PDB_dest/sysaux01.dbf"; set newname for datafile 10 to "/u01/app/oracle_base/oradata/CDB_dest/PDB_dest/undotbs01.dbf"; set newname for datafile 11 to "/u01/app/oracle_base/oradata/CDB_dest/PDB_dest/users01.dbf"; restore from nonsparse section size 400 m clone foreign pluggable database "PDB18" from service 'CDB18' ; } executing Memory Script executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME executing command: SET NEWNAME Starting restore at 05-MAR-18 channel ax1: starting datafile backup set restore channel ax1: using network backup set from service CDB18 channel ax1: specifying datafile(s) to restore from backup set channel ax1: restoring section 1 of 1 channel ax1: restoring foreign file 8 to /u01/app/oracle_base/oradata/CDB_dest/PDB_dest/system01.dbf channel ax1: restore complete, elapsed time: 00:00:07 channel ax1: starting datafile backup set restore channel ax1: using network backup set from service CDB18 channel ax1: specifying datafile(s) to restore from backup set channel ax1: restoring section 1 of 1 channel ax1: restoring foreign file 9 to /u01/app/oracle_base/oradata/CDB_dest/PDB_dest/sysaux01.dbf channel ax1: restore complete, elapsed time: 00:00:07 channel ax1: starting datafile backup set restore channel ax1: using network backup set from service CDB18 channel ax1: specifying datafile(s) to restore from backup set channel ax1: restoring section 1 of 1 channel ax1: restoring foreign file 10 to /u01/app/oracle_base/oradata/CDB_dest/PDB_dest/undotbs01.dbf channel ax1: restore complete, elapsed time: 00:00:07 channel ax1: starting datafile backup set restore channel ax1: using network backup set from service CDB18 channel ax1: specifying datafile(s) to restore from backup set channel ax1: restoring section 1 of 1 channel ax1: restoring foreign file 11 to /u01/app/oracle_base/oradata/CDB_dest/PDB_dest/users01.dbf channel ax1: restore complete, elapsed time: 00:00:01 Finished restore at 05-MAR-18 current log archived contents of Memory Script: { set archivelog destination to '/u01/app/oracle_base/oradata/CDB18/arch'; restore clone force from service 'CDB18' foreign archivelog from scn 781720; } executing Memory Script executing command: SET ARCHIVELOG DESTINATION Starting restore at 05-MAR-18 channel ax1: starting archived log restore to user-specified destination archived log destination=/u01/app/oracle_base/oradata/CDB18/arch channel ax1: using network backup set from service CDB18 channel ax1: restoring archived log archived log thread=1 sequence=18 channel ax1: restore complete, elapsed time: 00:00:01 channel ax1: starting archived log restore to user-specified destination archived log destination=/u01/app/oracle_base/oradata/CDB18/arch channel ax1: using network backup set from service CDB18 channel ax1: restoring archived log archived log thread=1 sequence=19 channel ax1: restore complete, elapsed time: 00:00:01 Finished restore at 05-MAR-18 Performing import of metadata... Finished Duplicate PDB at 05-MAR-18 released channel: ax1 released channel: dx1 |
Note: I used a different name for the PDB in the destination (duplicate) database by using “PDB18 as PDB_dest” syntax. You can keep the same PDB name by skipping “as New_PDB_Name” from duplicate command.
Now check the status of the duplicated PDB on detination CDB.
1 2 3 4 5 |
CDB$ROOT@CDB_DEST> show pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB_DEST READ WRITE NO |
Thanks,
Mandy
Leave a Reply