Steps To Create Container Database (CDB) Manually in Oracle 12c

Oracle 12c database is MULTITENANTE CONTAINER DATABASE space for creating pluggable databases.
(Eg Pluggable databases are applications like any OLTP databases etc..)

Oracle 12c database is Multi-tenant  container database in which a seed database called pdb$seed comes with it, Using which we can create pluggable database. in one container 253 pdbs can be created including pdbseed.

Follow below steps to create Multitenante Container Database manually.

Step 1 : Specify an instance identifier (SID) & Environment variables.

The maximum number of characters for ORACLE_SID is 12, only letters and digits are permitted.

[oracle@server1 ~]$ vi cdb1.sh  or bash_profile

export ORACLE_SID=cdb1
export ORACLE_HOME=/soft/app/oracle/product/12.1.1
export ORACLE_BASE=/soft/app/oracle
export PATH=$ORACLE_HOME/bin:$ORACLE_HOME/perl/bin:$PATH:.
export LD_LIBRARY_PATH=$ORACLRE_HOME/lib:/lib:/usr/lib
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib

Step 2 : Ensure that the required environment variables are set.

echo $ORACLE_SID
echo $ORACLE_HOME
echo $PATH

Step 3 : Create the initialization parameter file under ORACLE_HOME dbs location

[oracle@server1 ~]$ cd $ORACLE_HOME/dbs

[oracle@server1 dbs]$ cp  init.ora  initcdb1.ora   ( cdb1 is SID )

After copied open new initcdb1 parameter file and edit as specified below

[oracle@server1 dbs]$ vi initcdb1.ora
db_name='CDB1'
enable_pluggable_database=true
memory_target=1G
processes = 150
audit_file_dest='$ORACLE_BASE/admin/orcl/adump'
audit_trail ='db'
db_block_size=8192
db_domain=''
#db_recovery_file_dest='<ORACLE_BASE>/fast_recovery_area'
#db_recovery_file_dest_size=2G
diagnostic_dest='/u01/oradata/cdb1'
dispatchers='(PROTOCOL=TCP) (SERVICE=ORCLXDB)'
open_cursors=300
remote_login_passwordfile='EXCLUSIVE'
undo_tablespace='UNDOTBS1'
# You may want to ensure that control files are created on separate physical
# devices
control_files = /u01/oradata/cdb1/control1.ctl
compatible ='12.0.0'


Step 4 : Create directory structure to store database physical file.

[oracle@server1 ~]$ mkdir  -p  /u01/oradata/cdb1
[oracle@server1 ~]$ mkdir  -p  /u01/oradata/cdb1/pdbseed


Step 5 : Create database creation script.

[oracle@server1 ~]$ vi createcdb1.sql
create database cdb1
datafile '/u01/oradata/cdb1/system.dbf' size 1024M extent management local
sysaux datafile '/u01/oradata/cdb1/sysaux.dbf' size 1024M
undo tablespace undotbs1 datafile '/u01/oradata/cdb1/untotbs.dbf' size 500M
default temporary tablespace temp tempfile '/u01/oradata/cdb1/temp.dbf' size 500M
default tablespace users datafile '/u01/oradata/cdb1/users.dbf' size 500M
logfile
group 1('/u01/oradata/cdb1/redo1a.log') size 10M,
group 2('/u01/oradata/cdb1/redo21.log') size 10M
ENABLE PLUGGABLE DATABASE
SEED FILE_NAME_CONVERT=('/u01/oradata/cdb1','/u01/oradata/cdb1/pdbseed');

Step 5 : Startup the database using below steps

[oracle@server1 ~]$ sqlplus '/as sysdba'

SQL*Plus: Release 12.1.0.1.0 Production on Wed Jan 24 20:02:22 2018

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options

SQL> startup nomount

SQL> @createcdb1.sql

Database Created

Step 6 : Verifying CDB was created

SQL> select NAME,OPEN_MODE,CDB from v$database;

NAME      OPEN_MODE            CDB
--------- -------------------- ---
CDB1      READ WRITE           YES

SQL> select DBID, CON_ID, NAME, OPEN_MODE from v$database;

      DBID     CON_ID NAME      OPEN_MODE
---------- ---------- --------- --------------------
 939984158          0 CDB1      READ WRITE



Step 7 :  Build data dictionary views

Run the script necessary to build data dictionary views, synonyms and PL/SQL packages, and to support proper functioning of SQL*Plus

[oracle@server1 ~]$ vi postcdb.sql

@$ORACLE_HOME/rdbms/admin/catalog.sql
@$ORACLE_HOME/rdbms/admin/catproc.sql
conn system/manager
@$ORACLE_HOME/sqlplus/admin/pupbld.sql


SQL> @postcdb.sql

--
--
--
--



Notice that the con id is 0 for the  whole container cdb1

At this point you should have two containers in your CDB database. The Root container and Seed Pluggable database. Check with below query.

SQL> select CON_ID, NAME from v$containers;

    CON_ID NAME
---------- ------------------------------
         1 CDB$ROOT
         2 PDB$SEED



Step 7 :  Build data dictionary views on PDB$SEED

Run the script necessary to build data dictionary views, synonyms, PL/SQL packages and to support proper functioning of SQL*Plus in pdb$seed.

SQL> alter session set "_oracle_script"=true;

Session altered.

SQL> SELECT con_id,dbid,NAME,OPEN_MODE from v$pdbs;

    CON_ID       DBID NAME                           OPEN_MODE
---------- ---------- ------------------------------ ----------
         2 4208911838 PDB$SEED                       READ ONLY

SQL> alter pluggable database pdb$seed close;

Pluggable database altered.

SQL> alter pluggable database pdb$seed open;

Pluggable database altered.

SQL>


[oracle@server1 ~]$ vi postpdb.sql
@$ORACLE_HOME/rdbms/admin/catalog.sql
@$ORACLE_HOME/rdbms/admin/catblock.sql
@$ORACLE_HOME/rdbms/admin/catproc.sql
@$ORACLE_HOME/rdbms/admin/catoctk.sql
@$ORACLE_HOME/rdbms/admin/owminst.plb
conn system/manager
@$ORACLE_HOME/sqlplus/admin/pupbld.sql


SQL>@postpdb.sql


SQL> alter session set "_oracle_script"=false;

Session altered.

SQL> select OPEN_MODE from v$database;

OPEN_MODE
--------------------
READ WRITE


SQL> select con_id, dbid, NAME, OPEN_MODE from v$pdbs;

    CON_ID       DBID NAME                           OPEN_MODE
---------- ---------- ------------------------------ ----------
         2 4208911838 PDB$SEED                       READ WRITE




Newer Post Older Post

2 Responses to “Steps To Create Container Database (CDB) Manually in Oracle 12c”