In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Introduction to the concept of CDB and PDB
CDB and PDB are new features introduced by Oracle 12C. In the multi-rent user environment (Multitenant Environment) introduced by ORACLE 12C databases, one database container (CDB) is allowed to host multiple pluggable databases (PDB). 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. Here is a diagram of the relationship between CDB and PDB:
A CDB container database usually contains CDB$ROOT and PDB$SEED components:
A. CDB$ROOT stores the metadata provided by ORACLE and Common User,Common User refers to the users who exist in each container. Check out:
Show con_name
B.PDB$SEED is the template for creating a PDB database. There can be only one Seed in a CDB. Check out:
Show pdbs
C.PDB pluggable database. There can be one or more PDB in CDB. Check out:
Show pdbs
Create a CDB container database
When creating a database, dbca can choose whether to create a container database or a traditional database, as shown in the following figure: create CDB:
Create a pdb:
a. The command create pluggable database creates:
Create pluggable database app1 admin user pdba identified by pdba123
Specify the path to create the pdb:
Mkdir-p / u01/app/oracle/oradata/prod/data
Create pluggable database app1 admin user pdba identified by pdba123 FILE_NAME_CONVERT= ('/ u01qapax oraclecosoradata plaza prodactyoradataUniplicactyoradataplicacleoradata')
B.dbca creates a pdb:
Confirm:
Start pdb:
Alter pluggable database APP1 open
c. Clone the pdb database:
Alter system set db_create_file_dest='/u01/app/oracle/oradata/prod/'
Create pluggable database app3 from app2
Delete pdb
Close the corresponding pdb first, and then delete the pdb:
Alter pluggable database app3 close immediate
Drop pluggable database app3 including datafiles
Just delete the library, not the file:
Drop pluggable database app3 keep datafiles
Alter pluggable database app3 unplug into'/ home/oracle/app3.xml'
Drop pluggable database app3 keep datafiles
Show pdbs
Create pluggable database app5 using'/ home/oracle/app3.xml' nocopy
Switch container
Switch to app1 pdb:
Alter session set container=app1
Switch to the CDB container
Alter session set container=CDB$ROOT
See which container you currently belong to:
Show con_name
Select sys_context ('USERENV','CON_NAME') from dual
Start and shut down pdb
a. Specify pdb to shut down and start:
Alter pluggable database app1 open
Startup pluggable database app1
Start to read-only mode. The newly created pdb must be started once before it can be set to read only, otherwise report
ERROR at line 1:
ORA-65085: cannot open pluggable database in read-only mode:
You can confirm it from the dba_pdbs view. For the pdb of NEW, you need to open:
SQL > col pdb_name for A10
SQL > select pdb_name,status from dba_pdbs
PDB_NAME STATUS
--
APP1 NORMAL
PDB$SEED NORMAL
APP2 NORMAL
APP3 NORMAL
APP4 NEW
Create a new app3 database, and then boot to read only:
Create pluggable database app3 from app2
Alter pluggable database app3 open read only
Alter pluggable database app3 open read only
Show pdbs
Alter pluggable database app1 close immediate
B. Switch to the corresponding pdb to shut down and start:
Alter session set container= app1
Startup
Alter session set container= app1
Shutdown immediate
C. Concentrate on pdb:
Open all pdb:
Alter pluggable database all open
Close all pdb:
Alter pluggable database all close immediate
Pdb automatically starts:
Oracle 12.1 and oracle12.2 versions. By default, PDB does not start with CDB startup. Oracle 12.1 can only be implemented through triggers:
CREATE TRIGGER open_all_pdbs
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN'
END
/
Delete trigger:
Drop trigger open_all_pdbs
After oracle12.2, you can use save state to save the current state of the pdb database.
Show pdbs
Alter pluggable database app1 save state
Startup force
Show pdbs
View state status:
Col con_name for a10
Select con_name, state from dba_pdb_saved_states
Delete discard state status:
Alter pluggable database app1 discard state
View pdb information
View all pdb:
Show pdbs
Col name for a20
Select con_id,dbid,name,open_mode from v$pdbs
Select name,cause, type,message,status from pdb_plug_in_violations
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.