O Oracle Database 18c introduz o conceito de frota de CDB, que é uma coleção de diferentes CDBs que podem ser gerenciados como um CDB lógico.
Atualmente esse recurso está restrito ao Enterprise Edition em Engineered Systems, como Exadata, e Enterprise Edition no Oracle Database Cloud Services.
Há duas funções possíveis em uma frota: LEAD_CDB e MEMBER_CDB. O LEAD_CDB pode ser definido configurando a propriedade LEAD_CDB como “TRUE”. Todos os outros CDBs da frota atuariam como MEMBER_CDBs.
No exemplo abaixo, existem dois CDBs:
cdbvert011: Container database com os pluggables databases PDBDP, PDBDW, PDBMV, PDBSWD e PDBADDADOS. Este será o líder da frota.
cdbhor011: Container database com o pluggable database PDBWEBDW1.
Pluggables Databases 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
Pluggable Database 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 o CDBVERT011 como CDB principal:
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 CDB lead:
SQL> grant sysoper to system CONTAINER=ALL; Grant succeeded.
Crie o database link 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 do 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 são sincronizados 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.
Desabilitando o CDB Lead:
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.
Desabilitando o CDB Member:
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
Administering a CDB Fleet. Available at https://docs.oracle.com/en/database/oracle/oracle-database/18/multi/administering-cdb-fleet.html#GUID-0AA7FC65-F350-473B-96D2-976313514069