Sunday, January 29, 2017

Multitenant : Create and Configure a Container Database (CDB) in Oracle Database 12c Release 1

The multitenant option introduced in Oracle Database 12c allows a single container database (CDB) to host multiple separate pluggable databases (PDB). This article covers the options available to create a new container database.

There are articles specifically about installation of Oracle Database 12c here.

Oracle Universal Installer (OUI)


The Oracle Universal Installer (OUI) allows you to create a container database (CDB) during the software installation. The "Typical Install Configuration" screen has a checkbox to indicate the database is a container database. You can optionally create a single pluggable database (PDB) in this screen also.

Oracle Database Tutorial and Materials, Oracle Database Guides, Oracle Database Certifications

The advanced configuration options provides the same ability on the "Database Identifiers" screen.

Oracle Database Tutorial and Materials, Oracle Database Guides, Oracle Database Certifications

In both cases the creation of a pluggable database (PDB) is optional, so you can create an empty container database and create the pluggable database later if you wish.

Database Configuration Assistant (DBCA)


The Database Configuration Assistant (DBCA) gives similar options to the Oracle Universal Installer (OUI). The "Creation Mode" page allows you to enter the default installation configuration details directly.

Oracle Database Tutorial and Materials, Oracle Database Guides, Oracle Database Certifications

If you chose the "Advanced Mode" option, you can create a CDB and multiple PBDs in one go.

Oracle Database Tutorial and Materials, Oracle Database Guides, Oracle Database Certifications

Manual Creation


Using the DBCA, either during or after the software installation, is the recommended approach to creating CDBs, but it is possible to create them manually.

The simplest way to see how manual creation of a CDB is accomplished is to run the DBCA. Pick "Advanced Mode", select the "Custom Database" option (no template used) and at the end, uncheck the "Create Database" option and check the "Generate Database Creation Scripts" option. The resulting scripts will include one called "CreateDB.sql", with contents similar to this.

SET VERIFY OFF
connect "SYS"/"&&sysPassword" as SYSDBA
set echo on
spool /u01/app/oracle/admin/cdb1/scripts/CreateDB.log append
startup nomount pfile="/u01/app/oracle/admin/cdb1/scripts/init.ora";
CREATE DATABASE "cdb1"
MAXINSTANCES 8
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
DATAFILE '/u01/app/oracle/oradata/cdb1/system01.dbf' SIZE 700M REUSE
  AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
  EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/cdb1/sysaux01.dbf' SIZE 550M REUSE
  AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/u01/app/oracle/oradata/cdb1/temp01.dbf' SIZE 20M REUSE
  AUTOEXTEND ON NEXT  640K MAXSIZE UNLIMITED
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE  '/u01/app/oracle/oradata/cdb1/undotbs01.dbf' SIZE 200M REUSE
  AUTOEXTEND ON NEXT  5120K MAXSIZE UNLIMITED
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/u01/app/oracle/oradata/cdb1/redo01.log') SIZE 50M,
GROUP 2 ('/u01/app/oracle/oradata/cdb1/redo02.log') SIZE 50M,
GROUP 3 ('/u01/app/oracle/oradata/cdb1/redo03.log') SIZE 50M
USER SYS IDENTIFIED BY "&&sysPassword" USER SYSTEM IDENTIFIED BY "&&systemPassword"
enable pluggable database
seed file_name_convert=('/u01/app/oracle/oradata/cdb1/system01.dbf','/u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf',
                        '/u01/app/oracle/oradata/cdb1/sysaux01.dbf','/u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf',
                        '/u01/app/oracle/oradata/cdb1/temp01.dbf','/u01/app/oracle/oradata/cdb1/pdbseed/temp01.dbf',
                        '/u01/app/oracle/oradata/cdb1/undotbs01.dbf','/u01/app/oracle/oradata/cdb1/pdbseed/undotbs01.dbf');
spool off

Most of the CREATE DATABASE statement should look familiar. Notice the ENABLE PLUGGABLE DATABASE and SEED FILE_NAME_CONVERT options in bold.

When the ENABLE PLUGGABLE DATABASE clause is present, the database is created as a CDB with both root and seed.

The SEED FILE_NAME_CONVERT clause is used to determine the seed file names, based on the root file names. If you are using Oracle Managed Files (OMF), this clause is not necessary. If you prefer, you can specify the seed datafiles explicitly, rather than using the convert.

SEED
SYSTEM DATAFILE '/u01/app/oracle/oradata/cdb1/pdbseed/system01.dbf' SIZE 700M REUSE
  AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED
  EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/u01/app/oracle/oradata/cdb1/pdbseed/sysaux01.dbf' SIZE 550M REUSE
  AUTOEXTEND ON NEXT  10240K MAXSIZE UNLIMITED

Remember, your first choice for creating a CDB should always be the DBCA. It's important to know how the DBCA creates the CDB, but that doesn't mean a manual approach is better.

Configure a Container Database (CDB)


With the exception of selecting the "Create as Container database" option, the rest of the configuration during the installation or when using the DBCA is very similar to working with a single instance. After database creation, running the DBCA allows you to reconfigure some of the CDB options.

Related Posts

0 comments:

Post a Comment