Thursday, September 5, 2013

Converting Non-Container Database to Pluggable Database in 12c.

[oracle@box1 product]$ ps -aef |grep pmon
oracle    2019     1  0 Sep04 ?        00:00:35 ora_pmon_db11g
oracle    5831     1  0 01:03 ?        00:00:35 ora_pmon_cdb2
oracle   22297  1978  0 19:21 pts/0    00:00:00 grep pmon

[oracle@box1 product]$ export ORACLE_SID=cdb2

SQL> select cdb from v$database;

CDB
---
YES

[oracle@box1 product]$ export ORACLE_SID=db11g

SQL> select cdb from v$database;

CDB
---
NO

SQL> show con_name

CON_NAME
------------------------------
Non Consolidated


SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup open read only
ORACLE instance started.

Total System Global Area  242208768 bytes
Fixed Size                  2286944 bytes
Variable Size             184552096 bytes
Database Buffers           50331648 bytes
Redo Buffers                5038080 bytes
Database mounted.
Database opened.

SQL> begin
  2  DBMS_PDB.DESCRIBE(
  3  pdb_descr_file=>'/u01/app/oracle/oradata/cdb2/pdb_db11g/db11g.xml');
  4  end;
  5  /

PL/SQL procedure successfully completed.

SQL> shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

[oracle@box1 product]$ export ORACLE_SID=cdb2
[oracle@box1 product]$ sqlplus "/as sysdba"

SQL> create pluggable database pdb5
  2  using '/u01/app/oracle/oradata/cdb2/pdb_db11g/db11g.xml'
  3  copy
  4  file_name_convert=('/u01/app/oracle/oradata/db11g/','/u01/app/oracle/oradata/cdb2/pdb_db11g/');

Pluggable database created.

SQL> select NAME,OPEN_MODE from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB5                           MOUNTED

SQL> alter session set container=pdb5;

Session altered.

SQL> show con_name

CON_NAME
------------------------------
PDB5
SQL> @$ORACLE_HOME/rdbms/admin/noncdb_to_pdb.sql

SQL> alter session set container=pdb5;

Session altered.

SQL> alter pluggable database open;


Pluggable database altered.

SQL> show con_name

CON_NAME
------------------------------
PDB5

SQL> select NAME,OPEN_MODE from v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB5                           READ WRITE

1 row selected.


Reference.
http://www.oracle-base.com/articles/12c/multitenant-migrate-non-cdb-to-pdb-12cr1.php

No comments:

Post a Comment