[20181018]12c Pluggable Database save state.txt

lfree發表於2018-10-19

[20181018]12c Pluggable Database save state.txt

--//我最早使用版本12.1.0.1不支援這個特性,每次open cdb後,都要手工執行:
# ALTER PLUGGABLE DATABASE ALL OPEN;
--//現在使用的版本12.2.0.1支援這個特性,簡單測試看看:

1.環境:
SCOTT@test01p> @ ver1
PORT_STRING                    VERSION        BANNER                                                                               CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0           12.2.0.1.0     Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production              0

SYS@test> startup
ORACLE instance started.
Total System Global Area  805306368 bytes
Fixed Size                  8924064 bytes
Variable Size             297796704 bytes
Database Buffers          490733568 bytes
Redo Buffers                7852032 bytes
Database mounted.
Database opened.

SYS@test> show pdbs
CON_ID CON_NAME OPEN MODE  RESTRICTED
------ -------- ---------- ----------
     2 PDB$SEED READ ONLY  NO
     3 TEST01P  MOUNTED


SYS@test> alter pluggable database test01p SAVE STATE;
Pluggable database altered.

SYS@test> SELECT * FROM DBA_PDB_SAVED_STATES;
no rows selected

--//沒有開啟pdb,沒用.
--//# ALTER PLUGGABLE DATABASE ALL OPEN;

SYS@test> show pdbs
CON_ID CON_NAME OPEN MODE  RESTRICTED
------ -------- ---------- ----------
     2 PDB$SEED READ ONLY  NO
     3 TEST01P  READ WRITE NO


2.現在可以儲存當前狀態,下次啟動cdb時自動啟動:

SYS@test> alter pluggable database test01p SAVE STATE;
Pluggable database altered.

--//如果rac環境,加入INSTANCES=ALL;例子:
--// ALTER PLUGGABLE DATABASE test03p SAVE STATE INSTANCES=ALL;

3.檢視DBA_PDB_SAVED_STATES檢視記錄了save states:

SYS@test> SELECT * FROM DBA_PDB_SAVED_STATES;
    CON_ID CON_NAME             INSTANCE_NAME           CON_UID GUID                             STATE                RES
---------- -------------------- -------------------- ---------- -------------------------------- -------------------- ---
         3 TEST01P              test                 2923790755 C287357CE3D5470AA01668B945336F73 OPEN                 NO

--//關閉資料庫,測試看看:
SYS@test> shutdown immediate ;
Database closed.
Database dismounted.
ORACLE instance shut down.

SYS@test> startup
ORACLE instance started.
Total System Global Area  805306368 bytes
Fixed Size                  8924064 bytes
Variable Size             297796704 bytes
Database Buffers          490733568 bytes
Redo Buffers                7852032 bytes
Database mounted.
Database opened.

SYS@test> show pdbs
CON_ID CON_NAME OPEN MODE  RESTRICTED
------ -------- ---------- ----------
     2 PDB$SEED READ ONLY  NO
     3 TEST01P  READ WRITE NO

--//當然你可以移除:
SYS@test> SELECT * FROM DBA_PDB_SAVED_STATES;
    CON_ID CON_NAME             INSTANCE_NAME           CON_UID GUID                             STATE                RES
---------- -------------------- -------------------- ---------- -------------------------------- -------------------- ---
         3 TEST01P              test                 2923790755 C287357CE3D5470AA01668B945336F73 OPEN                 NO

SYS@test> alter pluggable database test01p discard state;
Pluggable database altered.

SYS@test> SELECT * FROM DBA_PDB_SAVED_STATES;
no rows selected

--//也可以執行如下儲存全部PDBs的SAVE STATE:
--//alter pluggable database all save state;
--//After that all PDBs will stay UP when the container started.







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

相關文章