← All field notes

12c: duplicate pluggable database without READ ONLY mode

At the beginning we have to prepare parameter file for the new instance

ora600@lab ~ / text#01
*._catalog_foreign_restore=FALSE
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata'
*.db_domain=''
*.db_name='skiper'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4560m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=skiperXDB)'
*.enable_pluggable_database=true
*.open_cursors=300
*.pga_aggregate_target=512m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1g
*.undo_tablespace=‚UNDOTBS1'
19 LINESTEXT / UTF-8

Start the instance in nomount

ora600@lab ~ / text#02
[oracle@rico dbs]$ export ORACLE_SID=skiper
[oracle@rico dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Mon May 25 14:32:46 2015

Copyright (c) 1982, 2014, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> create spfile from pfile;

File created.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1073741824 bytes
Fixed Size		    2932632 bytes
Variable Size		  390070376 bytes
Database Buffers	  675282944 bytes
Redo Buffers		    5455872 bytes
22 LINESTEXT / UTF-8

Since I want to duplicate the database in active mode I will register it in LISTENER. To achieve this I have to add the following lines to the listener.ora

ora600@lab ~ / text#03
SID_LIST_LISTENER=
  (SID_LIST=
      (SID_DESC=
         (GLOBAL_DBNAME=skiper)
         (SID_NAME=skiper)
         (ORACLE_HOME=/u01/app/oracle/product/12.1.0/dbhome_1)
       )
   )
9 LINESTEXT / UTF-8

Now we can perform active database duplication with only one pluggable database

ora600@lab ~ / text#04
oracle@rico dbs]$ rman target sys/Oracle123@localhost:1521/rico auxiliary sys/Oracle123@localhost:1521/skiper

Recovery Manager: Release 12.1.0.2.0 - Production on Mon May 25 14:44:41 2015

Copyright (c) 1982, 2014, Oracle and/or its affiliates.  All rights reserved.

connected to target database: RICO (DBID=645399623)
connected to auxiliary database: SKIPER (not mounted)

RMAN> duplicate target database to skiper pluggable database ricopdb from active database using compressed backupset;

(output removed for clarity)

14 LINESTEXT / UTF-8

Now we have to close the pluggable database and unplug it

ora600@lab ~ / text#05
SQL> alter pluggable database ricopdb close;

Pluggable database altered.

SQL> alter pluggable database ricopdb unplug into '/home/oracle/ricopdb.xml';

Pluggable database altered.

9 LINESTEXT / UTF-8

Now we can plug the database in our original container

ora600@lab ~ / text#06
SQL> create pluggable database ricotestpdb as clone using '/home/oracle/ricopdb.xml' 
  2  ;

Pluggable database created.

SQL> select con_id, name from v$pdbs;

    CON_ID NAME
---------- ------------------------------
	 2 PDB$SEED
	 3 RICOPDB
	 4 RICOTESTPDB
13 LINESTEXT / UTF-8

If you don’t want to copy datafiles to thair new location, you can use the following statement:

ora600@lab ~ / text#07
SQL> create pluggable database ricotest2pdb as clone using '/home/oracle/ricopdb.xml'  nocopy;

Pluggable database created.

5 LINESTEXT / UTF-8
END OF FIELD NOTE / 2015-05-25

Keep asking why. Keep looking deeper.

← Back to the blog