Step by step Clone PDB within CDB in Oracle Database 12c
Oracle database 12c is providing new feature to clone database in very simple steps.It is very easy and simple to clone database in Oracle version 12c.
Here, I am listing step by step to clone PDB (Plug-able Database ) database within it's CDB (Container Database).
Example shows, clone database from pdborcl to new database pbduporcl.
Below are the Steps,
SrNo
|
Description
|
Step 1
|
Setting the Source PDB to READ ONLY Mode
|
Step 2
|
Create directory for new clone PDB.
|
Step 3
|
Configure OMF to the directory of the Clone PDB
|
Step 4
|
Clone the PDB within CDB
|
Step 5
|
Set source PDB back to open mode.
|
Step 6
|
Check status of all PDBs
|
Step 1:- Setting the
Source PDB to READ ONLY Mode
Connect with SYS user and make pdborcl database to read only mode.
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:28:40 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter pluggable database pdborcl close immediate;
Pluggable database altered.
SQL> alter pluggable database pdborcl open read only;
Pluggable database altered.
SQL>
SQL> exit
Step 2:- Create
directory for new clone PDB
Now Create directory structure for new pdbduporcl database.
/mnt/devops_0/Oracle/db1212/db1212dat/orcl12c
-bash-4.1$ mkdir pdbduporcl
-bash-4.1$ ls -ltr
total 2080842
drwxr-x---+ 2 db1212 oinstall 5 May 8 14:19 pdbseed
-rw-r-----+ 1 db1212 oinstall 52429312 May 9 01:31 redo02.log
-rw-r-----+ 1 db1212 oinstall 52429312 May 9 11:30 redo03.log
-rw-r-----+ 1 db1212 oinstall 206577664 May 9 11:31 temp01.dbf
-rw-r-----+ 1 db1212 oinstall 5251072 May 9 11:35 users01.dbf
-rw-r-----+ 1 db1212 oinstall 361766912 May 9 11:45 undotbs01.dbf
-rw-r-----+ 1 db1212 oinstall 838868992 May 9 11:45 system01.dbf
-rw-r-----+ 1 db1212 oinstall 744497152 May 9 11:45 sysaux01.dbf
-rw-r-----+ 1 db1212 oinstall 52429312 May 9 11:45 redo01.log
drwxr-x---+ 2 db1212 oinstall 7 May 9 11:45 pdborcl
-rw-r-----+ 1 db1212 oinstall 17973248 May 9 11:45 control01.ctl
drwxr-xr-x+ 2 db1212 oinstall 2 May 9 11:45 pdbduporcl
Step 3:- Configure OMF
to the directory of the Clone PDB (Optional)
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:48:01 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> alter system set db_create_file_dest='/mnt/devops_0/Oracle/db1212/db1212dat/orcl12c/pdbduporcl';
System altered.
SQL>
Step 4:- Clone the PDB
within CDB
-bash-4.1$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 11:49:53 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
SQL> create pluggable database pdbduporcl from pdborcl;
Pluggable database created.
Open new PDB database
SQL> alter pluggable database pdbduporcl open;
Pluggable database altered.
Add TNS Entery in tnsnames.ora file.
pdbduporcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = orac12c)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = pdbduporcl)
)
)
Connect to new PDB database
-bash-4.1$ sqlplus /nolog
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:35:18 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
SQL> conn sys/sysdba123@pdbduporcl as sysdba
Connected.
SQL>
SQL> show con_name
CON_NAME
------------------------------
PDBDUPORCL
SQL>
Step 5:- Set source PDB
back to open mode.
-bash-4.1$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:37:41 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL>
SQL> alter pluggable database pdborcl close immediate;
Pluggable database altered.
SQL>
SQL> alter pluggable database pdborcl open;
Pluggable database altered.
Step 6:- Check status of
all PDBs
Now check the status of all PDBs as below.
-bash-4.1$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Wed May 9 12:37:41 2016
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
SQL> select con_id, dbid, name, open_mode from v$pdbs;
CON_ID DBID NAME OPEN_MODE
-------------- -------------- --------------------------- ------------------
2 3707469898 PDB$SEED READ ONLY
3 1332221668 PDBORCL READ WRITE
4 1313681298 PDBDUPORCL READ WRITE
SQL>
Thanks & Regards,
Chandan Tanwani
Oracle Performance Tuning Certified Expert