0% found this document useful (0 votes)
32 views9 pages

Oracle 12c Multitenant Database Creation

Uploaded by

Azmath Tech Tuts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views9 pages

Oracle 12c Multitenant Database Creation

Uploaded by

Azmath Tech Tuts
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 9

About Creating a CDB

The procedure for creating a multitenant container database (CDB) is very similar to the
procedure for creating a non-CDB

Configuring the CDB


1. In a CDB, most user data is in the PDBs. The root contains no user data or minimal user data. Plan
for the PDBs that will be
part of the CDB. The disk storage space requirement for a CDB is the space required for the Oracle
Database installation plus the sum of the space requirements for all of the PDBs that will be part of
the CDB. A CDB can contain up to 4,096 PDBs, but you can limit the CDB to a smaller number of
PDBs by setting the MAX_PDBS initialization parameter.

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.

To create a CDB, the ENABLE_PLUGGABLE_DATABASE initialization parameter must be set to TRUE.

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

GROUP# MEMBER CON_ID


---------- --------------------------------------------------------------------------- ----------
1 /u01/app/oracle/oradata/m1cdb/redo01.log 0
2 /u01/app/oracle/oradata/m1cdb/redo02.log 0
3 /u01/app/oracle/oradata/m1cdb/redo03.log 0

6. There is a separate SYSAUX tablespace for the root and for each PDB.

FILE_NAME TABLESPACE_NAME CON_ID


----------------------------------------------------------------- --------- ------------------------------ ----------
/u01/app/oracle/oradata/m1cdb/sysaux01.dbf SYSAUX 1
/u01/app/oracle/oradata/m1cdb/pdbseed/sysaux01.dbf SYSAUX 2
/u01/app/oracle/oradata/m1cdb/m1pdb1/sysaux01.dbf SYSAUX 3

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.

FILE_NAME TABLESPACE_NAME CON_ID


----------------------------------------------------------------- --------------- ----------------------------------------
/u01/app/oracle/oradata/m1cdb/system01.dbf SYSTEM 1
/u01/app/oracle/oradata/m1cdb/pdbseed/system01.dbf SYSTEM 2
/u01/app/oracle/oradata/m1cdb/m1pdb1/system01.dbf SYSTEM 3
/u01/app/oracle/oradata/m1cdb/users01.dbf USERS 1
/u01/app/oracle/oradata/m1cdb/m1pdb1/SAMPLE_SCHEMA_users01.dbf USERS 3

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

listing default permanent and temporary tablespaces of cdb


select property_name,property_value from database_properties where property_name like
'DEFAULT_%TABLE%'

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.

In a CDB, the UNDO_MANAGEMENT initialization parameter must be set to AUTO, and an undo


tablespace is required
to manage the undo data.

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

Recommended Minimum Initialization Parameters


DB_NAME Yes
Database identifier. Must correspond to the value used in the CREATE DATABASE statement.
Maximum 8 characters.

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.

#xhost + (from root user)

$su - oracle
$dbca
follow the instructions to create database using dbca

Check if the database is a multitenant container database

SQL> select name,cdb,con_id from v$database;

NAME CDB CON_ID


--------- --- --------- -------------
M1CDB YES 0

2. To list all the containers with in the multitenant container database

SQL> select con_id,name from v$containers;

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

3. To see the container to which you are currently connected

SQL> show con_id

CON_ID
------------------------------
1

SQL> show con_name

CON_NAME
------------------------------
CDB$ROOT

4. Check the instance details of the container database

SQL> select instance_name,status,con_id from v$instance;

INSTANCE_NAME STATUS CON_ID


---------------- ------------ ----------- -----------
m1cdb OPEN 0

5. Check the redo log files of the container database

SQL> select group#,member,con_id from v$logfile


GROUP# MEMBER CON_ID
---------- ------------------------------------------------------- --------------
3 /u01/app/oracle/oradata/m1cdb/redo03.log 0
2 /u01/app/oracle/oradata/m1cdb/redo02.log 0
1 /u01/app/oracle/oradata/m1cdb/redo01.log 0

5. list the datafiles of the container database, including those of root and all pdbs

SQL> select name from v$datafile;

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

list the controlfiles of the container database

select name,con_id from v$controlfile;

NAME CON_ID
----------------------------------------------------------------- ----------
/u01/app/oracle/oradata/m1cdb/control01.ctl 0
/u01/app/oracle/fast_recovery_area/m1cdb/control02.ctl 0

To list all temporary files

NAME CON_ID STATUS


------------------------------------------------------------ ---------- -------
/u01/app/oracle/oradata/m1cdb/temp01.dbf 1 ONLINE
/u01/app/oracle/oradata/m1cdb/pdbseed/pdbseed_temp01.dbf 2 ONLINE
/u01/app/oracle/oradata/m1cdb/m1pdb1/m1pdb1_temp01.dbf 3 ONLINE

2. Manual Database Creation using Create Database Command

1. Specify an Instance Identifier (SID)


$export ORACLE_SID=newcdb
set ORACLE_SID=mynewdb (Windows)

2. Createthe Initialization Parameter File


$vi initm1cdb.ora

m1cdb.__oracle_base='/u01/app/oracle'#ORACLE_BASE set from


environment
*.audit_file_dest='/u01/app/oracle/admin/m1cdb/adump'
*.audit_trail='db'
*.compatible='12.1.0.0.0'
*.control_files='/u01/app/oracle/oradata/m1cdb/control01.ctl','/u01/a
pp/oracle/fast_recovery_area/m1cdb/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='m1cdb'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=6800m
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=m1cdbXDB)'
*.enable_pluggable_database=true
*.local_listener='LISTENER_M1CDB'
*.log_archive_format='%t_%s_%r.dbf'
*.memory_target=2360m
*.open_cursors=300
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'
Enter the following command at a Windows command prompt:
oradim ­NEW ­SID sid ­STARTMODE MANUAL ­PFILE file
Replace the following placeholders with appropriate values:
– sid - The desired SID (for example mynewdb)
– file - The full path to the text initialization parameter file

3. Connect to the Instance


$sqlplus / as sysdba

SQL>STARTUP NOMOUNT PFILE=$ORACLE_HOME/dbs/initm1cdb.ora

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

Configuring EM Express for a CDB


For a CDB, you can configure Oracle Enterprise Manager Database Express (EM Express) for the root
and for each PDB by setting a global HTTPS port, or you can set a different port for every container in
the CDB.

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.

To configure EM Express for a CDB:


1. In SQL*Plus, access a container in a CDB.
The user must have common SYSDBA administrative privilege, and you must exercise this privilege
using AS SYSDBA at connect time. The container can be the root or a PDB.

2. Set the port in one of the following ways:


• To set the global port, connect to the CDB$ROOT, and issue the following SQL statement to configure
the global port for the 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);

Replace http_port_number with the appropriate 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.

• The URL for the HTTP port for a container:


http://database_hostname:http_port_number/em/

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.

• The URL for the HTTPS port for a container:


https://database_hostname:https_port_number/em/

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.

Ref: Oracle 12c Database Concepts and Administrator Guide

You might also like