As you know, Oracle Database 12c Release 1 (12.1.0.2.0) already released at July 22, 2014. You can download new release from
here.
With this new release coming some new features. This article series covers PDB Clone new features of Oracle Multitenant option of Oracle Database 12c Release 1 (12.1.0.2.0).
This article is in four parts:
- Excluding Data When Cloning a PDB
- Non-CDB Adopt to CDB as a PDB.
- PDB Subset Cloning
- PDB Snapshot Cloning (as soon)
Part II. Non-CDB Adopt to CDB as a PDB.The new release of Oracle Multitenant fully supports remote full and snapshot clones over a database link. A non-multitenant container database (CDB) can be adopted as a pluggable database (PDB) simply by cloning it over a database link.
This feature further improves rapid provisioning of pluggable databases. Administrators can spend less time on provisioning and focus more on other innovative operations. Follow examples:
I'll create a PDB using database link from following non-CDB:
[oracle@oel62-ora12c2 ~]$ export ORACLE_SID=prmdb
[oracle@oel62-ora12c2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jul 24 12:14:06 2014
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 banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE 12.1.0.2.0 Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production
SQL> select cdb, name from v$database;
CDB NAME
--- ---------
NO PRMDB
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prmdb/system01.dbf
/u01/app/oracle/oradata/prmdb/sysaux01.dbf
/u01/app/oracle/oradata/prmdb/undotbs01.dbf
/u01/app/oracle/oradata/prmdb/users01.dbf
My Multitenant Container Database as below:
[oracle@oel62-ora12c2 ~]$ export ORACLE_SID=prmcdb
[oracle@oel62-ora12c2 ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production on Thu Jul 24 12:22:42 2014
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 banner from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
PL/SQL Release 12.1.0.2.0 - Production
CORE 12.1.0.2.0 Production
TNS for Linux: Version 12.1.0.2.0 - Production
NLSRTL Version 12.1.0.2.0 - Production
SQL> select cdb,name from v$database;
CDB NAME
--- ---------
YES PRMCDB
SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PRMPDB01 READ WRITE
PRMPDB02 READ WRITE
PRMPDB03 READ WRITE
SQL> select file_name from cdb_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prmcdb/system01.dbf
/u01/app/oracle/oradata/prmcdb/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/undotbs01.dbf
/u01/app/oracle/oradata/prmcdb/users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/system01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb02/prmpdb02_users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/system01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/prmpdb01_users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb01/appdata01.dbf
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/prmcdb/prmpdb03/appdata01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/prmpdb03_users01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/sysaux01.dbf
/u01/app/oracle/oradata/prmcdb/prmpdb03/system01.dbf
15 rows selected.
We need create a database link to non-CDB in CDB. User of database link must be granted CREATE PLUGGABLE DATABASE privilege
and before create PDB, non-CDB must be opened read-only mode.
On non-CDB:
SQL> conn / as sysdba
Connected.
SQL> create user pdbcreator identified by pdbcreator;
User created.
SQL> grant create session, resource, create pluggable database to pdbcreator;
Grant succeeded.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.
Total System Global Area 830472192 bytes
Fixed Size 2929840 bytes
Variable Size 599788368 bytes
Database Buffers 222298112 bytes
Redo Buffers 5455872 bytes
Database mounted.
SQL> alter database open read only;
Database altered.
Create a database link in CDB to non-CDB and create a pluggable database via this database link:
On CDB:
SQL> create database link prmdb connect to pdbcreator identified by pdbcreator
2 using 'prmdb';
Database link created.
SQL> create pluggable database prmpdb04 from NON$CDB@prmdb
2 file_name_convert=('/u01/app/oracle/oradata/prmdb','/u01/app/oracle/oradata/prmcdb/prmpdb04');
Pluggable database created.
[oracle@oel62-ora12c2 prmcdb]$ pwd
/u01/app/oracle/oradata/prmcdb
[oracle@oel62-ora12c2 prmcdb]$ ls -l
total 1903672
-rw-r----- 1 oracle oinstall 17973248 Jul 24 12:27 control01.ctl
drwxr-x--- 2 oracle oinstall 4096 Jul 23 18:03 pdbseed
drwxr-x--- 2 oracle oinstall 4096 Jul 24 09:47 prmpdb01
drwxr-x--- 2 oracle oinstall 4096 Jul 23 18:22 prmpdb02
drwxr-x--- 2 oracle oinstall 4096 Jul 24 10:50 prmpdb03
drwxr-x--- 2 oracle oinstall 4096 Jul 24 12:27 prmpdb04
-rw-r----- 1 oracle oinstall 52429312 Jul 24 12:27 redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jul 24 10:52 redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jul 24 12:10 redo03.log
-rw-r----- 1 oracle oinstall 713039872 Jul 24 12:25 sysaux01.dbf
-rw-r----- 1 oracle oinstall 828383232 Jul 24 12:25 system01.dbf
-rw-r----- 1 oracle oinstall 206577664 Jul 24 12:26 temp01.dbf
-rw-r----- 1 oracle oinstall 225452032 Jul 24 12:25 undotbs01.dbf
-rw-r----- 1 oracle oinstall 5251072 Jul 24 12:15 users01.dbf
[oracle@oel62-ora12c2 prmcdb]$ cd prmpdb04
[oracle@oel62-ora12c2 prmpdb04]$ ls -l
total 1479768
-rw-r----- 1 oracle oinstall 681582592 Jul 24 12:28 sysaux01.dbf
-rw-r----- 1 oracle oinstall 828383232 Jul 24 12:28 system01.dbf
-rw-r----- 1 oracle oinstall 62922752 Jul 24 12:28 temp01.dbf
-rw-r----- 1 oracle oinstall 5251072 Jul 24 12:28 users01.dbf
SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PRMPDB01 READ WRITE
PRMPDB02 READ WRITE
PRMPDB03 READ WRITE
PRMPDB04 MOUNTED
Pluggable Database created successfully
We created the PDB from a non-CDB, therefore we must be run the @ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql script in new PDB. This script must be run before the PDB can be opened for the first time.
SQL> alter session set container = prmpdb04;
Session altered.
The script opens the PDB, performs changes, and closes the PDB when the changes are complete.
SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql
.....
PL/SQL procedure successfully completed.
SQL>
SQL>
SQL> WHENEVER SQLERROR CONTINUE;
SQL>
SQL>
SQL> alter database open;
Database altered.
SQL> conn mahir/mahir@prmpdb04;
Connected.
SQL> select * from dt;
D
---------
23-JUL-14
22-JUL-14
21-JUL-14
3 rows selected.
Script executed successfully and PDB opened.
SQL> conn / as sysdba
Connected.
SQL>
SQL> select name, open_mode from v$pdbs;
NAME OPEN_MODE
------------------------------ ----------
PDB$SEED READ ONLY
PRMPDB01 READ WRITE
PRMPDB02 READ WRITE
PRMPDB03 READ WRITE
PRMPDB04 READ WRITE
5 rows selected.
Cloning a Remote PDB or Non-CDB the source and target platforms must meet these requirements:
- They must have the same endianness.
- They must have the same set of database options installed.
I had created the PDB from non-CDB on same platform, so same endianes platforms.
Regards
Mahir M. Quluzade