Oracle 12c Multitenant Database Creation
Oracle 12c Multitenant Database Creation
The procedure for creating a multitenant container database (CDB) is very similar to the
procedure for creating a non-CDB
You can also create application containers in a CDB. An application container is a collection of
application PDBs that store
the data for one or more applications. In addition, application containers support user-created
application common objects
that can be shared by the application PDBs in the application container.
2. There are separate data files for the root, the CDB seed, each PDB, each application root, and each
application PDB.
There is one redo log for a single-instance CDB, or one redo log for each instance of an Oracle Real
Application Clusters
(Oracle RAC) CDB. Also, for Oracle RAC, all data files and redo log files must be on shared storage.
3. The global database name of the root is the global database name of the CDB. The global
database name of a PDB is
defined by the PDB name and the DB_DOMAIN initialization parameter.
4. A CDB uses a single SPFILE or a single text initialization parameter file (PFILE). Values of
initialization parameters set for
the root can be inherited by PDBs. You can set some initialization parameters for a PDB by using the
ALTER SYSTEM
statement.
The root must be the current container when you operate on an SPFILE. The user who creates or
modifies the SPFILE must
be a common user with SYSDBA, SYSOPER, or SYSBACKUP administrative privilege, and the user must
exercise the
privilege by connecting AS SYSDBA, AS SYSOPER, or AS SYSBACKUP respectively.
5. There is a single redo log and a single control file for an entire CDB.
NAME CON_ID
----------------------------------------------------------------- ------- ------------------------
/u01/app/oracle/oradata/m1cdb/control01.ctl 0
/u01/app/oracle/fast_recovery_area/m1cdb/control02.ctl 0
6. There is a separate SYSAUX tablespace for the root and for each PDB.
7. You can specify a separate default tablespace for the root and for each PDB. Also, there is a
separate SYSTEM tablespace for the root and for each PDB.
8. There is a default temporary tablespace for each container in the CDB, including the root and each
PDB, application root,
and application PDB.
The shared temporary tablespace is used is for recursive SQL only and is not used by hosted PDB
tenants directly.
FILE_NAME TABLESPACE_NAME
----------------------------------------------------------------- -------------------------------------------------
/u01/app/oracle/oradata/m1cdb/temp01.dbf TEMP
/u01/app/oracle/oradata/m1cdb/pdbseed/pdbseed_temp01.dbf TEMP
/u01/app/oracle/oradata/m1cdb/m1pdb1/m1pdb1_temp01.dbf TEMP
PROPERTY_NAME PROPERTY_VALUE
------------------------------ ---------------------------------------------------
DEFAULT_TEMP_TABLESPACE TEMP
DEFAULT_PERMANENT_TABLESPACE USERS
9. A CDB can run in different undo modes. You can configure a CDB to have one active undo
tablespace for the entire CDB
or a separate undo tablespace for each container in the CDB. You can specify the undo mode during
CDB creation, and
you can change the undo mode after the CDB is created.
When you choose to have one active undo tablespace for the entire CDB, shared undo is used, and
local undo is disabled. In this configuration, there is one active undo tablespace for a single instance
CDB. When local undo is enabled, there is one undo tablespace for each container in a single
instance configuration.
undo_tablespace='UNDOTBS1' (init parameter for shared undo)
For an Oracle RAC CDB, each PDB has one undo tablespace in each node in which it is open. With
shared undo, only a common user who has the appropriate privileges and whose
current container is the root can create an undo tablespace.
The best practice is to use local undo for a CDB. Shared undo is supported primarily for upgrade and
transitional purposes
only. Although there is minor overhead associated with local undo when compared with shared undo,
the benefits of local undo make it preferable in most environments. Local undo makes unplug
operations and point in time recovery faster, and it is required for some features, such as relocating a
PDB. By default, DBCA creates new CDBs with local undo enabled.
When local undo is not enabled, undo tablespaces are visible in static data dictionary views and
dynamic performance (V$) views when the current container is the root. Undo tablespaces are
visible only in dynamic performance views when the current container is a PDB.
Also, when local undo is disabled, Oracle Database silently ignores undo tablespace and rollback
segment operations when
the current container is a PDB.
9. The root and each PDB might require several services. You can create services for the root or for
individual PDBs.
Database services have an optional PDB property. You can create services and associate them with a
particular PDB by
specifying the PDB property. Services with a null PDB property are associated with the CDB root.
You can also use the DBMS_SERVICE supplied PL/SQL package to create services and associate them
with PDBs.
When you run CREATE_SERVICE procedure, the service is associated with the current container.
You can manage services with the SRVCTL utility, Oracle Enterprise Manager Cloud Control, and the
DBMS_SERVICE supplied PL/SQL package.
When you create a PDB, a new default service for the PDB is created automatically. The service has
the same
name as the PDB. You cannot manage this service with the SRVCTL utility. However, you can create
user-defined
services and customize them for your applications.
dispatchers='(PROTOCOL=TCP) (SERVICE=m1cdbXDB)'
local_listener='LISTENER_M1CDB' (init parameter)
10. In a CDB, the CDB root and all of the containers share a single instance, or, when using Oracle
RAC, multiple concurrent instances. You can start up and shut down an entire CDB, which in turn
determines the state of hosted PDBs. When the CDB is open, you can control the open mode of PDBs
by using either an ALTER PLUGGABLE DATABASE statement in the context of the CDB or PDB to open
or close hosted PDBs. To maintain backward compatibility, ALTER
DATABASE OPEN and ALTER DATABASE CLOSE statements are supported when they are executed and
a PDB is the
current container. You can also use the SQL*Plus STARTUP command and the SQL*Plus SHUTDOWN
command when a
PDB is the current container. However, the SQL*Plus STARTUP MOUNT command is a CDB-only
operation and cannot be used when a PDB is the current container.
Database Creation
1. Using DBCA 1455
2. Manual Database Creation using Create Database Command
Using DBCA to Create a CDB
Oracle strongly recommends using the Database Configuration Assistant (DBCA) to create a CDB,
because it is a more automated approach, and your CDB is ready to use when DBCA completes. DBCA
enables you to specify the number of PDBs in the CDB when it is created.
DBCA can be launched by the Oracle Universal Installer (OUI), depending upon the type of install that
you select. You can also launch DBCA as a standalone tool at any time after Oracle Database
installation.
You can use DBCA to create a CDB in interactive mode or noninteractive/silent mode. Interactive mode
provides a graphical interface and guided workflow for creating and configuring a CDB.
Noninteractive/silent mode enables you to script a pre-configured
CONTROL_FILES No
Strongly recommended. If not provided, then the database instance creates one control file in the same
location as the initialization parameter file. Providing this parameter enables you to multiplex control
files.
MEMORY_TARGET No
Sets the total amount of memory used by the instance and enables automatic memory management. You
can choose other initialization parameters instead of this one for more manual control of memory usage.
$su - oracle
$dbca
follow the instructions to create database using dbca
CON_ID NAME
---------- ------------------------------
1 CDB$ROOT
2 PDB$SEED
3 M1PDB1
CON_ID
------------------------------
1
CON_NAME
------------------------------
CDB$ROOT
5. list the datafiles of the container database, including those of root and all pdbs
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/m1cdb/system01.dbf
/u01/app/oracle/oradata/m1cdb/sysaux01.dbf
/u01/app/oracle/oradata/m1cdb/undotbs01.dbf
/u01/app/oracle/oradata/m1cdb/users01.dbf
/u01/app/oracle/oradata/m1cdb/pdbseed/system01.dbf
/u01/app/oracle/oradata/m1cdb/pdbseed/sysaux01.dbf
/u01/app/oracle/oradata/m1cdb/m1pdb1/system01.dbf
/u01/app/oracle/oradata/m1cdb/m1pdb1/sysaux01.dbf
/u01/app/oracle/oradata/m1cdb/m1pdb1/SAMPLE_SCHEMA_users01.dbf
/u01/app/oracle/oradata/m1cdb/m1pdb1/example01.dbf
NAME CON_ID
----------------------------------------------------------------- ----------
/u01/app/oracle/oradata/m1cdb/control01.ctl 0
/u01/app/oracle/fast_recovery_area/m1cdb/control02.ctl 0
CREATE DATABASE m1cdb
USER SYS IDENTIFIED BY sys_password
USER SYSTEM IDENTIFIED BY system_password
LOGFILE
GROUP 1 '/u01/app/oracle/oradata/m1cdb/redo01.log' SIZE 50M BLOCKSIZE 512,
GROUP 2 '/u01/app/oracle/oradata/m1cdb/redo02.log' SIZE 50M BLOCKSIZE 512,
GROUP 3 '/u01/app/oracle/oradata/m1cdb/redo03.log' SIZE 50M BLOCKSIZE 512
MAXLOGHISTORY 1
MAXLOGFILES 16
MAXLOGMEMBERS 3
MAXDATAFILES 1024
CHARACTER SET AL32UTF8
NATIONAL CHARACTER SET AL16UTF16
EXTENT MANAGEMENT LOCAL
DATAFILE '/u01/app/oracle/oradata/m1cdb/system01.dbf'
SIZE 700M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SYSAUX DATAFILE '/u01/app/oracle/oradata/m1cdb/sysaux01.dbf'
SIZE 550M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
DEFAULT TABLESPACE deftbs
DATAFILE '/u01/app/oracle/oradata/m1cdb/deftbs01.dbf'
SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
DEFAULT TEMPORARY TABLESPACE tempts1
TEMPFILE '/u01/app/oracle/oradata/m1cdb/temp01.dbf'
SIZE 20M REUSE AUTOEXTEND ON NEXT 640K MAXSIZE UNLIMITED
UNDO TABLESPACE undotbs1
DATAFILE '/u01/app/oracle/oradata/m1cdb/undotbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K MAXSIZE UNLIMITED
ENABLE PLUGGABLE DATABASE
SEED
FILE_NAME_CONVERT = ('/u01/app/oracle/oradata/m1cdb/',
'/u01/app/oracle/oradata/m1cdb/pdbseed/')
SYSTEM DATAFILES SIZE 125M AUTOEXTEND ON NEXT 10M MAXSIZE UNLIMITED
SYSAUX DATAFILES SIZE 100M
USER_DATA TABLESPACE usertbs
DATAFILE '/u01/app/oracle/oradata/m1cdb/pdbseed/usertbs01.dbf'
SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED
LOCAL UNDO ON;
1. catalog.sql
2. catproc.sql
3. utlrp.sql
4. pupbld.sql
5.catcdb.sql
1. catalog.sql
------------------
Creates the views of the data dictionary tables, the dynamic performance views, and public synonyms
for many of the views. Grants PUBLIC access to the synonyms.
2. catproc.sql
------------------
Runs all scripts required for or used with PL/SQL.
3. utlrp.sql
--------------
Recompiles all PL/SQL modules that are in an invalid state, including packages, procedures, and types.
4. pupbld.sql
-----------------
Required for SQL*Plus. Enables SQL*Plus to disable commands by user.
5. Run the catcdb.sql SQL script. This script installs all of the components required
by a CDB.
Enter the following in SQL*Plus to run the script:
@?/rdbms/admin/catcdb.sql
You can set a global port, which enables you to use EM Express to connect to all of the PDBs in the
CDB using the HTTP or HTTPS port for the CDB. Alternatively, you can set a different HTTP or
HTTPS port for every container in a CDB.
exec DBMS_XDB_CONFIG.SETGLOBALPORTENABLED(TRUE);
• To set the HTTP port for the current container, run the following procedure:
exec DBMS_XDB_CONFIG.SETHTTPPORT(http_port_number);
• To set the HTTPS port for the current container , run the following procedure:
exec DBMS_XDB_CONFIG.SETHTTPSPORT(https_port_number);
Replace https_port_number with the appropriate HTTPS port number.
After the port is set, you can access EM Express in one of the following ways:
• To use the global port, enter the EM Express URL provided by Database Configuration Assistant
(DBCA) when it configured the CDB that includes the PDB. When the EM Express login screen
appears, specify your administrator credentials, and enter the name of the PDB that you want to connect
to in the Container Name field.
Replace database_hostname with the host name of the computer on which the database instance is
running, and replace http_port_number with the appropriate HTTP port number.
Replace database_hostname with the host name of the computer on which the database instance is
running, and replace https_port_number with the appropriate HTTPS port number.
When connected to the root, EM Express displays data and enables actions that apply to the entire CDB.
When connected to a PDB, EM Express displays data and enables actions that apply to the PDB only.