Oracle Data Guard is an amazing piece of tech. It helps keeping your data safe. When you convert to the multitenant architecture, it is crucial that you don’t jeopardize your Data Guard configuration.
Follow the below steps to bring along your standby database.
What’s The Problem
When you prepare for multitenant conversion, you prepare two things:
- Data files – you make the data files consistent by opening the non-CDB in read-only mode.
- Manifest file – you create an XML file which contains information about the non-CDB.
The manifest file contains information about the data files, including the location. However, the manifest file lists only the location on the primary database. There is no information about the standby database.
When you plug in the non-CDB, the plug-in happens without problems on the CDB primary database. It reads the manifest file and finds the data files.
But what about the CDB standby database? Since the manifest file does not list the file location on the standby host, how can the standby database find the corresponding data files?
The Options
There are two options which you control with the standbys
clause on the create pluggable database
statement:
- Enabled recovery:
- You specify
standbys=all
, or you explicitly list the standby database in thestandbys
clause. - On plug-in, the CDB standby database must find the data files. How the standby database finds the data files depends on the configuration.
- The new PDB is protected by Data Guard immediately on plug-in.
- If the standby database fails to find the data files, recovery stops for the entire CDB. All your PDBs are now unprotected unless you use PDB Recovery Isolation (see appendix).
- You specify
- Deferred recovery:
- You specify
standbys=none
, or you don’t list the standby database in thestandbys
clause. - On plug-in, the CDB standby notes the creation of the PDB but does not attempt to find and recover the data files.
- The new PDB is not protected by Data Guard until you provide the data files and re-enable recovery as described in Making Use Deferred PDB Recovery and the STANDBYS=NONE Feature with Oracle Multitenant (Doc ID 1916648.1). Typically, this means restoring all data files to the standby system. The other PDBs in the CDB standby are fully protected during the entire process.
- You specify
Convert with AutoUpgrade
You must convert with deferred recovery on the CDB standby database. AutoUpgrade uses this approach by default:
upg1.manage_standbys_clause=standbys=none
When AutoUpgrade completes, you must follow the process to restore the data files on the CDB standby database and re-enable recovery.
There is no way to plug in with enabled recovery. This includes the alias trick. This requires work on the primary and standby systems. AutoUpgrade is a fully automated process that does not allow you to intervene midway.
If you set manage_standbys_clause
to anything but the default to plug in with enabled recovery, you will most likely end up in problems. Either the data files are missing on the standby system or not at the right SCN.
This stops the MRP process in the standby database. Since the MRP process is responsible for recovering all the other PDBs as well, you are not only breaking the recently added PDB, but also all other PDBs.
Convert Manually
ASM
You can plug-in with enabled recovery and use the data files on the standby. The standby database searches the OMF location for the data files. ASM does not you manually moving files into an OMF location. Instead, you can create aliases in the OMF location as described in Reusing the Source Standby Database Files When Plugging a non-CDB as a PDB into the Primary Database of a Data Guard Configuration (Doc ID 2273304.1). The standby database follows the plug-in operation.
This option won’t work, if you use the as clone
clause on the create pluggable database
statement. The clause generates a new GUID and since the GUID is part of the OMF location, you won’t be able to create aliases upfront.
Alternatively, you can plug in with deferred recovery.
OMF in File System
You can plug-in with enabled recovery and use the data files on the standby. The CDB standby database searches the OMF location for the data files. Either:
- Move the data files into the OMF location.
- Create soft links in the OMF location for each data file pointing to the current location.
These options won’t work, if you want to use the as clone
clause. The clause generates a new GUID and since the GUID is part of the OMF location, you don’t know the OMF location upfront.
If you set standby_pdb_source_file_directory
in the CDB standby database, it looks for the data files in that directory. However, it will always copy the data files into the OMF location. Even if you specify create pluggable database ... nocopy
. Setting standby_pdb_source_file_directory
is, however, compatible with the as clone
clause.
Alternatively, you can plug in with deferred recovery.
Regular Files
The database uses regular files when db_create_file_dest
is empty.
If you plug in with enabled recovery, the CDB standby database expects to find the data files in the exact same location (path and file name) as on the primary database. The location is either the full path from the manifest file or the location specified by create pluggable database ... source_file_directory='<data_file_location>'
.
If the data files are in a different location on the CDB standby database, you either:
- Set
db_file_name_convert
in your CDB standby database. This changes the name of each of the data files accordingly. - Set
standby_pdb_source_file_directory
in your CDB standby database. When media recovery looks for a specific file during plug-in, it searches this directory instead of the full path from the manifest file.
You can plug-in using the as clone
clause without problems.
Alternatively, you can plug in with deferred recovery.
Refreshable Clone PDBs
When you migrate a non-CDB using refreshable clone PDBs, you are using a clone of the non-CDB database. Thus, there are no existing data files on the standby database that you can use.
You can only create a refreshable clone PDB with deferred recovery (standbys=none
).
After you transition the refreshable clone PDB into a regular, stand-alone PDB using alter pluggable database ... refresh mode none
, you must follow the process to restore the data files and re-enable recovery.
If you use AutoUpgrade, you must wait until the entire job completes.
Until you have completed the recovery process, the PDB is not protected by Data Guard.
For further information, including how Oracle Cloud Infrastructure makes it easier for you, have a look at Sinan’s blog post.
Important
Whichever method you choose, you must check your Data Guard configuration before going live.
-
Check the recovery status on all standby databases:
select name, recovery_status from v$pdbs;
-
Test the Data Guard configuration by performing a switchover.
Don’t go live without checking your Data Guard configuration!
Appendix
PDB Recovery Isolation
PDB Recovery Isolation is a new feature in Oracle Database 21c.
In an Active Data Guard environment, PDB recovery isolation ensures that media recovery of a CDB on the standby is not impacted when one or more PDBs are not consistent with the rest of the CDB.
Source: About PDB Recovery Isolation
If you plug in a database with standbys=all
and the standby database can’t find the data files, PDB recovery isolation kicks in:
- The standby database disables recovery of the affected PDB.
- The standby database restores the data files from the primary database.
- After restore, the standby database re-enables recovery of the PDB.
- The affected PDB is unprotected until the process is completed.
- The other PDBs are unaffected by the situation.
PDB Recovery Isolation reduces risk and automates the resolution of the problem.
At the time of writing, it requires a license for Active Data Guard.
Further Reading
- Data Guard Impact on Oracle Multitenant Environments (Doc ID 2049127.1)
- Step by Step Process of Migrating non-CDBs and PDBs Using ASM for File Storage (Doc ID 1576755.1)
Thank You
A big thank you to my valued colleague, Sinan Petrus Toma, for teaching me about PDB recovery isolation.