9.7.8 Creating Sparse Test Masters for PDBs
This procedure creates a hierarchical snapshot tree or sparse test masters manually for a pluggable database (PDB) in an Oracle Multitenant database.
The test master must be closed while making the daily reference snapshot. The downtime is very short (less than 5 minutes). You can use a replication mechanism, such as Oracle GoldenGate, to keep the sparse test master current with the production PDB. For more information about configuring Oracle GoldenGate with PDBs, see Configuring Oracle GoldenGate in a Multitenant Container Database in Oracle GoldenGate Oracle Installation and Setup Guide. The following example assumes you are using Oracle GoldenGate.
STEP 1: Create First Test Master PDB From the PROD PDB
This is a traditional PDB clone operation to instantiate the test master PDB. Once the clone completes, you configure Oracle GoldenGate to extract changes from the PRODPDB1
PDB in production and replicate these changes to the test master TMPDB1
PDB.
-
Run the following commands on the
PROD
container database (CDB) root:PRODCDB> alter pluggable database prodpdb1 close; PRODCDB> alter pluggable database prodpdb1 open read only;
-
Run the following commands from the test master CDB root:
TMCDB> create database link PROD_DBLINK connect to system identified by password using 'PROD_CDB'; TMCDB> create pluggable database TMPDB1 from PRODPDB1@PROD_DBLINK; TMCDB> alter pluggable database TMPDB1 open;
-
Configure Oracle GoldenGate so that the changes made at the
PRODPDB1
PDB will be extracted, replicated and applied to theTMPDB1
PDB. After configuring the extract and replicat and starting the extract process, openPRODPDB1
PDB in read write mode.Note:
ThePRODPDB1
PDB cannot be opened for changes until after Oracle GoldenGate has been configured and the extract process started.PRODCDB> alter pluggable database PRODPDB1 close; PRODCDB> alter pluggable database PRODPDB1 open;
At this point, you have a full copy of PRODPDB1
on test master as TMPDB1
receiving all data changes made at PRODPDB1
.
Note:
Oracle GoldenGate does not replicate data dictionary changes such as CREATE TABLESPACE or ADD DATAFILE. Only schema changes are replicated fromPRODPDB1
to TMPDB1
.
Figure 9-19 TMPDB1 Created From the PRODPDB1 Pluggable Database
![Description of Figure 9-19 follows Description of Figure 9-19 follows](img/sagug_dt_027.png)
Description of "Figure 9-19 TMPDB1 Created From the PRODPDB1 Pluggable Database"
Although TMPDB1
can be opened in read/write mode, you should leave it in read-only mode because the only changes it should receive are from PRODPDB1
through Oracle GoldenGate.
To create a snapshot from TMPDB1
, the test master PDB must be opened in read-only mode. To provide a test master PDB from which you can create snapshots, and a test master PDB that is kept current with its source, you need two PDBs. The next step shows how you can accomplish this.
STEP 2: Create Daily Read-Only Snapshot and Move TMPDB1 PDB to a New Sparse Test Master PDB
This step creates a read-only snapshot PDB that acts as a test master. You can then create read/write snapshot PDBs from this read-only snapshot PDB every day. The main steps are:
-
Create a (daily) read-only snapshot PDB that you can make available to private read/write clients.
-
Create a new sparse
TMPDB1
PDB pointing back to the read-only daily snapshot PDB. The newTMPDB1
PDB also accepts and applies changes fromPRODPDB1
.
Connect to the TMPDB1
PDB, then run the following commands:
TMCDB> alter session set container = CDB$ROOT;
# Stop the Oracle GoldenGate replicat process at the Test Master database. This allows
# all changes made at PRODPDB1 to continue to be extracted and then applied to
# TMPDB1 when the replicat process is restarted.
# Close the test master PDB.
TMCDB> alter pluggable database TMPDB1 close;
# Write the test master PDB metadata to an XML file.
TMCDB> alter pluggable database TMPDB1 unplug into
'/home/oracle/snapshot/TMPDB1_monday.XML';
# Drop the test master PDB, but keep the data files.
TMCDB> drop pluggable database TMPDB1 keep datafiles;
# Create a TMPDB1_MONDAY PDB using the XML file you just created.
#Use the NOCOPY clause to reuse the original data files.
TMCDB> create pluggable database TMPDB1_MONDAY using
'/home/oracle/snapshot/TMPDB1_monday.XML' nocopy;
# Open the new TMPDB1_MONDAY PDB. The PDB must be opened
# once in read/write mode to complete the creation process.
TMCDB> alter pluggable database TMPDB1_MONDAY open;
TMCDB> alter pluggable database TMPDB1_MONDAY close;
TMCDB> alter pluggable database TMPDB1_MONDAY open read only;
# Create the new TMPDB1 PDB to receive changes from PRODPDB1. This PDB
# must have the same name as the original test master PDB to ensure no
# changes are required to the Oracle GoldenGate configuration.
TMCDB> create pluggable database TMPDB1 from TMPDB1_MONDAY
create_file_dest='+SPARSE'
snapshot copy;
# Open the new TMPDB1 PDB. The PDB must be opened once in read/write
# mode to complete the PDB creation process.
TMCDB> alter pluggable database TMPDB1 open;
TMCDB> alter pluggable database TMPDB1 close;
TMCDB> alter pluggable database TMPDB1 open read only;
# Restart the Oracle GoldenGate replicat process to the new TMPDB1
# PDB. The Oracle GoldenGate replicat process now applies changes from
# PRODPDB1 to the TMPDB1 snapshot and all changes are written to
# sparse files.
The following figure shows the TMPDB1
created from TMPDB1_MONDAY
. The original TMPDB1 has been renamed to TMPDB1_Monday as part of the DROP PLUGGABLE DATABASE
/CREATE PLUGGABLE DATABASE
steps listed above. The new TMPDB1 is a sparse snapshot pluggable database that, until any changes are made to TMPDB1, looks exactly like TMPDB1_Monday. Oracle GoldenGate applies redo to the new TMPDB1 snapshot without having to make any changes to the replicat configuration
Figure 9-20 TMPDB1 Created From TMPDB1_MONDAY
![Description of Figure 9-20 follows Description of Figure 9-20 follows](img/sagug_dt_028.png)
Description of "Figure 9-20 TMPDB1 Created From TMPDB1_MONDAY"
STEP 3: Create Read/Write Snapshot From TMPDB1_MONDAY
You create the snapshots from TMPDB1_MONDAY
, not from TMPDB1
. This allows TMPDB1
to continue receiving and applying changes from PRODPDB1
.
Connect to the TMPDB1_MONDAY
PDB, then run the following commands:
TMCDB> alter session set container = cdb$ROOT;
TMCDB> create pluggable database TEST_MONDAY_JIM from TMPDB1_MONDAY
create_file_dest='+SPARSE'
snapshot copy;
TMCDB> alter pluggable database TEST_MONDAY_JIM open;
The following figure shows the TEST_MONDAY_JIM snapshot PDB created from TMPDB1_MONDAY. TEST_MONDAY_JIM uses TMPDB1_MONDAY as its parent so all data in TMPDB1_MONDAY_JIM is that same as the data in TMPDB1_MONDAY until changes are made to the snapshot PDB. Oracle GoldenGate continues to receive and apply redo to TMPDB1.
Figure 9-21 TEST_MONDAY_JIM Created From TMPDB1_MONDAY
![Description of Figure 9-21 follows Description of Figure 9-21 follows](img/sagug_dt_029.png)
Description of "Figure 9-21 TEST_MONDAY_JIM Created From TMPDB1_MONDAY"
When you need to create another test master and snapshot, you just need to repeat Step 2. For example, to create a test master on Tuesday, you can do the following:
Start a SQL*Plus session for the TMPDB1
PDB.
TMCDB> alter session set container = CDB$ROOT;
# Stop the Oracle GoldenGate replicat process from applying changes to
# TMPDB1
# Close the test master PDB
TMCDB> alter pluggable database TMPDB1 close;
# Write the test master PDB metadata to an XML file
TMCDB> alter pluggable database TMPDB1 unplug into
'/home/oracle/snapshots/TMPDB1_tuesday.XML';
# Drop the test master PDB, but keep the data files
TMCDB> drop pluggable database TMPDB1 keep datafiles;
# Create a TMPDB1_TUESDAY PDB from the XML file
TMCDB> create pluggable database TMPDB1_TUESDAY using
'/home/oracle/snapshot/TMPDB1_tuesday.XML' nocopy;
# Open the new TMPDB1_TUESDAY PDB
TMCDB> alter pluggable database TMPDB1_TUESDAY open;
TMCDB> alter pluggable database TMPDB1_TUESDAY close;
TMCDB> alter pluggable database TMPDB1_TUESDAY open read only;
# Create the new TMPDB1 PDB as a snapshot PDB
TMCDB> create pluggable database TMPDB1 from TMPDB1_TUESDAY
create_file_dest='+SPARSE'
snapshot copy;
# Open the TMPDB1 PDB
TMCDB> alter pluggable database TMPDB1 open;
TMCDB> alter pluggable database TMPDB1 close;
TMCDB> alter pluggable database TMPDB1 open read only;
# Restart the Oracle GoldenGate replicat process to apply changes to
# the new TMPDB1
You can now create read/write snapshot PDBs from TMPDB1_TUESDAY, similar to Step 3 above. The same as with full database sparse test masters, you can repeat this process up to 9 times in total before needing to either create a new TMPDB1 test master or drop and recreate the original TMPDB1 to begin building a new hierarchical snapshot tree.
Parent topic: Managing Exadata Snapshots