|
默认情况下12c的pdb不会随着cdb启动而自动open, 在某些时候,数据库因故重启后,pdb无法正常访问。绝大多数情况下,我们还是希望pdb随着cdb一起启动(open)的。 因此,我们需要设置pdb随cdb一起启动。
对于Oracle 12.1.0.2 之后, Oracle推荐使用save state属性,也就是说,保存上次的状态,pdb关之前是open/close状态,cdb重启后pdb会保留这个状态。
例子:
[oracle@sztech ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Mon Sep 19 16:58:13 2022
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup;
ORACLE instance started.
Total System Global Area 1241510080 bytes
Fixed Size 9134272 bytes
Variable Size 452984832 bytes
Database Buffers 771751936 bytes
Redo Buffers 7639040 bytes
Database mounted.
Database opened.
查看当前pdb状态
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
5 ORCL MOUNTED
手动启动pdb实例orcl
SQL> alter pluggable database orcl open;
Pluggable database altered.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
5 ORCL READ WRITE NO
启用保存所有pdb状态, 建议加上instances=all,否则命令只对当前实例下的PDB有效。
ALTER PLUGGABLE DATABASE all save STATE;
启用保存某个pdb状态
SQL> ALTER PLUGGABLE DATABASE orcl save STATE;
Pluggable database altered.
状态保留在
dba_pdb_saved_states
我们关闭cdb,在启动cdb验证一下
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.
Total System Global Area 1241510080 bytes
Fixed Size 9134272 bytes
Variable Size 452984832 bytes
Database Buffers 771751936 bytes
Redo Buffers 7639040 bytes
Database mounted.
Database opened.
SQL> show pdbs
CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
5 ORCL READ WRITE NO
SQL>
|
|