ORACLE12C new features--CDB and PDB

Source: Internet
Author: User
Tags unique id sqlplus

Oracle 12C introduces new features for CDB and PDB, allowing a single database container (CDB) to host multiple pluggable databases (PDB) in a multi-tenant environment introduced in Oracle 12C databases (multitenant environment). CDB is all called container database, the Chinese translation is a data base container, the PDB is all called pluggable database, you can plug and Unplug databases. Before Oracle 12C, the instance and database were one-to-one or many-on relationships (RAC): an instance could be associated with only one database, and the database could be loaded by multiple instances. The instance and database cannot be a one-to-many relationship. When you enter Oracle 12C, the instance and database can be a one-to-many relationship. The following is an official document about the CDB vs. pdb diagram.

650) this.width=650; "Src=" https://s5.51cto.com/wyfs02/M01/9B/88/wKioL1lkRQCCns6HAAD0j4lp1IY096.png-wh_500x0-wm_ 3-wmp_4-s_850200442.png "title=" 1.png "alt=" Wkiol1lkrqccns6haad0j4lp1iy096.png-wh_50 "/>

In fact, if you are familiar with SQL Server, such CDB and PDB is not the sense and SQL Server single-instance multi-database architecture is the same thing. Like Pdb$seed can be regarded as the master, msdb and other system database, PDBs can be regarded as user-created database. The concept of pluggable and the separation and attachment of user databases in SQL Server is a matter of fact. It seems that Oracle also "copied" the concept of SQL Server, just a makeover packaging.

1. CDB components (component of a CDB)

A CDB database container contains the following components:


Root component

ROOT is also known as Cdb$root, which stores the metadata provided by Oracle and the Common user, an example of which is the source code for the PL/SQL package provided by Oracle, Common user refers to users who exist in each container.


Seed component

Seed is also called pdb$seed, this is the template you created for the PDBs database, and you cannot add or modify an object in seed. There is only one seed in a CDB. This gratitude, personal feeling is very similar to the model database in SQL Server.


PDBs

CDB can have one or more Pdbs,pdbs backwards compatible, which can be used as previously done in the database PDBs, which refers to most general operations.

Each of these components can be called a container. Therefore, root (root) is a container, and seed (seed) is a container, and each PDB is a container. Each container has a unique ID and name in the CDB.


Attention:

①: A CDB can contain 253 pdb (minus one is seed and can create 252 pdb).

The data files for ②:root,seed and each PDB are independent.

③: A single instance of CDB has a redo Log;rac environment in which each instance has a redo log.

④: There is only a set of background processes that are shared by root and all PDB.

The global database name of ⑤:root is the global database name of CDB, and the global database name of the PDB is defined by the PDB name and the Db_domain parameter together.


⑥: A CDB uses a spfile or a pfile, where the value of the parameter set for root can be inherited by the PDB. Alternatively, you can use the ALTER SYSTEM statement to set the parameters of the PDB. When performing an operation on a parameter file, you must use common user and use as SYSDBA, Assysoper, as sysbackup to connect to the database. To create a CDB, you must set the value of the initialization parameter enable_pluggable_database to True.


⑦: All PDB character sets use the CDB character set.

You can set all the PDB's time zone to be the same as CDB, or you can set the time zone separately for the PDB.

The block size is applied to the entire CDB.

A CDB also has only one control file (which can be multiplexed).


⑧:root and each PDB have their own Sysaux tablespace and system table space. You can set the default tablespace for root and for each PDB. The default temporary table space is only one for the entire CDB, but you can create a temporary tablespace for each PDB.


⑨: The Undo table space is unique to CDB. In CDB, the initialization parameter undo_management must be set to auto. When the current container is PDB, you cannot view the Undo table space through the data dictionary view, only through the dynamic performance view.


2. Introduction to PDB

2.1. Advantages of new PDB features

"Can integrate multiple PDB into a single platform.

"Can quickly provide a new PDB or a clone of an existing PDB.

"With the plug-in technology, the existing database can be quickly redeployed to a new platform.

"Multiple PDB database patches or upgrades are completed at once.

"A PDB can be patched or upgraded by unplugging a single PDB to a higher version of the CDB.

"Separates the contents of a PDB from the many PDB in the same CDB.

"Separates these PDB application administrators from their responsibilities.

2.2. Features of new PDB features

"In a CDB, you can have a lot of PDB.

"PDB and the normal database of versions prior to 12.1 are backwards compatible.

The PDB is transparent to the application-you don't need to change the client code or database objects.

"Each instance of the RAC opens CDB as a whole (so CDB and the PDB database versions in it are the same).

Session only sees the PDB that it connects to itself.

You can pull a pdb out of a CDB and then insert another CDB.

"You can clone the PDB between the same CDB or a different CDB.

The resource manager expands with the capabilities of the PDB.

The entity PDB is implemented by SQL statements (create, unplug, insert, clone, clear, set open mode).

"When connected to the so-called" root "(root), the CDB administrator performs these operations.

"All PDB can be backed up one at a time, but can be recovered separately.

2.3, the PDB detailed

Each PDB has its own private data dictionary for user-created database objects; CDB, on the other hand, also contains a data dictionary of Oracle-provided systems, where each data dictionary defines its own namespace. In other words, there is a global data dictionary (CDB level) and a local data dictionary (PDB level).

"Has a new separate data dictionary schema that allows a PDB to be quickly pulled out of a CDB and inserted into a different CDB.

"Each PDB can see only the read-only definition of the system provided by Oracle.

"has global database parameters, as well as local database parameters. The PDB parameter is only specific to the PDB, and when unplugged, the PDB parameter remains unchanged.

The database user can be global (CDB) or local (PDB). SYS and system users are present in level two db at the outset. If you create a new user in the CDB, you can see the user in the PDB as well. Users created in the PDB can only be used in that PDB.

The temporary table space can be global or local.

The Redo log and undo table spaces are global (CDB level).

The Data guard functions as a whole at the CDB level; The Rman scheduled backup is also done as a whole at the CDB level; You can back up only one PDB at any time.

"When applying the PDB, no code modification is required; The system administrator can connect to CDB; The service name in the connection string determines the target PDB.

The PDB allows for clearer declarations to define an application; a PDB is ignorant of the other PDB in the same CDB; each PDB is a closed container. This guarantees a new level of DB independence and security.


3. Daily Operation:

3.1. View the current container

Sql> show Con_name;


Con_name

------------------------------

Cdb$root

------OR:

Sql> Select Sys_context (' Userenv ', ' con_name ') "Current Container" from dual;


Current Container

--------------------------------------------------------------------------------

Cdb$root


3.2. View the PDB information in CDB:

Sql> Select con_id, dbid, GUID, name, open_mode from V$pdbs;


con_id DBID GUID NAME Open_mode

---------- ---------- -------------------------------- ------------------------------ ----------

2 427872663 439bfcb2a2ee1be7e055000000000001 pdb$seed READ only

3 1891424478 439c5b1174c121b7e055000000000001 Feige READ WRITE---Feige is a PDB


3.3. Create a new PDB:

Sql> Create pluggable Database test_pdb Admin user admin identified by admin;

sql> Alter pluggable database test_pdb open; ----Open the Test_pdb

Sql> select Con_id,dbid,con_uid,guid,name,open_mode,create_scn,total_size,block_size from V$pdbs; ---View the status of the PDB


con_id DBID con_uid GUID NAME open_mode create_scn total_s IZE block_size

---------- ---------- ---------- -------------------------------- ------------------------------ ---------- --------- - ---------- ----------

2 427872663 427872663 439bfcb2a2ee1be7e055000000000001 pdb$seed READ only 1594401 838860800 8192

3 1891424478 1891424478 439c5b1174c121b7e055000000000001 feige READ WRITE 1753608 865075200 8192

4 2998508999 2998508999 53f376e8715628bce055000000000001 test_pdb READ WRITE 1757024 859832320 8192


(the "Admin user" clause is required, in the extended format, to give the new user permission and a role, and the user can create a fresh session only within the admin.) After the pluggable database is created, the new PDB is in mounted mode)


3.4. Clone a PDB

Sql> Create pluggable database test2_pdb from test_pdb; ---test_pdb must be open before it can be opened

sql> Alter pluggable database test2_pdb open; ---then open the PDB


3.5. Switch to PDB, or switch to CDB

Sql> alter session set CONTAINER=TEST_PDB; ---switch to the PDB


Sql> alter session set Container=cdb$root; ---switch to CDB


3.6. Close a PDB and close all PDB

sql> Alter pluggable database test_pdb close; ---Close test_pdb this PDB database

Sql> Alter pluggable database all close; ---Close all the PDB in the database


3.7. Plug and unplug a PDB database

sql> Alter pluggable database Feige close; ---Feige this pdb off first

sql> Alter pluggable database Feige unplug into '/opt/oracle/oradata/feige.xml ';

(feige.xml: The file determines the data file name and full path information. This information is used when inserting an operation. Note: The PDB is still part of the CDB from which it was pulled, but now the state becomes unplugged (UNPLUGGED). )

sql> Drop pluggable database feige keep datafiles; ----Delete this PDB in the current container

----If there are two containers on this server, go to another container and insert the PDB

EXEC dbms_pdb.  Check_plug_compatibility (pdb_descr_file=> '/opt/oracle/oradata/feige.xml '); --see if the PDB and this container are compatible and if the error indicates incompatible

----start inserting the PDB, the Using keyword must follow the absolute path described by the PDB, which is the result of the previous pull-out operation. XML file)

Create pluggable database feige using '/opt/oracle/oradata/feige.xml ' move File_name_convert = ('/cdb1/', '/cdb2/');

----finally open this PDB

Alter pluggable database Feige open;


3.8. Connect to the PDB database:

The connection PDB is actually the same as the connected single-instance database, the service name of the connection is registered, and can be done in the following way:

①: Use the Listener registered service name connection as follows:

[Email protected] ~]$ LSNRCTL Status---Use this command to find the registered service name

[[email protected] ~]$ sqlplus system/[email protected]:1521/feige---to connect to the PDB database


②: Connect via TNSNames profile, as follows:

FEIGE =

(DESCRIPTION =

(ADDRESS = (PROTOCOL = TCP) (HOST = localhost) (PORT = 1521))

(Connect_data =

(SERVER = dedicated)

(service_name = feige)

)

)


[[email protected] admin]$ sqlplus system/[email protected]----Use this method to connect


---to this point, CDB and the PDB first summarized here, some basic knowledge and operation are introduced


This article is from the "stupid Child's DBA path" blog, please be sure to keep this source http://fengfeng688.blog.51cto.com/4896812/1946278

ORACLE12C new features--CDB and PDB

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.