How to Create and configure a multitenant container database (CDB)

The configuration of creating a multi-tenant container database (CDB) is similar to the procedure for creating a non-CDB, however you need to have a knowledge of the architecture and concepts before leaving to create the CDB.


When should I use the CDB Creation method.


1) When using Oracle Universal Installer (OUI) to install software only, and did not create a CDB;

2) You want to create another CDB on the same host.


There are two specific methods that can be done to create a CBD:


  • Using the traditional Database Configuration Assistant (DBCA) which is a graphical interface tool, very easy and intuitive. See the topic below 'Creating Container Database (CDB) using DBCA'


  • If you can't use the graphical interface, you can create it manually with CREATE DATABASE through line of code, SQL statements.

Here I will show the two forms starting with the CREATE DATABASE manual method.


Creating a CDB manually using CREATE DATABASE.


Note the following prerequisites:


These instructions will be applied to a single instance database;

Using ASM to manage storage, group disks must be initialized before performing CDB creation.

Run the show parameter ENABLE_PLUGGABLE_DATABASE command and make sure it is TRUE enabled. if not, set the init.ora parameter enable_pluggable_database = true.


Run the catcdb.sql SQL script:


Enter the following in SQL*Plus (sqlplus / as sysdba) to run the script

SQL>@?/rdbms/admin/catcdb.sql;

Now we are going to use the script for the log file directory, insert /tmp and also create_cdb.log when prompted for the values as below:

SQL> host perl -I &&rdbms_admin &&rdbms_admin_catcdb --logDirectory &&1 --logFilename &&2
Enter value for 1: /tmp
Enter value for 2: create_cdb.log

The script will ask for administrator passwords and the name of the temporary tablespace:

Enter new password for SYS: ********
Enter new password for SYSTEM: ********
Enter temporary tablespace name: TEMP

The controlfile initialization parameters assume the following specific locations:


-> Directory '+DG_DATA/NEW_CDB/DATAFILE/' to Datafiles;

-> Directory '+DG_DATA/NEW_CDB/DATAFILE/pdbseed/ ' to PDBSEED;

-> Directory '+DG_DATA/MY_DIRECTORY_01/' to Redo;

-> Directory '+DG_DATA/MY_DIRECTORY_02/' to Redo;

CREATE DATABASE NEW_CDB                                                     
  USER SYS IDENTIFIED BY sys_password                                      
  USER SYSTEM IDENTIFIED BY system_password                                
  LOGFILE GROUP 1 ('+DG_DATA/MY_DIRECTORY_01/redo01a.log','+DG_DATA/MY_DIRECTORY_02/redo01b.log')  
             SIZE 100M BLOCKSIZE 512,                                      
          GROUP 2 ('+DG_DATA/MY_DIRECTORY_01/redo02a.log','+DG_DATA/MY_DIRECTORY_02/redo02b.log')  
             SIZE 100M BLOCKSIZE 512,                                      
          GROUP 3 ('+DG_DATA/MY_DIRECTORY_01/redo03a.log','+DG_DATA/MY_DIRECTORY_02/redo03b.log')  
             SIZE 100M BLOCKSIZE 512                                       
  MAXLOGHISTORY 1                                                          
  MAXLOGFILES 16                                                           
  MAXLOGMEMBERS 3                                                          
  MAXDATAFILES 1024                                                        
  CHARACTER SET AL32UTF8                                                   
  NATIONAL CHARACTER SET AL16UTF16                                         
  EXTENT MANAGEMENT LOCAL                                                  
  DATAFILE '+DG_DATA/NEW_CDB/DATAFILE/system01.dbf'                    
    SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED            
  SYSAUX DATAFILE '+DG_DATA/NEW_CDB/DATAFILE/sysaux01.dbf'            
    SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED            
  DEFAULT TABLESPACE deftbs                                                
     DATAFILE '+DG_DATA/NEW_CDB/DATAFILE/deftbs01.dbf'                
     SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED                       
  DEFAULT TEMPORARY TABLESPACE tempts1                                     
     TEMPFILE '+DG_DATA/NEW_CDB/DATAFILE/temp01.dbf'                  
     SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED              
  UNDO TABLESPACE undotbs1                                                 
     DATAFILE '+DG_DATA/NEW_CDB/DATAFILE/undotbs01.dbf'               
     SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED            
  ENABLE PLUGGABLE DATABASE                                                
    SEED                                                                   
    FILE_NAME_CONVERT = ('+DG_DATA/NEW_CDB/DATAFILE/ ',                
                         '+DG_DATA/NEW_CDB/DATAFILE/pdbseed/')               
    SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED    
    SYSAUX DATAFILES SIZE 100M                                             
  USER_DATA TABLESPACE usertbs                                             
    DATAFILE '+DG_DATA/NEW_CDB/DATAFILE/pdbseed/usertbs01.dbf'               
    SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED                        
  LOCAL UNDO ON;

Manual CDB creation procedure was successfully performed.



Creating Container Database (CDB) using DBCA


Using DBCA has more technical advantages and alternatives besides being an Oracle recommendation.

  • Graphic module for automated creation;

  • You can define the number of PDBs in a CDB when it is created;

  • When you finish creating the CDB using the DBCA wizard, you are ready to use.

  • Once the CDB is created you can still use the DBCA to clone local PDBs, connect and disconnect PDBs, duplicate a CDB using the silent module.

Note:

I called the CDB "ORADES" and the PDB 'ORADES_PDB01'


Use the DBCA command:

dbca

Step 1:

We started with operations with DBCA, selecting the option "Create a database". "Next" button.







Step 2:

Let's go to each item as follows:

1) Leave the Typical Configuration checked;

2) Enter the Global Name of your DATABASE;

3) Select the Storage Type ("Automatic Storage Management ASM). ASM will bring up File Location: automatically;

4) Keep the Character Set:

5) Enter the Password;

Attention this step to Create a Multitenant Database:

1) Check Create As Container Database

2) Enter the name of your PDB

"Next" button.

Step 3:

A summary of the configurations that will be performed by DBCA will be shown.

"Finish" button.








Step 4:

Wait to finish it may happen that progress will take a while.









Step 5:

Your Pluggable Database (PDB) in a Multitenant Environment has already been successfully created. "Close" button.








Access sqlplus to check if your database is Startup with the commands:

sqlplus / as sysdba
show pdbs;

We have successfully completed the entire procedure!