ITPub博客

首页 > 数据库 > Oracle > [20181018]12c Pluggable Database save state.txt

[20181018]12c Pluggable Database save state.txt

原创 Oracle 作者:lfree 时间:2018-10-19 07:53:33 0 删除 编辑

[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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论
熟悉oracle相关技术,擅长sql优化,rman备份与恢复,熟悉linux shell编程。

注册时间:2008-01-03

  • 博文量
    2625
  • 访问量
    6388639