Scenario 6: Configure Data Guard Protection for the Source PDB
bos_sales
by configuring target PDB nyc_sales
in the newyork
container database. This is implemented in four
tasks:
- Execute the
ADD PLUGGABLE DATABASE
command to create the target PDB in the target container database. - Instantiate the target PDB by copying the all files associated with the source PDB to the target PDB location.
- Create PDB-level standby redo logfiles (SRLs) to receive foreign source redo.
- Initiate redo transport from the source PDB to the target PDB.
ADD PLUGGABLE DATABASE
command.
DGMGRL> ADD PLUGGABLE DATABASE 'nyc_sales' AT newyork SOURCE is 'bos_sales' AT boston PDBFileNameConvert is
"'/BOSTON/bos_sales/','/NEWYORK/nyc_sales/'";
Pluggable Database "NYC_SALES" added
Task 2: instantiate the target PDB.
PDBFileNameConvert
clause of the
ADD PLUGGABLE DATABASE
command. Replace <myowner> and
<nychost> with values approprirate for your environment.
$ cd $ORACLE_BASE/oradata/NEWYORK
$ mkdir nyc_sales
Copy the
source PDB files into this directory. The example uses the Linux operating system
secure copy command scp to perform this task. SQL> ALTER SESSION SET CONTAINER=bos_sales;
Session altered.
SQL> ALTER DATABASE BEGIN BACKUP;
Database altered.
SQL> host scp -r $ORACLE_BASE/oradata/BOSTON/bos_sales/*
<myowner>@<nychost>:$ORACLE_BASE/oradata/NEWYORK/nyc_sales
sysaux01.dbf 100% 930MB 22.4MB/s 00:41
system01.dbf 100% 310MB 27.7MB/s 00:11
temp01.dbf 100% 20MB 92.0MB/s 00:00
undotbs01.dbf 100% 100MB 54.9MB/s 00:01
users01.dbf 100% 5128KB 55.0MB/s 00:00
SQL> ALTER DATABASE END BACKUP; Database altered.
Task 3: create PDB-level standby redo logfiles.
This step is only performed the first time a target PDB is configured within a container database.
For traditional Data Guard deployments, standby redo logfiles (SRLs) typically are added to the primary database at the CDB level before creating any standby databases so RMAN will automatically propagate these files to all standby databases subsequently created from the primary database.
For DGPDB deployments, by contrast, SRLs are added at the PDB level after
the initial DGPDB configuration and one or more target PDBs have been created.
PDB-level SRLs can be added only to PDBs in the target role. If a CDB has multiple
PDBs in the target role, all of these target PDBs share the same set of PDB-level
SRLs to receive redo from their corresponding source PDBs. In addition, if a CDB has
no PDBs in the target role, a role change from source role to target role for one
PDB must be performed before any PDB-level SRLs can be created for that CDB. For the
example configuration, PDB-level SRLs will be added to the current source PDB
bos_sales
in Scenario 7: Switchover from Source PDB to Target PDB.
newyork
as SYSDBA and issue
the following SQL commands to add PDB-level SRLs. Note that the size specified for
the PDB level SRLs must be the same size as the source container database online
redo log files (ORLs) and that typically the number of PDB-level SRLs is one more
than the number of source ORLs to help ensure there is always a free target
PDB-level SRL available to receive redo from the source CDB.
SQL> ALTER SESSION SET CONTAINER=nyc_sales;
Session altered.
SQL> ALTER DATABASE ADD STANDBY LOGFILE thread 1
2 group 4 ('$ORACLE_BASE/fast_recovery_area/NEWYORK/onlinelog/standby_redo04.log') size 200M,
3 group 5 ('$ORACLE_BASE/fast_recovery_area/NEWYORK/onlinelog/standby_redo05.log') size 200M,
4 group 6 ('$ORACLE_BASE/fast_recovery_area/NEWYORK/onlinelog/standby_redo06.log') size 200M,
5 group 7 ('$ORACLE_BASE/fast_recovery_area/NEWYORK/onlinelog/standby_redo07.log') size 200M;
Database altered.
Use the VALIDATE PLUGGABLE DATABASE
command to confirm successful
creation of the PDB level standby redo logfiles:
DGMGRL> VALIDATE PLUGGABLE DATABASE nyc_sales AT newyork;
Ready for Switchover: NO
Data Guard Role: Physical Standby
Apply State: Not Running
Standby Redo Log Files: 4
Source: BOS_SALES (con_id 3) at boston
Task
4: initiate redo transport from the source PDB to the target PDB.
DGMGRL> EDIT PLUGGABLE DATABASE nyc_sales AT newyork SET STATE='APPLY-ON';
Succeeded.
DGMGRL> SHOW CONFIGURATION;
Configuration - Boston
Protection Mode: MaxPerformance
Members:
boston - Primary database
newyork - Primary database in NewYork configuration
Data Guard for PDB: Enabled in SOURCE role
Configuration Status:
SUCCESS (status updated 3 seconds ago)
DGMGRL> SHOW PLUGGABLE DATABASE bos_sales AT boston;
Pluggable database - BOS_SALES at boston
Data Guard Role: Primary
Con_ID: 3
Active Target: con_id 3 at newyork
Pluggable Database Status:
SUCCESS
DGMGRL> SHOW PLUGGABLE DATABASE nyc_sales AT newyork;
Pluggable database - NYC_SALES at newyork
Data Guard Role: Physical Standby
Con_ID: 3
Source: con_id 3 at boston
Transport Lag: 13 minutes 11 seconds (computed 59 seconds ago)
Apply Lag: (unknown)
Intended State: APPLY-ON
Apply State: Running
Apply Instance: newyork
Average Apply Rate: (unknown)
Real Time Query: OFF
Pluggable Database Status:
SUCCESS
Note that although redo apply is running on the target PDB, there is a transport
lag. Connect to the source CDB boston
as SYSDBA and archive the
current log a few times to initiate redo transport to the newly configured standby
redo logfiles:
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
System altered.
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;
System altered.
When the state of the target PDB is checked again, the target PDB is protecting the
source PDB with no transport or apply lag.
DGMGRL> SHOW PLUGGABLE DATABASE nyc_sales AT newyork;
Pluggable database - NYC_SALES at newyork
Data Guard Role: Physical Standby
Con_ID: 3
Source: con_id 3 at boston
Transport Lag: 0 seconds (computed 0 second ago)
Apply Lag: 0 seconds (computed 0 second ago)
Intended State: APPLY-ON
Apply State: Running
Apply Instance: newyork
Average Apply Rate: 178 KByte/s
Real Time Query: OFF
Pluggable Database Status:
SUCCESS
Continue to use this DGMGRL session in the next scenario.