Oracle 12C pluggable database自啟動

kisslfcr發表於2016-08-17
實驗環境建立了兩個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

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29135257/viewspace-2123591/,如需轉載,請註明出處,否則將追究法律責任。

相關文章