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)05/31 Report--
This article mainly explains "CDB and PDB creation, connection, start and close methods," interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's let Xiaobian take you to learn "CDB and PDB creation, connection, start and close methods"!
I. Basic management of CDB and PDB
Basic concepts:
Multitenant Environment: Multitenant Environment
CDB: Database Container
PDB (Pluggable Database): Pluggable Database
II. Creation 2.1 Creation of CDB
PDBs are contained in CDB, so to create PDBs you must first create CDB. There can be multiple CDB on a machine. After Oracle software installation is complete, CDB can be created
Start DBCA
C:\app\oracle\product\12.1.0\dbhome_1\BIN\dbca.bat)
2.2 Create PDB
C:\app\oracle\product\12.1.0\dbhome_1\BIN\dbca.bat
III. Connection 3.1 Connection CDB
Sqlplus default connection CDB
sqlplus sys/oracle as sysdba
3.2 Connect PDB
pdb can be accessed via the alter session container in CDB
alter session set container=pdb1
You can also log in directly via tns (see below)
sqlplus sys/oracle@pdb1 as sysdba
where tnsnames.ora added
PDB1 = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = pdb1) ) 4.1 Startup shutdown CDBSQL> show con_nameCON_NAME--------------CDB$ROOTSQL> shutdown immediate The database has been shut down. The database has been unloaded. The ORACLE routine has been closed. SQL> startupORACLE routine started. Total System Global Area 5044088832 bytesFixed Size 2413072 bytesVariable Size 1040190960 bytesDatabase Buffers 3992977408 bytesRedo Buffers 8507392 bytes Database loaded Database is open. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs;CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ----------4122484437 PDB$SEED READ ONLY3387525155 PDB1 MOUNTED3946119498 PDB2 MOUNTEDSQL>
From the above operation, you can see that when the database is started, all PDBs are in the state of Mounted.
4.2 Start Close PDB
Pdb management can be carried out in cdb can also be carried out in pdb, if cdb, PLUGGABLE keyword is required, if pdb directly and ordinary database
SQL> show con_nameCON_NAME------------------------------CDB$ROOTSQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ----------4122484437 PDB$SEED READ ONLY3387525155 PDB1 MOUNTED3946119498 PDB2 MOUNTEDSQL> alter pluggable database pdb1 open; Pluggable database changed. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ----------4122484437 PDB$SEED READ ONLY3387525155 PDB1 READ WRITE3946119498 PDB2 MOUNTEDSQL> alter pluggable database pdb2 open; Pluggable database changed. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ----------4122484437 PDB$SEED READ ONLY3387525155 PDB1 READ WRITE3946119498 PDB2 READ WRITESQL> alter pluggable database pdb1 close; Pluggable database changed. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ----------4122484437 PDB$SEED READ ONLY3387525155 PDB1 MOUNTED3946119498 PDB2 READ WRITESQL> alter pluggable database pdb2 close; Pluggable database changed. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ----------4122484437 PDB$SEED READ ONLY3387525155 PDB1 MOUNTED3946119498 PDB2 MOUNTEDSQL> alter pluggable database all open; Pluggable database changed. SQL> alter pluggable database all close; Pluggable database changed. SQL> alter session set container=pdb1 ; session changed. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ----------3387525155 PDB1 MOUNTEDSQL> startup Pluggable database is open. SQL> shutdown Pluggable database is closed. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE---------- ---------- ------------------------------ ----------3387525155 PDB1 MOUNTEDSQL>4.3 Autostart all PDBs
From the above operation, it can be seen that all PDBs are in the state of Mounted when the database is started. In actual application, it can be considered to add the following triggers to make all PDBs in the open state.
create or replace trigger sys.after_startup after startup on databasebeginexecute immediate 'alter pluggable database all open ' ;end after_startup ;
verification process
SQL> create or replace trigger sys.after_startup after startup on databasebeginexecute immediately 'alter pluggable database all open'; end after_startup ;/trigger created SQL> shutdown Database is closed. The database has been unloaded. The ORACLE routine has been closed. SQL> startupORACLE routine started. Total System Global Area 5044088832 bytesFixed Size 2413072 bytesVariable Size 1040190960 bytesDatabase Buffers 3992977408 bytesRedo Buffers 8507392 bytes Database loaded Database is open. SQL> select con_id,dbid,NAME,OPEN_MODE from v$pdbs; CON_ID DBID NAME OPEN_MODE------------------------------------------4122484437 PDB$READ ONLY3387525155 PDB1 READ WRITE3946119498 PDB2 READ WRITESQL> V. Common SQL--View ORACLE 12C version select * from v$version;--View container name and IDshow con_name ;--View status select name ,open_mode from v$pdbs ;--Switch containeralter session set container=pdb1 To this point, I believe you have a deeper understanding of "CDB and PDB creation, connection, startup and shutdown methods", you may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!
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.