19c physical standby cdb中只针对某一个pdb进行灾备

发布时间 2023-04-24 15:12:16作者: 蚌壳里夜有多长

Parameter enabled_pdbs_on_standby and STANDBYS Option With Data Guard Subset Standby (Doc ID 2417018.1)

create pluggable databases ... STANDBYS option.

   This parameter determines whether to physically create the datafile in the standby database.
   The new PDB is included in one or more standby CDBs. default value is "ALL", include the new PDB in all standby CDBs.
   STANDBYS=NONE to exclude the new PDB from all standby CDBs.

・Parameter enabled_pdbs_on_standby.

   This parameter determines whether to apply the redo log to the PDB of the standby database.
   Specifies which PDB to replicate on standby database. default value is "*", replicate all PDBs.
   enabled_pdbs_on_standby is meaningful only on standby databases.
   It settings are ignored on a primary database.

 

   When creating a PDB in an Oracle Multitenant environment that includes a Data Guard physical standby database,
   create pluggable databases ... STANDBYS option and Parameter enabled_pdbs_on_standby take precedence as follows.

   (*1) : Whether the datafile is physically created in the standby database.

   (*2) : Whether the redo log is applied the PDB on the standby database ( v$pdbs.recovery_status ).

 

 Case    
 Parameter : Value

 Datafile in Standby (*1)     Recovery Status in Standby (*2)
 1    
 STANDBYS : ALL
 enabled_pdbs_on_standby : Included in PDB-list

 Created     Enable
 2    
 STANDBYS : ALL
 enabled_pdbs_on_standby : Not included in PDB-list

 Not Created     Disable
 3    
 STANDBYS : NONE
 enabled_pdbs_on_standby : Included in PDB-list

 Created     Enable
 4    
 STANDBYS : NONE
 enabled_pdbs_on_standby : Not included in PDB-list

 Not Created     Disable
 5    
 STANDBYS : ALL
 enabled_pdbs_on_standby : *

 Created     Enable
 6    
 STANDBYS : NONE
 enabled_pdbs_on_standby : *

 Not Created     Disable
 

Cases 1 to 4 are explained in the following procedure. (Case1 : PDB1, Case2 : PDB2, Case3 : PDB3, Case4 : PDB4).

1. On Standby Database, Parameter enabled_pdbs_on_standby includes PDB1 and PDB3 (not includes PDB2 and PDB4).

SQL> alter system set enabled_pdbs_on_standby='PDB1','PDB3' scope=both;

System altered.

SQL> show parameter enabled_pdbs_on_standby

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
enabled_pdbs_on_standby string PDB1, PDB3

-- Check managed recovery mode

SQL> select distinct recovery_mode from v$archive_dest_status;

RECOVERY_MODE
-----------------------
MANAGED REAL TIME APPLY

 

2. On Primary Database, Creating the PDBs

-- PDB1 and PDB2 is specifie STANDBYS=ALL, PDB3 and PDB4 is specifie STANDBYS=NONE.

SQL> create pluggable database PDB1 admin user pdbadmin identified by "<password>" file_name_convert=('/u01/app/oracle/oradata/dg12201/pdbseed','/u01/app/oracle/oradata/dg12201/pdb1') STANDBYS=ALL;

Pluggable database created.

SQL> create pluggable database PDB2 admin user pdbadmin identified by "<password>" file_name_convert=('/u01/app/oracle/oradata/dg12201/pdbseed','/u01/app/oracle/oradata/dg12201/pdb2') STANDBYS=ALL;

Pluggable database created.

SQL> create pluggable database PDB3 admin user pdbadmin identified by "<password>" file_name_convert=('/u01/app/oracle/oradata/dg12201/pdbseed','/u01/app/oracle/oradata/dg12201/pdb3') STANDBYS=NONE;

Pluggable database created.

SQL> create pluggable database PDB4 admin user pdbadmin identified by "<password>" file_name_convert=('/u01/app/oracle/oradata/dg12201/pdbseed','/u01/app/oracle/oradata/dg12201/pdb4') STANDBYS=NONE;

Pluggable database created.

-- Open all PDBs

SQL> alter pluggable database all open;

Pluggable database altered.

-- Check the open_mode and recovery_status of all PDBs.

SQL> select con_id, name, open_mode, recovery_status from v$pdbs order by con_id, name;

CON_ID NAME OPEN_MODE RECOVERY
---------- ------------------------------------------- ---------- --------
2 PDB$SEED READ ONLY ENABLED
3 PDB1 READ WRITE ENABLED
4 PDB2 READ WRITE ENABLED
5 PDB3 READ WRITE ENABLED
6 PDB4 READ WRITE ENABLED

 

3. On Standby Database,

-- Redo logs are not applied to PDB2, PDB4 (v$pdbs.recovery_status = DISABLED).

SQL> select con_id, name, open_mode, recovery_status from v$pdbs order by con_id;

CON_ID NAME OPEN_MODE RECOVERY
---------- ------------------------------------------- ---------- --------
2 PDB$SEED READ ONLY ENABLED
3 PDB1 MOUNTED ENABLED
4 PDB2 MOUNTED DISABLED
5 PDB3 MOUNTED ENABLED
6 PDB4 MOUNTED DISABLED

-- Datafiles that are displayed as "UNNAMEDXXXXX" are not physically created in the standby database.

SQL> select con_id, name from v$datafile order by con_id;

CON_ID NAME
---------- ------------------------------------------------------------
1 /u01/app/oracle/oradata/dg12201/system01.dbf
1 /u01/app/oracle/oradata/dg12201/sysaux01.dbf
1 /u01/app/oracle/oradata/dg12201/undotbs01.dbf
1 /u01/app/oracle/oradata/dg12201/users01.dbf
2 /u01/app/oracle/oradata/dg12201/pdbseed/system01.dbf
2 /u01/app/oracle/oradata/dg12201/pdbseed/sysaux01.dbf
2 /u01/app/oracle/oradata/dg12201/pdbseed/undotbs01.dbf
3 /u01/app/oracle/oradata/dg12201/pdb1/sysaux01.dbf
3 /u01/app/oracle/oradata/dg12201/pdb1/system01.dbf
3 /u01/app/oracle/oradata/dg12201/pdb1/undotbs01.dbf
4 /u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/UNNAMED00089
4 /u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/UNNAMED00090
4 /u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/UNNAMED00091
5 /u01/app/oracle/oradata/dg12201/pdb3/system01.dbf
5 /u01/app/oracle/oradata/dg12201/pdb3/sysaux01.dbf
5 /u01/app/oracle/oradata/dg12201/pdb3/undotbs01.dbf
6 /u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/UNNAMED00095
6 /u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/UNNAMED00096
6 /u01/app/oracle/product/12.2.0.1/dbhome_1/dbs/UNNAMED00097

 

STANDBYS option and Parameter enabled_pdbs_on_standby is effective when creating a new PDB after Data Guard configuration.
It does not affect the existing PDB before Data Guard configuration. Disabling PDB recovery after Data Guard configuration is as follows.

- On Standby Database,

-- Cancel managed recovery

SQL> recover managed standby database cancel;
Media recovery complete.
SQL>

-- Set container to target PDB

SQL> alter session set container=PDB1;

Session altered.

-- Change recovery_status to disable.

SQL> alter pluggable database PDB1 disable recovery;

Pluggable database altered.

SQL> select con_id, name, open_mode, recovery_status from v$pdbs order by con_id;

CON_ID NAME OPEN_MODE RECOVERY
---------- ------------------------------------------- ---------- --------
3 PDB1 MOUNTED DISABLED

 

PDB Enabled/Disabled only applies to the initial creation of the PDB.
At some point in the future PDB that had recovery enabled could have its recovery disabled and vice versa regardless of the settings of the parameter.

PDBs coming from external sources (plugins, remote clones) you still need to provide the files to the standby in some manner.
These parameters/clauses have no impact in regard to populating the files at the standby for these cases.