Create Standby Skip Pluggable Database
Goal
Let us assume there is a need to create a standby database that excludes some pluggable databases of the primary, e.g. the PDBs must not be restored during standby database creation, and the standby will ignore any redo related to them.It is known that the DUPLICATE command does not allow that: Backup and Recovery Reference
Note: RMAN does not support partial PDB duplication. Therefore, you cannot use theThis blog post describes how the desired can be accomplished.SKIP TABLESPACE,TABLESPACE,SKIP PLUGGABLE DATABASE, andPLUGGABLE DATABASEoptions when creating a standby database.
Idea
- Skip the tablespaces of the pluggable databases that should not be protected by Data Guard:
SKIP [FOREVER] TABLESPACEclause of the RESTORE command can be used - Drop the excluded data files on the standby
- Set ENABLED_PDBS_ON_STANDBY to apply redo only to certain PDBs
Setup
Primary and Standby
- db_name:
orcl - Oracle version:
19.10
Primary
- Hostname:
servera - db_unique_name:
orcla - instance_name:
orcla1 - Pluggable Databases:
PDB1-3
Standby
- Hostname:
serverb - db_unique_name:
orclb - instance_name:
orclb1 - Pluggable Database:
PDB1
Creating Primary
The primary database was created by the following DBCA command:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | dbca -silent -createDatabase \ -responseFile NO_VALUE \ -gdbName orcl \ -sid orcla1 \ -templateName New_Database.dbt \ -createAsContainerDatabase true \ -numberOfPDBs 3 \ -pdbName pdb \ -pdbAdminPassword Oracle123 \ -sysPassword Oracle123 \ -systemPassword Oracle123 \ -recoveryAreaDestination +FRA \ -recoveryAreaSize 10000 \ -storageType ASM \ -datafileDestination +DATA \ -enableArchive true \ -memoryMgmtType AUTO_SGA \ -dbOptions "APEX:false,DV:false,CWMLITE:false,IMEDIA:false,JSERVER:false,OMS:false,ORACLE_TEXT:false,SAMPLE_SCHEMA:false,SPATIAL:false" \ -initParams "db_unique_name=orcla,dg_broker_start=true" |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | [oracle@servera ~]$ dbca -silent -createDatabase \> -responseFile NO_VALUE \> -gdbName orcl \> -sid orcla1 \> -templateName New_Database.dbt \> -createAsContainerDatabase true \> -numberOfPDBs 3 \> -pdbName pdb \> -pdbAdminPassword Oracle123 \> -sysPassword Oracle123 \> -systemPassword Oracle123 \> -recoveryAreaDestination +FRA \> -recoveryAreaSize 10000 \> -storageType ASM \> -datafileDestination +DATA \> -enableArchive true \> -memoryMgmtType AUTO_SGA \> -dbOptions "APEX:false,DV:false,CWMLITE:false,IMEDIA:false,JSERVER:false,OMS:false,ORACLE_TEXT:false,SAMPLE_SCHEMA:false,SPATIAL:false" \> -initParams "db_unique_name=orcla,dg_broker_start=true"[WARNING] [DBT-06801] Specified Fast Recovery Area size (10,000 MB) is less than the recommended value. CAUSE: Fast Recovery Area size should at least be three times the database size (8,897 MB). ACTION: Specify Fast Recovery Area Size to be at least three times the database size.[WARNING] [DBT-06801] Specified Fast Recovery Area size (10,000 MB) is less than the recommended value. CAUSE: Fast Recovery Area size should at least be three times the database size (4,502 MB). ACTION: Specify Fast Recovery Area Size to be at least three times the database size.Prepare for db operation6% completeRegistering database with Oracle Restart10% completeCreating and starting Oracle instance12% complete16% completeCreating database files17% complete23% completeCreating data dictionary views25% complete29% complete32% complete34% complete36% complete38% complete42% completeCreating cluster database views43% complete55% completeCompleting Database Creation59% complete61% completeCreating Pluggable Databases65% complete69% complete73% complete81% completeExecuting Post Configuration Actions100% completeDatabase creation complete. For details check the logfiles at: /u01/app/oracle/cfgtoollogs/dbca/orcla.Database Information:Global Database Name:orclaSystem Identifier(SID):orcla1Look at the log file "/u01/app/oracle/cfgtoollogs/dbca/orcla/orcla.log" for further details.[oracle@servera ~]$ |
PDB1-3. PDB1 should be replicated as usual. Both PDB2 and PDB3 should not be available on standby.Creating Standby
Adding Static Service to Listener
I edited/u01/app/19.3.0/grid/network/admin/listener.ora and added a static registration for my standby instance:1 2 3 4 5 6 7 8 | SID_LIST_LISTENER= (SID_LIST= (SID_DESC= (GLOBAL_DBNAME=orclb) (SID_NAME=orclb1) (ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1) ) ) |
Copying password file
1 2 3 | [oracle@serverb ~]$ scp servera:$ORACLE_HOME/dbs/orapworcla1 $ORACLE_HOME/dbs/orapworclb1Warning: Permanently added 'servera' (ECDSA) to the list of known hosts.orapworcla1 100% 2048 860.9KB/s 00:00 |
Bootstrap init.ora
1 2 3 4 5 6 7 8 | db_name=orcldb_unique_name=orclbinstance_name=orclb1enable_pluggable_database=truedb_recovery_file_dest=+FRAdb_recovery_file_dest_size=10Gdg_broker_start=trueenabled_pdbs_on_standby=pdb1 |
PDB1 will be enabled on the standby database.Starting Standby Instance
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [oracle@serverb ~]$ sqlplus / as sysdbaSQL*Plus: Release 19.0.0.0.0 - Production on Fri Feb 26 15:00:55 2021Version 19.10.0.0.0Copyright (c) 1982, 2020, Oracle. All rights reserved.Connected to an idle instance.SQL> startup nomount pfile=/tmp/init.oraORACLE instance started.Total System Global Area 457176832 bytesFixed Size 9135872 bytesVariable Size 306184192 bytesDatabase Buffers 134217728 bytesRedo Buffers 7639040 bytesSQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - ProductionVersion 19.10.0.0.0 |
Restoring Standby Control File and Mounting Standby Database
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | [oracle@serverb ~]$ rmanRecovery Manager: Release 19.0.0.0.0 - Production on Fri Feb 26 15:01:04 2021Version 19.10.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.RMAN> connect target sys/Oracle123@servera/orclaconnected to target database: ORCL (DBID=1593309578)RMAN> connect auxiliary sys/Oracle123@serverb/orclbconnected to auxiliary database: ORCL (not mounted)RMAN> run{ sql clone 'create spfile from memory'; shutdown clone immediate; startup clone nomount; restore clone from service 'servera/orcla' standby controlfile;}2> 3> 4> 5> 6> 7>using target database control file instead of recovery catalogsql statement: create spfile from memoryOracle instance shut downconnected to auxiliary database (not started)Oracle instance startedTotal System Global Area 457176832 bytesFixed Size 9135872 bytesVariable Size 306184192 bytesDatabase Buffers 134217728 bytesRedo Buffers 7639040 bytesStarting restore at 26.02.2021 15:02:27allocated channel: ORA_AUX_DISK_1channel ORA_AUX_DISK_1: SID=76 device type=DISKchannel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: restoring control filechannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02output file name=+FRA/ORCLB/CONTROLFILE/current.256.1065538951Finished restore at 26.02.2021 15:02:31RMAN>RMAN> run{ sql clone 'alter database mount standby database';}2> 3> 4>sql statement: alter database mount standby databaseRMAN> |
Restoring Standby Database
Here are the primary data files:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | alter session set "_exclude_seed_cdb_view"=false;select p.pdb_name pdb_name, f.file_id, f.file_name from cdb_data_files f, dba_pdbs p where p.pdb_id(+) = f.con_id order by f.file_id, p.pdb_id;PDB_NAME FILE_ID FILE_NAME---------- ---------- -------------------------------------------------------------------------------- 1 +DATA/ORCLA/DATAFILE/system.260.1065528853PDB$SEED 2 +DATA/ORCLA/BC3D34CE047E62F0E0530600000AF770/DATAFILE/system.261.1065528859 3 +DATA/ORCLA/DATAFILE/sysaux.262.1065528863PDB$SEED 4 +DATA/ORCLA/BC3D34CE047E62F0E0530600000AF770/DATAFILE/sysaux.263.1065528865 5 +DATA/ORCLA/DATAFILE/undotbs1.264.1065528867PDB$SEED 6 +DATA/ORCLA/BC3D34CE047E62F0E0530600000AF770/DATAFILE/undotbs1.265.1065528869 7 +DATA/ORCLA/DATAFILE/users.268.1065528883PDB1 8 +DATA/ORCLA/BC3DBECD0A3C07D3E0530600000A8D82/DATAFILE/system.272.1065531169PDB1 9 +DATA/ORCLA/BC3DBECD0A3C07D3E0530600000A8D82/DATAFILE/sysaux.270.1065531169PDB1 10 +DATA/ORCLA/BC3DBECD0A3C07D3E0530600000A8D82/DATAFILE/undotbs1.271.1065531169PDB1 11 +DATA/ORCLA/BC3DBECD0A3C07D3E0530600000A8D82/DATAFILE/users.274.1065531177PDB2 12 +DATA/ORCLA/BC3DBF5BB0310A08E0530600000A91B8/DATAFILE/system.277.1065531179PDB2 13 +DATA/ORCLA/BC3DBF5BB0310A08E0530600000A91B8/DATAFILE/sysaux.275.1065531179PDB2 14 +DATA/ORCLA/BC3DBF5BB0310A08E0530600000A91B8/DATAFILE/undotbs1.276.1065531179PDB2 15 +DATA/ORCLA/BC3DBF5BB0310A08E0530600000A91B8/DATAFILE/users.279.1065531185PDB3 16 +DATA/ORCLA/BC3DBFD5112A0AB0E0530600000AE27E/DATAFILE/system.282.1065531187PDB3 17 +DATA/ORCLA/BC3DBFD5112A0AB0E0530600000AE27E/DATAFILE/sysaux.280.1065531187PDB3 18 +DATA/ORCLA/BC3DBFD5112A0AB0E0530600000AE27E/DATAFILE/undotbs1.281.1065531187PDB3 19 +DATA/ORCLA/BC3DBFD5112A0AB0E0530600000AE27E/DATAFILE/users.284.1065531193 |
PDB2 and PDB3 should not be restored on the standby site, so that I would like to skip data files 12-19.The command to restore the standby database and its output are as follows:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 | run{ set newname for tempfile 1 to '+DATA'; set newname for tempfile 2 to '+DATA'; set newname for tempfile 3 to '+DATA'; set newname for tempfile 4 to '+DATA'; set newname for tempfile 5 to '+DATA'; switch clone tempfile all; set newname for database to '+DATA'; restore from service 'servera/orcla' clone database skip forever tablespace pdb2:sysaux, pdb2:system, pdb2:undotbs1, pdb2:users, pdb3:sysaux, pdb3:system, pdb3:undotbs1, pdb3:users ;}executing command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMEexecuting command: SET NEWNAMErenamed tempfile 1 to +DATA in control filerenamed tempfile 2 to +DATA in control filerenamed tempfile 3 to +DATA in control filerenamed tempfile 4 to +DATA in control filerenamed tempfile 5 to +DATA in control fileexecuting command: SET NEWNAMEStarting restore at 26.02.2021 15:03:50using channel ORA_AUX_DISK_1channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00001 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00002 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00003 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00004 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00005 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00006 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00007 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00008 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00009 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00010 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03channel ORA_AUX_DISK_1: starting datafile backup set restorechannel ORA_AUX_DISK_1: using network backup set from service servera/orclachannel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup setchannel ORA_AUX_DISK_1: restoring datafile 00011 to +DATAchannel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01Finished restore at 26.02.2021 15:04:33RMAN> |
Updating Standby Control File
I reconnect to the standby database and runSWITCH TO COPY commands:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | RMAN>Recovery Manager complete.[oracle@serverb ~]$ rman target sys/Oracle123@serverb/orclbRecovery Manager: Release 19.0.0.0.0 - Production on Fri Feb 26 15:06:55 2021Version 19.10.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.connected to target database: ORCL (DBID=1593309578, not open)RMAN> switch database root to copy;Starting implicit crosscheck backup at 26.02.2021 15:06:59using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=76 device type=DISKCrosschecked 1 objectsFinished implicit crosscheck backup at 26.02.2021 15:06:59Starting implicit crosscheck copy at 26.02.2021 15:06:59using channel ORA_DISK_1Crosschecked 11 objectsFinished implicit crosscheck copy at 26.02.2021 15:07:00searching for all files in the recovery areacataloging files...no files catalogeddatafile 1 switched to datafile copy "+DATA/ORCLB/DATAFILE/system.257.1065539031"datafile 3 switched to datafile copy "+DATA/ORCLB/DATAFILE/sysaux.258.1065539045"datafile 5 switched to datafile copy "+DATA/ORCLB/DATAFILE/undotbs1.259.1065539055"datafile 7 switched to datafile copy "+DATA/ORCLB/DATAFILE/users.260.1065539063"RMAN> switch pluggable database "PDB$SEED", pdb1 to copy;datafile 2 switched to datafile copy "+DATA/ORCLB/BC3D34CE047E62F0E0530600000AF770/DATAFILE/system.261.1065539039"datafile 4 switched to datafile copy "+DATA/ORCLB/BC3D34CE047E62F0E0530600000AF770/DATAFILE/sysaux.262.1065539053"datafile 6 switched to datafile copy "+DATA/ORCLB/BC3D34CE047E62F0E0530600000AF770/DATAFILE/undotbs1.256.1065539059"datafile 8 switched to datafile copy "+DATA/ORCLB/BC3DBECD0A3C07D3E0530600000A8D82/DATAFILE/system.263.1065539063"datafile 9 switched to datafile copy "+DATA/ORCLB/BC3DBECD0A3C07D3E0530600000A8D82/DATAFILE/sysaux.264.1065539067"datafile 10 switched to datafile copy "+DATA/ORCLB/BC3DBECD0A3C07D3E0530600000A8D82/DATAFILE/undotbs1.265.1065539069"datafile 11 switched to datafile copy "+DATA/ORCLB/BC3DBECD0A3C07D3E0530600000A8D82/DATAFILE/users.266.1065539073" |
Dropping Excluded Data Files
I can drop all data files of pluggable databasesPDB2 and PDB3 on standby:1 2 3 4 5 6 7 8 9 10 11 12 13 | SQL> alter session set container=pdb2;Session altered.SQL> alter database datafile 12,13,14,15 offline drop;Database altered.SQL> alter session set container=pdb3;Session altered.SQL> alter database datafile 16,17,18,19 offline drop; |
Creating Data Guard Configuration
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 | [oracle@serverb ~]$ dgmgrlDGMGRL for Linux: Release 19.0.0.0.0 - Production on Fri Feb 26 15:13:12 2021Version 19.10.0.0.0Copyright (c) 1982, 2019, Oracle and/or its affiliates. All rights reserved.Welcome to DGMGRL, type "help" for information.DGMGRL> connect sys/Oracle123@servera/orclaConnected to "orcla"Connected as SYSDBA.DGMGRL>DGMGRL> create configuration orcl as primary database is orcla connect identifier is '//servera/orcla';Configuration "orcl" created with primary database "orcla"DGMGRL> add database orclb as connect identifier is '//serverb/orclb';Database "orclb" addedDGMGRL> enable configuration;Enabled.DGMGRL> show configuration;Configuration - orcl Protection Mode: MaxPerformance Members: orcla - Primary database Warning: ORA-16789: standby redo logs configured incorrectly orclb - Physical standby database Warning: ORA-16809: multiple warnings detected for the memberFast-Start Failover: DisabledConfiguration Status:WARNING (status updated 50 seconds ago)DGMGRL> show database verbose orclb;Database - orclb Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 14 seconds (computed 5 seconds ago) Apply Lag: 14 seconds (computed 5 seconds ago) Average Apply Rate: 3.65 MByte/s Active Apply Rate: 0 Byte/s Maximum Apply Rate: 0 Byte/s Real Time Query: OFF Instance(s): orclb1 Database Warning(s): ORA-16789: standby redo logs configured incorrectly Properties: DGConnectIdentifier = '//serverb/orclb' ObserverConnectIdentifier = '' FastStartFailoverTarget = '' PreferredObserverHosts = '' LogShipping = 'ON' RedoRoutes = '' LogXptMode = 'ASYNC' DelayMins = '0' Binding = 'optional' MaxFailure = '0' ReopenSecs = '300' NetTimeout = '30' RedoCompression = 'DISABLE' PreferredApplyInstance = '' ApplyInstanceTimeout = '0' ApplyLagThreshold = '30' TransportLagThreshold = '30' TransportDisconnectedThreshold = '30' ApplyParallel = 'AUTO' ApplyInstances = '0' StandbyFileManagement = '' ArchiveLagTarget = '0' LogArchiveMaxProcesses = '0' LogArchiveMinSucceedDest = '0' DataGuardSyncLatency = '0' LogArchiveTrace = '0' LogArchiveFormat = '' DbFileNameConvert = '' LogFileNameConvert = '' ArchiveLocation = '' AlternateLocation = '' StandbyArchiveLocation = '' StandbyAlternateLocation = '' InconsistentProperties = '(monitor)' InconsistentLogXptProps = '(monitor)' LogXptStatus = '(monitor)' SendQEntries = '(monitor)' RecvQEntries = '(monitor)' HostName = 'serverb.example.com' StaticConnectIdentifier = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=serverb.example.com)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=orclb_DGMGRL)(INSTANCE_NAME=orclb1)(SERVER=DEDICATED)))' TopWaitEvents = '(monitor)' SidName = '(monitor)' Log file locations: Alert log : /u01/app/oracle/diag/rdbms/orclb/orclb1/trace/alert_orclb1.log Data Guard Broker log : /u01/app/oracle/diag/rdbms/orclb/orclb1/trace/drcorclb1.logDatabase Status:WARNING |
Running Tests
Opening Standby Database Read-Only
Let us open the standby database:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 | DGMGRL> edit database orclb set state='apply-off';Succeeded.SQL> alter database open read only;Database altered.SQL> select name from v$tempfile;NAME--------------------------------------------------------------------------------+DATA/ORCLB/TEMPFILE/temp.267.1065539757+DATA/ORCLB/BC3D34CE047E62F0E0530600000AF770/TEMPFILE/temp.268.1065539759+DATA+DATA+DATASQL> sho pdbs CON_ID CON_NAME OPEN MODE RESTRICTED---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 MOUNTED 4 PDB2 MOUNTED 5 PDB3 MOUNTEDSQL> alter pluggable database pdb1 open read only;Pluggable database altered.SQL> alter pluggable database pdb2 open read only;alter pluggable database pdb2 open read only*ERROR at line 1:ORA-01147: SYSTEM tablespace file 12 is offline |
PDB1 can be opened just fine, the pluggable database PDB2 cannot be opened as expected. Neither can PDB3.Enabling standby recovery:
1 2 | DGMGRL> edit database orclb set state='apply-on';Succeeded. |
Testing Data Guard Replication
Finally, I can check that the data guard replication works as expected:1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | STANDBY> alter session set container=pdb1;Session altered.STANDBY> select count(*) from new_table;select count(*) from new_table *ERROR at line 1:ORA-00942: table or view does not existPRIMARY> alter session set container=pdb1;Session altered.PRIMARY> create table new_table as select * from dba_objects;Table created.PRIMARY> alter session set container=cdb$root;Session altered.PRIMARY> alter system archive log current;System altered.STANDBY> select count(*) from new_table; COUNT(*)---------- 23043 |
Adding new Pluggable Database
A newly added pluggable database will not be replicated due to the currentENABLED_PDBS_ON_STANDBY setting. Depending on the parameter, some PDBs can be excluded and others can be replicated by default.1 2 3 4 5 6 7 8 9 10 11 | SQL> create pluggable database pdb4 admin user pdb_admin identified by pdb_admin;Pluggable database created.SQL> alter pluggable database pdb4 open;Pluggable database altered.SQL> alter system archive log current;System altered. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | 2021-02-26T15:19:29.147366+00:00PR00 (PID:4163): Media Recovery Log +FRA/ORCLB/ARCHIVELOG/2021_02_26/thread_1_seq_16.263.1065539909Recovery created pluggable database PDB4PDB4(6):File copy for ts-SYSTEM skipped for excluded/offline tablespacePDB4(6):File #20 added to control file as 'UNNAMED00020'. Originally created as:PDB4(6):'+DATA/ORCLA/BC3FCA17DFEB23DEE0530600000AF95F/DATAFILE/system.287.1065539949'PDB4(6):because the pluggable database was created with nostandbyPDB4(6):or the tablespace belonging to the pluggable database isPDB4(6):offline.PDB4(6):File copy for ts-SYSAUX skipped for excluded/offline tablespacePDB4(6):File #21 added to control file as 'UNNAMED00021'. Originally created as:PDB4(6):'+DATA/ORCLA/BC3FCA17DFEB23DEE0530600000AF95F/DATAFILE/sysaux.285.1065539949'PDB4(6):because the pluggable database was created with nostandbyPDB4(6):or the tablespace belonging to the pluggable database isPDB4(6):offline.PDB4(6):File copy for ts-UNDOTBS1 skipped for excluded/offline tablespacePDB4(6):File #22 added to control file as 'UNNAMED00022'. Originally created as:PDB4(6):'+DATA/ORCLA/BC3FCA17DFEB23DEE0530600000AF95F/DATAFILE/undotbs1.286.1065539949'PDB4(6):because the pluggable database was created with nostandbyPDB4(6):or the tablespace belonging to the pluggable database isPDB4(6):offline.PDB4(6):File copy for ts-TEMP skipped for excluded/offline tablespacePR00 (PID:4163): Media Recovery Waiting for T-1.S-17 (in transit) |
Conclusion
Oracle already has enough features to create a standby database that includes subset PDBs of the primary. Although it is possible to create a clone (non-standby) that excludes certain PDBs using theDUPLICATE command, the SKIP PLUGGABLE DATABASE clause cannot be used while duplicating for standby. Instead, this blog post provides an alternative solution. Another option is to use Refreshable Clone PDBs - they can be considered as a standby replacement with certain restrictions.The situation itself reminds me the Snapshot Standby Feature. I used it even before Oracle introduced the feature with a much of fuss. Depending on the customers' demand, Oracle can extend
DUPLICATE DATABASE FOR STANDBY to start supporting the SKIP PLUGGABLE DATABASE clause.