当前位置:Gxlcms > 数据库问题 > Oracle 12C pluggable database自启动

Oracle 12C pluggable database自启动

时间:2021-07-01 10:21:17 帮助过:12人阅读

实验环境创建了两个PDB,本实验实现在开启数据库时,实现pluggable database PDB2自启动:


原始环境:


SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.


Total System Global Area  943718400 bytes
Fixed Size                  2931136 bytes
Variable Size             650118720 bytes
Database Buffers          285212672 bytes
Redo Buffers                5455872 bytes
Database mounted.
Database opened.
SQL> select name,open_mode from v$pdbs;


NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDBYCR                         MOUNTED
PDB2                           MOUNTED


SQL> 


创建trigger:


SQL> CREATE TRIGGER open_pdb_pdb2
  2     AFTER STARTUP
  3     ON DATABASE
  4  BEGIN
  5     EXECUTE IMMEDIATE ‘alter pluggable database pdb2 open‘;
  6  END open_all_pdbs;
  7  /


Trigger created.


SQL> shu immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.


Total System Global Area  943718400 bytes
Fixed Size                  2931136 bytes
Variable Size             650118720 bytes
Database Buffers          285212672 bytes
Redo Buffers                5455872 bytes
Database mounted.
Database opened.
SQL> select name,open_mode from v$pdbs;


NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDBYCR                         MOUNTED
PDB2                           READ WRITE


已实现pdb2的自启动,可以通过修改trigger脚本中的sql语句实现启动不同的pdb或者实现所有pdb的自启动,脚本如下:
CREATE TRIGGER open_pdb_pdb2
   AFTER STARTUP
   ON DATABASE
BEGIN
   EXECUTE IMMEDIATE ‘alter pluggable database pdb2 open‘;
END open_all_pdbs;
/


观察alert日志中有如下消息:
Opening pdb PDB$SEED (2) with no Resource Manager plan active
alter pluggable database pdb2 open
Database Characterset for PDB2 is WE8MSWIN1252
Due to limited space in shared pool (need 6094848 bytes, have 3981120 bytes), limiting Resource Manager entities from 2048 to 32
Opening pdb PDB2 (4) with no Resource Manager plan active
Pluggable database PDB2 opened read write
Completed: alter pluggable database pdb2 open
Starting background process CJQ0
Completed: ALTER DATABASE OPEN

Oracle 12C pluggable database自启动

标签:write   manage   var   select   alert   nbsp   har   实验环境   let   

人气教程排行