As you probably know, the Oracle 12c multitenant feature consists of a container database (CDB) and one or more pluggable databases (PDBs). Each PDB has a separate set of data files, however, a lot of other components are still shared.
The obvious one is the instance itself and, after all, that's a major selling point for this feature in the first place (i.e.; consolidation). But even at the database (=disk) level, a lot of things are common:
The nature of a shared (linked) dictionary and common redo logs imply that a standby (Data Guard) configuration is set up at the CDB level. One source CDB means one target CDB, with all PDBs going to the same single target CDB in a 1:1 relationship.
This problem is not completely new, having been introduced with transportable tablespaces in Oracle 8i – but the CDB is now potentially subject to more data movement than we have been used to before; PDBs can be created, unplugged, plugged, dropped.
In this post let's look at the more common, simple case, where you want the same operations to occur on the standby database as they did on the primary:
So let's try this and see:
1. From pdb$seed
First of all, one needs to realize that STANDBY_FILE_MANAGEMENT comes into play here - after all, it's just new datafiles being created:
2. So let's create a new PDB from an existing one:
3. A similar thing will also happen when plugging in an unplugged PDB:
The obvious one is the instance itself and, after all, that's a major selling point for this feature in the first place (i.e.; consolidation). But even at the database (=disk) level, a lot of things are common:
- The dictionary is partially shared (linked)
- Redo logs contain changes for all PDBs and the CDB
- The undo is also shared (however, watch 12.2 for a possible change with this)
The nature of a shared (linked) dictionary and common redo logs imply that a standby (Data Guard) configuration is set up at the CDB level. One source CDB means one target CDB, with all PDBs going to the same single target CDB in a 1:1 relationship.
This problem is not completely new, having been introduced with transportable tablespaces in Oracle 8i – but the CDB is now potentially subject to more data movement than we have been used to before; PDBs can be created, unplugged, plugged, dropped.
In this post let's look at the more common, simple case, where you want the same operations to occur on the standby database as they did on the primary:
- If you create a new PDB from PDB$SEED Oracle has all the information it needs and the standby will recover the database just fine.
- If you create a new PDB as a clone of an existing (local) one, Oracle has the files it needs... but it won't copy it this for the standby, unless you are using the additional paid Advanced Data Guard option.
- If you create new PDB from a different set of files (remote), you need to copy the files to the standby, too.
So let's try this and see:
1. From pdb$seed
First of all, one needs to realize that STANDBY_FILE_MANAGEMENT comes into play here - after all, it's just new datafiles being created:
create pluggable database pdbfromseed admin user pdbfromseeduser identified by oracle FILE_NAME_CONVERT=('/oradata/CDB2/pdbseed','/oradata/CDB2/pdbfromseed'); Recovery created pluggable database PDBFROMSEED Wed Nov 11 20:48:20 2015 Recovery copied files for tablespace SYSTEM Recovery successfully copied file /oradata2/CDB2SBY/pdbfromseed/system01.dbf from /oradata2/CDB2SBY/pdbseed/system01.dbf File #10 added to control file as 'UNNAMED00010' because the parameter STANDBY_FILE_MANAGEMENT is set to MANUAL The file should be manually created to continue.Not surprisingly, you can either manually rename the file or just set the parameter to auto (but that won't fix the current problem, it works for new operations only):
alter database rename file '/u01/app/oracle/product/12.1.0.2/dbs/UNNAMED00010' to '/oradata2/CDB2SBY/pdbfromseed/system01.dbf'; Database altered. alter system set standby_file_management=auto; System altered.And all is then well:
Recovery copied files for tablespace SYSAUX Recovery successfully copied file /oradata2/CDB2SBY/pdbfromseed/sysaux01.dbf from /oradata2/CDB2SBY/pdbseed/sysaux01.dbf Recovery created file /oradata2/CDB2SBY/pdbfromseed/sysaux01.dbf Successfully added datafile 11 to media recovery Datafile #11: '/oradata2/CDB2SBY/pdbfromseed/sysaux01.dbf'
2. So let's create a new PDB from an existing one:
create pluggable database pdbfrompdb from pdbfromseed file_name_convert=('/oradata/CDB2/pdbfromseed','/oradata/CDB2/pdbfrompdb');
Errors in file /oradata/diag/rdbms/cdb2sby/CDB2SBY/trace/CDB2SBY_pr00_7068.trc: ORA-01565: error in identifying file '/oradata2/CDB2SBY/pdbfrompdb/system01.dbf' ORA-27037: unable to obtain file status Linux-x86_64 Error: 2: No such file or directory Additional information: 3 Recovery was unable to create the file as: '/oradata2/CDB2SBY/pdbfrompdb/system01.dbf' Errors with log /home/oracle/fra/CDB2SBY/archivelog/2015_11_11/o1_mf_1_763_c47c77xz_.arc Wed Nov 11 21:07:27 2015 Media Recovery failed with error 1274 Recovery interrupted! Recovery stopped due to failure in applying recovery marker (opcode 17.34). Datafiles are recovered to a consistent state at change 2814907 but controlfile could be ahead of datafiles. Wed Nov 11 21:07:27 2015 Errors in file /oradata/diag/rdbms/cdb2sby/CDB2SBY/trace/CDB2SBY_pr00_7068.trc: ORA-00283: recovery session canceled due to errors ORA-01274: cannot add data file that was originally created as '/oradata/CDB2/pdbfrompdb/system01.dbf' ORA-283 signalled during: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE...So we need to copy the files:
oracle@localhost:/oradata2/CDB2SBY$ mkdir pdbfrompdb oracle@localhost:/oradata2/CDB2SBY$ cp pdbfromseed/* pdbfrompdb/And after restarting recovery, the standby is up again.
3. A similar thing will also happen when plugging in an unplugged PDB:
create pluggable database pdbfrompdbcopy as clone using '/home/oracle/unplug_pdb.xml' file_name_convert=('/oradata/CDB2/pdbfrompdb','/oradata/CDB2/pdbfrompdbcopy'); ALTER DATABASE RECOVER MANAGED STANDBY DATABASE * ERROR at line 1: ORA-00283: recovery session canceled due to errors ORA-01274: cannot add data file that was originally created as '/oradata/CDB2/pdbfrompdbcopy/system01.dbf'
cp /oradata/CDB2/pdbfrompdb/* pdbfrompdbcopy/Note that in #2 we could copy the files locally, because Oracle has the files of the cloned PDB (and ADG can thus do it easily, too). In this case, however, it's just some other PDB, so we have to copy the files from the PDBs source of origin.
Next time we will have a look at another option: omitting the files from standby.
Comments