domingo, 14 de setembro de 2014

12c - Preserving or Discarding the Open Mode of PDBs When the CDB Restarts

Antes do 12.1.0.2, quando um CDB era inicializado, todos PDBs permaneciam em modo mount, exceto o PDB$SEED, que deve ficar em Read only.

Para resolver isso, era necessário criar uma trigger para abrir os PDBs.

CREATE OR REPLACE TRIGGER ABRIR_TODOS_PDBS
AFTER STARTUP ON DATABASE
BEGIN
EXECUTE IMMEDIATE 'ALTER PLUGGABLE DATABASE ALL OPEN';
END;
/


No patchset 12.1.0.2, foi introduzida a capacidade de preservar o estado de inicialização dos PDBs.

[oracle@oracle01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Mon Sep 8 16:26:37 2014

Copyright (c) 1982, 2014, Oracle. All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> SELECT name, open_mode FROM v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1                           READ WRITE
PDB2                           MOUNTED
PDB3                           MOUNTED

Agora vamos salvar o estado atual:

ALTER PLUGGABLE DATABASE pdb1 SAVE STATE;


Verificando os estados salvos:

[oracle@oracle01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Mon Sep 8 16:32:37 2014

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> SELECT con_name, instance_name, state FROM dba_pdb_saved_states;

CON_NAME             INSTANCE_NAME        STATE
-------------------- -------------------- --------------
PDB1                 cdb1                 OPEN


Restartando o CDB:

[oracle@oracle01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Mon Sep 8 16:36:35 2014

Copyright (c) 1982, 2014, Oracle. All rights reserved.


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup
ORACLE instance started.

Total System Global Area 626327552 bytes
Fixed Size 2291472 bytes
Variable Size 276826352 bytes
Database Buffers 339738624 bytes
Redo Buffers 7471104 bytes
Database mounted.
Database opened.

SQL> SELECT name, open_mode FROM v$pdbs;

NAME                           OPEN_MODE
------------------------------ ----------
PDB$SEED                       READ ONLY
PDB1 
                          READ WRITE
PDB2 
                          MOUNTED
PDB3 
                          MOUNTED

Para descartar o estado atual:

ALTER PLUGGABLE DATABASE pdb1 DISCARD STATE;

[oracle@oracle01 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Mon Sep 8 16:38:37 2014

Copyright (c) 1982, 2014, Oracle. All rights reserved.

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic Storage Management, OLAP, Advanced Analytics
and Real Application Testing options

SQL> SELECT con_name, instance_name, state FROM dba_pdb_saved_states;

no rows selected


Referências:



Abraço,

Alex Zaballa.

0 comentários: