Monday, April 12, 2021

Plugging in a PDB in Data Guard Configuration

An earlier post shows how to use the STANDBY_PDB_SOURCE_FILE_DIRECTORY parameter to reuse the data files of a standby non-CDB when primary non-CDB is plugged in as a PDB. This post shows how the same parameter could help when plugging in an uplugged PDB to primary. It is assumed the PDB is already unplugged.
If a PDB is plugged into the primary and standby is unable to find the data files mentioned the redo apply on the standby will stop. Primary plugin command
 create pluggable database devpdb using '/opt/installs/pdbarc/devpdb.xml';
On standby alert log
2021-02-17T14:28:48.909759+00:00
Errors in file /opt/app/oracle/diag/rdbms/testfs2/testfs2/trace/testfs2_pr00_27573.trc:
ORA-01274: cannot add data file that was originally created as '/opt/data/TESTFS/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_system_j2tb048o_.dbf'
ORA-01565: error in identifying file '/opt/data/TESTFS/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_system_j2tb048o_.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2021-02-17T14:28:50.031565+00:00
Background Media Recovery process shutdown (testfs2)
This situation must be manually resoved either one file at time with a command similar to
run{
 set newname for datafile 63 to new;
 restore datafile 63 from service testfstns;
 switch datafile all;
 }
or PDB level
run {
 set newname for pluggable database devpdb to new;
 restore pluggable database devpdb from service PRODCDBTNS;
 switch datafile all;
}
This manual work could be avoided if the data files were made available on the standby instance prior to the plugin operation. Copy the data files of the PDB being plugged into a location the standby has access to and update the STANDBY_PDB_SOURCE_FILE_DIRECTORY parameter with the location.
$ pwd
/opt/installs/pdbfiles
$ ls
system.323.1064753757     sysaux.321.1064753757    
users.312.1064753751      undotbs1.322.1064753757     
oradbaudit.328.1064753751 ...

alter system set standby_pdb_source_file_directory='/opt/installs/pdbfiles';


Execute the plugin command in primary
create pluggable database devqa using '/opt/installs/pdbarc/devpdb.xml' copy;
Observe the alert log on the standby for detection and creation of the data files related to the PDB.
2021-02-17T15:29:19.457346+00:00
Recovery created pluggable database DEVQA
Recovery attempting to copy datafiles for pdb-DEVQA from           source dir-/opt/installs/pdbfiles
2021-02-17T15:29:25.313016+00:00
Recovery copied files for tablespace SYSTEM
Recovery successfully copied file /opt/data/TESTFS2/BB6378EF1A471937E053F00C1FAC6AAD/datafile/o1_mf_system_j2tfkm7v_.dbf from /opt/installs/pdbfiles/system.323.1064753757
DEVQA(4):Datafile 64 added to flashback set
DEVQA(4):Successfully added datafile 64 to media recovery
DEVQA(4):Datafile #64: '/opt/data/TESTFS2/BB6378EF1A471937E053F00C1FAC6AAD/datafile/o1_mf_system_j2tfkm7v_.dbf'
2021-02-17T15:29:30.214394+00:00
Recovery copied files for tablespace SYSAUX
Recovery successfully copied file /opt/data/TESTFS2/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_sysaux_j2tfkm7x_.dbf from /opt/installs/pdbfiles/sysaux.321.1064753757
DEVQA(4):Datafile 65 added to flashback set
DEVQA(4):Successfully added datafile 65 to media recovery
DEVQA(4):Datafile #65: '/opt/data/TESTFS2/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_sysaux_j2tfkm7x_.dbf'
2021-02-17T15:29:36.450080+00:00
Recovery copied files for tablespace UNDOTBS1
Recovery successfully copied file /opt/data/TESTFS2/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_undotbs1_j2tfkm7y_.dbf from /opt/installs/pdbfiles/undotbs1.322.1064753757
DEVQA(4):Datafile 66 added to flashback set
DEVQA(4):Successfully added datafile 66 to media recovery
DEVQA(4):Datafile #66: '/opt/data/TESTFS2/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_undotbs1_j2tfkm7y_.dbf'
Recovery copied files for tablespace USERS
Recovery successfully copied file /opt/data/TESTFS2/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_users_j2tfkm7z_.dbf from /opt/installs/pdbfiles/users.312.1064753751
DEVQA(4):Datafile 67 added to flashback set
DEVQA(4):Successfully added datafile 67 to media recovery
DEVQA(4):Datafile #67: '/opt/data/TESTFS2/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_users_j2tfkm7z_.dbf'
Recovery copied files for tablespace ORADBAUDIT
Recovery successfully copied file /opt/data/TESTFS2/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_oradbaud_j2tfkm80_.dbf from /opt/installs/pdbfiles/oradbaudit.328.1064753751
DEVQA(4):Datafile 68 added to flashback set
DEVQA(4):Successfully added datafile 68 to media recovery
DEVQA(4):Datafile #68: '/opt/data/TESTFS2/BAFDC660C6050F62E053060C1FAC3C30/datafile/o1_mf_oradbaud_j2tfkm80_.dbf'


Steps and the result is the same whether active data guard is used or not.

However, this method doesn't work when PDB is plugged in using a compressed archive file (.pdb file). Making the .pdb file available in the location refered by STANDBY_PDB_SOURCE_FILE_DIRECTORY did not result in standby uncompressing it and creating the required data files.

Related Posts
Plugging in non-CDB to CDB and reusing the non-CDB Datafiles in Standby
Creating a PDB in a Data Guard Configuration