Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

New Features of Oracle12C-- cdb and pdb

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Oracle 12C introduces new features of CDB and PDB, allowing a database container (CDB) to host multiple pluggable databases (PDB) in the multi-rent user environment (Multitenant Environment) introduced by ORACLE 12C databases. The full name of CDB is Container Database, the Chinese translation is database container, and the full name of PDB is Pluggable Database. You can plug and unplug the database. Before ORACLE 12C, the instance and database had an one-to-one or many-to-one relationship (RAC): that is, an instance could only be associated with one database, and the database could be loaded by multiple instances. It is impossible for an instance to have an one-to-many relationship with a database. When entering ORACLE 12C, the instance can have an one-to-many relationship with the database. The following is a diagram of the official documentation on the relationship between CDB and PDB.

In fact, if you are familiar with SQL SERVER, does this kind of CDB and PDB feel the same thing as SQL SERVER's single-instance multi-database architecture? Like PDB$SEED can be seen as master, msdb and other system databases, PDBS can be seen as user-created databases. The concept of pluggable and the separation and attachment of the user database in SQL SERVER is actually the same thing. It seems that ORACLE also "plagiarized" the concept of SQL SERVER, only a makeover of the packaging.

1. CDB component (Components of a CDB)

An CDB database container contains the following components:

ROOT component

ROOT, also known as CDB$ROOT, stores the metadata and Common User provided by ORACLE. An example of metadata is the source code of the PL/SQL package provided by ORACLE, and Common User is the user that exists in each container.

SEED component

Seed, also known as PDB$SEED, is the template you use to create a PDBS database. You cannot add or modify an object in Seed. There can be and only one Seed in a CDB. This feeling is very similar to the model database in SQL SERVER.

PDBS

There can be one or more PDBS,PDBS backward compatible in CDB, and PDBS can be manipulated as before in the database, in this case, most general operations.

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

Note:

①: a CDB can contain 253 PDB (252 PDB can be created without one seed).

②: 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 one 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; the global database name of PDB is defined by both the PDB name and DB_DOMAIN parameters.

⑥: a CDB uses either a SPFILE or a PFILE, where the value of the parameter set for ROOT can be inherited by PDB. Alternatively, you can use the ALTER SYSTEM statement to set the parameters of PDB. When performing operations on parameter files, you must use common user and use AS SYSDBA, ASSYSOPER, AS SYSBACKUP to connect to the database. To create a CDB, the initialization parameter ENABLE_PLUGGABLE_DATABASE must be set to TRUE.

⑦: all PDB character sets use CDB's character set.

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

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 and SYSTEM tablespaces. Default tablespaces can be set for root and for each PDB. The default temporary tablespace is only one for the entire CDB, but temporary tablespaces can be created for each PDB.

⑨: undo tablespaces are unique to CDB. In CDB, the initialization parameter UNDO_MANAGEMENT must be set to AUTO. When the current container is PDB, the undo tablespace cannot be viewed through the data dictionary view, but only through the dynamic performance view.

2. Introduction to PDB

2.1. the advantages of the new features of PDB

"multiple PDB can be integrated into one platform.

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

Through the plug technology, the existing database can be quickly redeployed to a new platform.

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

"by unplugging a single PDB to a different CDB in a later version, you can patch or upgrade a PDB.

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

"separate the responsibilities of these PDB application administrators.

2.2.2.The functions of new features of PDB

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

"PDB and pre-12.1 plain databases are backward compatible.

"PDB is transparent to applications-you don't need to change client code or database objects.

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

"the session only sees the PDB to which it is connected.

"you can pull a PDB from one CDB and insert another CDB.

"you can clone PDB between the same CDB or different CDB.

"Resource managers are expanded with the capabilities of PDB.

"entity PDB operations are implemented through SQL statements (create, unplug, insert, clone, clear, set open mode).

When connected to the so-called 'root', the CDB administrator performs these operations.

"all PDB can be backed up once, but can be restored separately.

2.3.The detailed explanation of PDB

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

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

"each PDB can only see a read-only definition of the system provided by the oracle.

"there are global database parameters and local database parameters. The PDB parameter only belongs to a specific PDB, and when unplugged, the PDB parameter will remain the same.

"Database users can be global (CDB) or local (PDB). SYS and SYSTEM users exist in two levels of DB from the very beginning. If you create a new user in CDB, you can also see that user in PDB. Users created in PDB can only be used in that PDB.

"temporary tablespaces can be global or local.

"Redo logs and Undo tablespaces are global (CDB level).

"Data Guard works at the CDB level as a whole; backups scheduled by RMAN are also done at the CDB level as a whole; you can back up only one PDB at any time.

"when the application connects to the PDB, there is no need to modify the code; the system administrator can connect the service name in the CDB; connection string to determine the target PDB.

"PDB allows you to define an application more clearly; an PDB knows nothing about other PDB in the same CDB; each PDB is an airtight container. This ensures the independence and security of the new level of DB.

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

Create a new PDB:

SQL > create pluggable database test_pdb admin user admin identified by admin

SQL > alter pluggable database test_pdb open;-Open test_pdb

SQL > select con_id,dbid,con_uid,guid,name,open_mode,create_scn,total_size,block_size from vdatabases;-View the status of pdb

CON_ID DBID CON_UID GUID NAME OPEN_MODE CREATE_SCN TOTAL_SIZE 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, permissions and roles are given to the new user, who can only create new sessions within the admin. After creating the pluggable database, 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

Switch to PDB, or switch to CDB

SQL > alter session set container=test_pdb;-switch to pdb

SQL > alter session set container=cdb$root;-switch to CDB

Close one pdb and close all pdb

SQL > alter pluggable database test_pdb close;-close test_pdb, the pdb database

SQL > alter pluggable database all close;-close all pdb in the database

Insert and unplug a pdb database

SQL > alter pluggable database feige close;-close the pdb of feige first

SQL > alter pluggable database feige unplug into'/ opt/oracle/oradata/feige.xml'

(feige.xml: the file determines information such as the name and full path of the data file. This information is used during the insert operation. Note: PDB is still part of the CDB it pulled, but now the state has changed to UNPLUGGED. )

SQL > drop pluggable database feige keep datafiles;-delete the pdb in the current container

-if there are two containers on this server, enter another container and insert the pdb

Exec DBMS_PDB.Check_Plug_Compatibility (PDB_Descr_File= >'/ opt/oracle/oradata/feige.xml');-- check whether pdb is compatible with this container. If an error is reported, it is not compatible.

-start inserting pdb, (the using keyword must be followed by the absolute path described by PDB, that is, the .XML file generated during the previous pull operation)

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

-finally, open the pdb.

Alter pluggable database feige open

3.8. connect to the pdb database:

Connecting to pdb is actually the same as connecting to a normal single instance database. You can connect to the registered service name in the following ways:

①: connect with the service name registered by listening, as follows:

[oracle@localhost ~] $lsnrctl status-find the registered service name through this command

[oracle@localhost ~] $sqlplus system/oracle@192.168.2.100:1521/feige-this connects to the PDB database

②: connect through the tnsnames configuration file, as follows:

Feige =

(DESCRIPTION =

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

(CONNECT_DATA =

(SERVER = DEDICATED)

(SERVICE_NAME = feige)

)

)

[oracle@localhost admin] $sqlplus system/oracle@feige-connect in this way

-so far, cdb and pdb are summarized here, and some basic knowledge and operations are introduced.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report