Oracle 12c - Multitenant Feature

Post on 16-Jul-2015

144 Views

Category:

Technology

5 Downloads

Preview:

Click to see full reader

Transcript

Oracle 12c Multitenant Feature

Overview

• A new option for Oracle Database 12c, Oracle Multitenant helps customers reduce IT costs by streamlining consolidation, provisioning, upgrades, and more. It is supported by a new architecture that allows a multitenant container database to hold many pluggable databases. And it fully balances other options, including Oracle Real Application Clusters and Oracle Active Data Guard. An existing database can be simply adopted, with no change, as a pluggable database; and no changes are needed in the other tiers of the application.

Container & Pluggable Database

• A CDB is very similar to a conventional Oracle database. It’s main purpose is to house the data dictionary for those objects that are owned by the root container and those that are accessible to all PDBs. A single CDB can host multiple PDBs.

• A PDB contains only information pertaining to itself and hence only has datafiles and tempfiles. It also has it’s own data dictionary.

Creating a Container Database (CDB) - OUI

• We can use the Oracle Universal Installer (OUI) to create a CDB during the 12c software installation by checking the “Create as Container database” option on the “Typical Installation Screen”. We also have an option to create a single PDB at this time.

Creating a Container Database (CDB) - OUI

• We can create a CDB on the “Database Identifiers” screen as well.

Creating a Container Database (CDB) - DBCA

• A CDB can be created using the Database Configuration Assistant (DBCA) also. The "Creation Mode" page allows us to enter the default installation configuration details directly.

Creating a Container Database (CDB) - DBCA

• If we choose the "Advanced Mode" option, we can create a CDB and multiple PBDs in one go.

Creating a Container Database (CDB) – Manual Creation

• We can also create a CDB manually. The following script can be used for the same –

• 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. We can also specify the seed datafiles explicitly.

• 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

Managing a Pluggable Database (PDB) - DBCA

• On the opening “Database Operation” screen of DBCA, a new option has been added which allows us to manage pluggable databases of an existing container database.

Managing a Pluggable Database (PDB) - DBCA

• Resulting screen options.

Creating a Pluggable Database (PDB) - DBCA

• On choosing the first option “Create a Pluggable Database” on the last screen, we are asked to select the Container Database where the PDB would be created.

Creating a Pluggable Database (PDB) - DBCA

• The first option “Create a new Pluggable Database” can be used to create a fresh PDB. If we want to plug a previously unplugged database, then one of the rest two options, PDB Archive or PDB File Set, can be used. These options can be used to match the format of the files containing the unplugged PDB.

Creating a Pluggable Database (PDB) - DBCA

• On this screen, we enter the PDB name, database location and admin credentials.

Creating a Pluggable Database (PDB) - DBCA

• The new PDB is created as a clone of the seed database we created during the Container Database creation.

Unplugging a Pluggable Database (PDB) - DBCA

• On the "Manage Pluggable Databases" screen shown previously, we can select the "Unplug a Pluggable Database" option to unplug a PDB. On the resulting screen, we select the container database that houses the pluggable database to be unplugged.

Unplugging a Pluggable Database (PDB) - DBCA

• After we select the PDB to unplug, we need to decide whether to use a pluggable database archive or file set and then enter the appropriate location details.

Creating a Pluggable Database (PDB) using Archive or File Set - DBCA

• We can select either of the two options, “Create Pluggable Database From PDB Archive" or "Create Pluggable Database using PDB File Set“ and enter the location details of the required files.

Creating a Pluggable Database (PDB) using Archive or File Set - DBCA

• Here we enter the pluggable database name, database location and admin credentials.

Deleting a Pluggable Database (PDB) - DBCA

• After choosing the container database on the “Database List” screen, we can select the pluggable database that we wish to delete from the drop down list on the resulting screen.

Configuring a Pluggable Database (PDB) - DBCA

• After choosing the container database on the “Database List” screen, we can select the pluggable database that we wish to configure from the drop down list on the “Pluggable Database List” screen. On the resulting “Pluggable Database Options” screen, we can choose to configure Label Security.

Creating a Pluggable Database (PDB) - Manually

• To create a new PDB from a seed database, we need to tell Oracle where the file should be placed.

• CONN / AS SYSDBA

• CREATE PLUGGABLE DATABASE pdb2 ADMIN USER pdb_adm IDENTIFIED BY Password1 FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdbseed/','/u01/app/oracle/oradata/cdb1/pdb2/');

• Alternatively,

• CONN / AS SYSDBA

• ALTER SESSION SET PDB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/cdb1/pdbseed/','/u01/app/oracle/oradata/cdb1/pdb3/';

• CREATE PLUGGABLE DATABASE pdb3 ADMIN USER pdb_adm IDENTIFIED BY Password1;

• We can see the PDBs that are present by querying the DBA_PDBS and V$PDBS views.

• SELECT pdb_name, status FROM dba_pdbs ORDER BY pdb_name;

• SELECT name, open_mode FROM v$pdbs ORDER BY name;

• The PDBs are created with the status of ‘NEW’. They must be opened in READ WRITE mode for the integration with the CDB to be complete.

• ALTER PLUGGABLE DATABASE pdb2 OPEN READ WRITE;

Unplugging a Pluggable Database (PDB) - Manually

• Before unplugging a PDB, we must make sure it is closed.

• ALTER PLUGGABLE DATABASE pdb2 CLOSE;

• ALTER PLUGGABLE DATABASE pdb2 UNPLUG INTO '/u01/app/oracle/oradata/cdb1/pdb2/pdb2.xml';

• We can delete the PDB, choosing to keep the files on the file system.

• DROP PLUGGABLE DATABASE pdb2 KEEP DATAFILES;

Plugging a Pluggable Database (PDB) - Manually

We need to first check if the PDB is compatible with the CDB.SET SERVEROUTPUT ON DECLARE

l_result BOOLEAN; BEGIN

l_result := DBMS_PDB.check_plug_compatibility( pdb_descr_file => '/u01/app/oracle/oradata/cdb1/pdb2/pdb2.xml', pdb_name => 'pdb2'); IF l_result THEN

DBMS_OUTPUT.PUT_LINE('compatible'); ELSE

DBMS_OUTPUT.PUT_LINE('incompatible'); END IF;

END; / compatiblePL/SQL procedure successfully completed.

CREATE PLUGGABLE DATABASE pdb5 USING '/u01/app/oracle/oradata/cdb1/pdb2/pdb2.xml' FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdb2/','/u01/app/oracle/oradata/cdb1/pdb5/');

Or,CREATE PLUGGABLE DATABASE pdb2 USING '/u01/app/oracle/oradata/cdb1/pdb2/pdb2.xml' NOCOPY TEMPFILE REUSE; ALTER PLUGGABLE DATABASE pdb2 OPEN READ WRITE;

Cloning a Pluggable Database (PDB) - Manually

Cloning an existing local PDB is similar to creating a new PDB from the seed PDB, except that now we would be using a non-seed PDB as a source.

ALTER PLUGGABLE DATABASE pdb3 CLOSE; ALTER PLUGGABLE DATABASE pdb3 OPEN READ ONLY; CREATE PLUGGABLE DATABASE pdb4 FROM pdb3 FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/pdb3/','/u01/app/oracle/oradata/cdb1/pdb4/'); ALTER PLUGGABLE DATABASE pdb4 OPEN READ WRITE; -- Switch the source PDB back to read/write ALTER PLUGGABLE DATABASE pdb3 CLOSE; ALTER PLUGGABLE DATABASE pdb3 OPEN READ WRITE;

We can also clone from a remote PDB using a database link in the local CBD.CREATE PLUGGABLE DATABASE pdb5 FROM remote_pdb5@remotecdb1 FILE_NAME_CONVERT=('/u01/app/oracle/oradata/cdb1/remote_pdb5/','/u01/app/oracle/oradata/cdb1/pdb5/'); ALTER PLUGGABLE DATABASE pdb4 OPEN READ WRITE;

*This functionality does not work properly in the 12.1.0.1 release of the database.

Deleting a Pluggable Database (PDB) - Manually

When dropping a PDB, we can choose to keep or drop the associated datafiles. The PDBs must be closed before dropping.ALTER PLUGGABLE DATABASE pdb2 CLOSE; DROP PLUGGABLE DATABASE pdb2 KEEP DATAFILES; ALTER PLUGGABLE DATABASE pdb3 CLOSE; DROP PLUGGABLE DATABASE pdb3 INCLUDING DATAFILES;

SELECT name, open_mode FROM v$pdbs ORDER BY name; NAME OPEN_MODE ------------------------------ ----------PDB$SEED READ ONLY PDB1 MOUNTED

Oracle Documentation & References

• Oracle Database 12c: Introduction to a Multitenant Environment with Tom Kyte -http://www.youtube.com/watch?v=2MrouEW9j88&feature=youtu.be

• White Paper - http://www.oracle.com/technetwork/database/multitenant/overview/multitenant-wp-12c-2078248.pdf

• Data Sheet - http://www.oracle.com/technetwork/database/multitenant-ds-12c-1951720.pdf

top related