Refresh PDB from Primary

1. Introduction

Oracle has announced the support of up to three pluggable databases in Standard Edition 2 from 19c. With Dbvisit Standby 10.0.x, any new pluggable databases added to primary is automatically refreshed in the standby database when you send archivelogs from primary and apply them in standby without having to re-create the standby database.

Adding a snapshot pluggable database to primary is not supported for this process.

There are two new parameters that need to be set to appropriate values before creating the pluggable database or before sending archivelogs from primary to standby after adding the pluggable database. The parameters are

BCKDIR

BCKDIR_DR

The above parameters by default have the value of $DBVISIT_BASE/standbymp/oracle/backup/{DDC} directory.

BCKDIR parameters hold the backup of the pluggable database that was recently added in the primary and it's recommended to provide a proper location unless the pluggable database is added from the seed database. The backups taken are by default compressed RMAN backup, and we recommend providing a location with enough free space if the pluggable database is refreshed from an existing pluggable database or it is attached from a different server.

BCKDIR_DR parameter is the location in the standby server where the backup of the pluggable database is transferred from the primary. This location too must have enough free space to accommodate the backup of the pluggable database. The parameters can be found in Primary Server Settings (BCKDIR) and Standby Server Settings(BCKDIR_DR).

The Parameter PDB_SYNC is set to Y by default. This is to ensure that any PDB added in the primary is refreshed to standby without any manual intervention. If this parameter is set to N then the PDB’s created in the primary are not refreshed in the standby.

2. Example

2.1 Add pluggable database in primary

SQL> sho pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO SQL> create pluggable database PDB2 admin user PDB2admin identified by PDB2admin; Pluggable database created. SQL> sho pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 PDB2 MOUNTED SQL> alter pluggable database PDB2 open; Pluggable database altered. SQL> alter pluggable database all save state; Pluggable database altered. SQL> sho pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED READ ONLY NO 3 PDB1 READ WRITE NO 4 PDB2 READ WRITE NO SQL> select name,guid from v$pdbs; NAME GUID ------------------------------ -------------------------------- PDB$SEED CEBBFFF0A9CF56F7E0536601000AE0D1 PDB1 D0C7417AED7E68E1E0536601000A94FD PDB2 D0C827189B6208CDE0536601000ADAD1 SQL> alter session set container=PDB2; Session altered. SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/system.2934.1088681057 +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/sysaux.2935.1088681057 +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/undotbs1.2933.1088681057 SQL> create tablespace users; Tablespace created. SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/system.2934.1088681057 +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/sysaux.2935.1088681057 +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/undotbs1.2933.1088681057 +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/users.2937.1088681181 SQL>

2.2 Send Archivelog from Primary

A new task is created in the task bar for exporting the PDB and the regular send archivelogs from primary to standby will proceed without any interruptions.

 

oracle@standby: /usr/dbvisit/standbymp/oracle/backup/DEV : cd D0C827189B6208CDE0536601000ADAD1/ oracle@standby: /usr/dbvisit/standbymp/oracle/backup/DEV/D0C827189B6208CDE0536601000ADAD1 : ls -lrt total 120824 -rw-r--r--. 1 oracle oinstall 62054400 Nov 15 11:29 DEV_PDB2_DBF_12_2n0e7tbq_1_1.RMAN -rw-r--r--. 1 oracle oinstall 38936576 Nov 15 11:29 DEV_PDB2_DBF_13_2p0e7tcc_1_1.RMAN -rw-r--r--. 1 oracle oinstall 21651456 Nov 15 11:29 DEV_PDB2_DBF_14_2r0e7tcm_1_1.RMAN -rw-r--r--. 1 oracle oinstall 1073152 Nov 15 11:29 DEV_PDB2_DBF_15_2t0e7tcs_1_1.RMAN -rw-r--r--. 1 oracle oinstall 980 Nov 15 11:29 DEV_PDB2.json oracle@standby: /usr/dbvisit/standbymp/oracle/backup/DEV/D0C827189B6208CDE0536601000ADAD1 :

2.2 Apply Archivelog in Standby

The PDB is refreshed from the backup that was transferred from primary to standby.

 

SQL> sho pdbs CON_ID CON_NAME OPEN MODE RESTRICTED ---------- ------------------------------ ---------- ---------- 2 PDB$SEED MOUNTED 3 PDB1 MOUNTED 4 PDB2 MOUNTED SQL> alter session set container=PDB2; Session altered. SQL> col name for a100 SQL> select name from v$datafile; NAME -------------------------------------------------------------------------------- +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/system.276.1088681839 +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/sysaux.281.1088681855 +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/undotbs1.275.1088681871 +DATA/DEV/D0C827189B6208CDE0536601000ADAD1/DATAFILE/users.285.1088681877 SQL>

3. Refresh using refresh_pdb procedure

The pluggable database that is created in the primary can be refreshed using the procedure refresh_pdb as well in the standby. In below example, we see how this is done.

Find the GUID of the pluggable database

Run the PDB refresh command