Oracle
 sql >> Base de Dados >  >> RDS >> Oracle

Gerenciando a Frota CDB no Oracle Database 18c


O Oracle Database 18c apresenta o conceito de frota de CDB, que é uma coleção de diferentes CDBs que podem ser gerenciados como um CDB lógico.

No momento, esse recurso está restrito à Enterprise Edition em sistemas projetados, como Exadata e Enterprise Edition em Oracle Database Cloud Services.

Existem duas funções possíveis em uma frota:LEAD_CDB e MEMBER_CDB . O LEAD_CDB pode ser definido definindo a propriedade LEAD_CDB como “TRUE”. Todos os outros CDBs da frota atuariam como MEMBER_CDBs.

No exemplo abaixo temos dois CDBs e PDBs nele.

cdbvert011 :Banco de dados container com bancos de dados plugáveis ​​PDBDP, PDBDW, PDBMV, PDBSWD e PDBADDADOS. Este será o líder da frota.
cdbhor011 :Banco de dados de contêiner com banco de dados plugável PDBWEBDW1.



Bancos de dados plugáveis ​​no Container Database cdbvert011 :

$ export ORACLE_SID=cdbvert011
$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Wed May 27 08:36:16 2020
Version 18.2.0.0.0

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

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.2.0.0.0

sql> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBDP READ WRITE NO
4 PDBDW READ WRITE NO
5 PDBMV READ WRITE NO
6 PDBSWD READ WRITE NO
7 PDBADDADOS READ WRITE NO




Banco de dados conectável no Container Database cdbhor011:

$ export ORACLE_SID=cdbhor011
$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Wed May 27 08:36:16 2020
Version 18.2.0.0.0

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

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.2.0.0.0

sql> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBWEBDW1 READ WRITE NO





Configure CDBVERT011 como LEAD CDB:

sql> select property_value from database_properties where property_name='LEAD_CDB';

no rows selected

sql> alter database set lead_cdb=TRUE;

Database altered.

sql> select property_value from database_properties where property_name='LEAD_CDB';

PROPERTY_VALUE
------------------------------
TRUE




Conceda os privilégios apropriados ao usuário comum no lead do CDB:

sql> grant sysoper to system CONTAINER=ALL;

Grant succeeded.




Crie o link do banco de dados e defina como membro da frota:

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.2.0.0.0

sql> select property_value from database_properties where property_name='LEAD_CDB_URI';

no rows selected

sql> create database link dblink_lead connect to system identified by password using 'CDBVERT011';

Database link created.

sql> alter database set LEAD_CDB_URI='dblink:dblink_lead';

Database altered.

sql> select property_value from database_properties where property_name='LEAD_CDB_URI';

PROPERTY_VALUE
--------------------------------------------------------------------------------
dblink:dblink_lead





Conecte-se no CDBVERT011 e liste todos os PDBs. O valor STUB na coluna STATUS define o CDB e seus PDBs como membros da frota. Depois de configurar a frota de CDB, as informações do PDB dos vários membros do CDB, incluindo o membro do CDB, são sincronizadas com o CDB principal.

$ export ORACLE_SID=cdbvert011
$ sqlplus / as sysdba

SQL*Plus: Release 18.0.0.0.0 - Production on Wed May 27 08:36:16 2020
Version 18.2.0.0.0

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

Connected to:
Oracle Database 18c Enterprise Edition Release 18.0.0.0.0 - Production
Version 18.2.0.0.0

sql> show pdbs;

CON_ID CON_NAME OPEN MODE RESTRICTED
---------- ------------------------------ ---------- ----------
2 PDB$SEED READ ONLY NO
3 PDBDP READ WRITE NO
4 PDBDW READ WRITE NO
5 PDBMV READ WRITE NO
6 PDBSWD READ WRITE NO
7 PDBADDADOS READ WRITE NO
9 PDBWEBDW1 MOUNTED

sql> select pdb_id, pdb_name, status, is_proxy_pdb from dba_pdbs;

PDB_ID PDB_NAME STATUS IS_PROXY_
------- -------- ------ ----------
3 PDBDP NORMAL NO
2 PDB$SEED NORMAL NO
4 PDBDW NORMAL NO
5 PDBMV NORMAL NO
6 PDBSWD NORMAL NO
7 PDBADDADOS NORMAL NO
8 CDBHOR011 STUB YES
9 PDBWEBDW1 STUB YES

8 rows selected.


Desabilite o Lead CDB:

sql> ALTER DATABASE SET LEAD_CDB = false;
Database altered. 

sql> select pdb_id, pdb_name, status, is_proxy_pdb from dba_pdbs;

PDB_ID PDB_NAME STATUS IS_PROXY_
------- -------- ------ ----------
3 PDBDP NORMAL NO
2 PDB$SEED NORMAL NO
4 PDBDW NORMAL NO
5 PDBMV NORMAL NO
6 PDBSWD NORMAL NO
7 PDBADDADOS NORMAL NO

6 rows selected.


Desabilite o Membro CDB:

sql> alter database set lead_cdb_uri='';

Database altered.

sql> select pdb_id, pdb_name, status, is_proxy_pdb from dba_pdbs;

PDB_ID PDB_NAME STATUS IS_PROXY_
------- -------- ------ ----------
3 PDBWEBDW1 NORMAL NO
2 PDB$SEED NORMAL NO

sql> drop database link dblink_lead;

Database link dropped.




Referências

Administrando uma Frota CDB. Disponível em https://docs.oracle.com/en/database/oracle/oracle-database/18/multi/administering-cdb-fleet.html#GUID-0AA7FC65-F350-473B-96D2-976313514069