Showing posts with label non-CDB. Show all posts
Showing posts with label non-CDB. Show all posts

Friday, September 10, 2021

Converting EM Repository DB from Non-CDB to PDB

With EM 13.4 it is possible to use either non-CDB or a PDB as the repository database. This post shows the steps for converting a non-CDB EM repository DB to a PDB.
Main thing to look out for is that repository connection string is updated in various files the EM uses. Current connection string could be found out with the following command.
emctl config oms -list_repos_details
Oracle Enterprise Manager Cloud Control 13c Release 4
Copyright (c) 1996, 2020 Oracle Corporation.  All rights reserved.
Repository Connect Descriptor : (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SID=emandb1)))
Repository User : SYSMAN

Mos Docs 2431726.1, 2144665.1 and 2214218.1 all mention the files where the connection string is specified. These are available in the following directories.
cd /opt/app/software/em/gc_inst/user_projects/domains/GCDomain/config/fmwconfig

embi-policystoremerge-jpscfg.xml
  <property name="jdbc.url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SID=emandb1)))"/>

jps-config-jse.xml
 <property name="jdbc.url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SID=emandb1)))"/>

jps-config.xml
 <property name="jdbc.url" value="jdbc:oracle:thin:@(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SID=emandb1)))"/>
 

cd /opt/app/software/em/gc_inst/user_projects/domains/GCDomain/config/jdbc
all *.xml files in this directory as per 2214218.1
 
cd /opt/app/software/em/gc_inst/em/EMGC_OMS1
emgc.properties
EM_REPOS_CONNECTDESCRIPTOR=(DESCRIPTION\=(ADDRESS_LIST\=(ADDRESS\=(PROTOCOL\=TCP)(HOST\=console-srv)(PORT\=2020)))(CONNECT_DATA\=(SID\=emandb1)))

Main issue here is that connection string uses SID. Once the repos DB is plugged in as a PDB, the SID cannot be used to connect to it. Service name (SERVICE_NAME) must be used instead. Therefore as the first step the connection string would be updated to use service name instead of SID.
The current repos DB is called emandb1.
It will have a default service called emandb1. The listener status command would give these details.
Service "emandb1" has 1 instance(s).
  Instance "emandb1", status READY, has 1 handler(s) for this service...
If the non-CDB is plugged as a PDB using the same name emandb1 then this will result in a default service for PDB called emandb1. This would allow OMS to connect to the PDB without requring any connection string change. Also changing the connecting string before non-CDB conversion would allow any connectivity related issues to be ironed out beforehand.
With this in mind change the connection string to use service_name instead of SID. First check the connection string with service_name works by using it on a sqlplus connection
sqlplus sysman@"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SERVICE_NAME=emandb1)))"

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Sep 7 09:10:44 2021
Version 19.12.0.0.0

SQL>

Then use the following command (mentioned in 2214218.1, 1395107.1 and CC Advanced Installation and Configuration Guide) to change the connecting string. The documentation states to shutdown OMS before running this command. The normal output is shown below.
emctl stop oms
Oracle Enterprise Manager Cloud Control 13c Release 4
Copyright (c) 1996, 2020 Oracle Corporation.  All rights reserved.
Stopping Oracle Management Server...
Oracle Management Server Successfully Stopped
Oracle Management Server is Down
JVMD Engine is Down

emctl config oms -store_repos_details -repos_conndesc "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SERVICE_NAME=emandb1)))" -repos_user SYSMAN
Oracle Enterprise Manager Cloud Control 13c Release 4
Copyright (c) 1996, 2020 Oracle Corporation.  All rights reserved.
Enter Repository User's Password :
Successfully updated datasources and stored repository details in Credential Store.
If there are multiple OMSs in this environment, run this store_repos_details command on all of them.
And finally, restart all the OMSs using 'emctl stop oms -all' and 'emctl start oms'.
It is also necessary to restart the BI Publisher Managed Server.

But at times the command has also complained admin server is down when only oms stopped is called. It seems the admin server neeeds to be up connection string change to work. Good thing is comamnd will bring up the admin server if it is down. See the output below for this case.
emctl stop oms

emctl config oms -store_repos_details -repos_conndesc "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SERVICE_NAME=emandb1)))" -repos_user SYSMAN
Oracle Enterprise Manager Cloud Control 13c Release 4
Copyright (c) 1996, 2020 Oracle Corporation.  All rights reserved.
Enter Repository User's Password :
Admin server is down. It is required to update repository details. This command will try to bring it up.
Starting Admin Server only...
Admin Server Successfully Started
Successfully updated datasources and stored repository details in Credential Store.
If there are multiple OMSs in this environment, run this store_repos_details command on all of them.
And finally, restart all the OMSs using 'emctl stop oms -all' and 'emctl start oms'.
It is also necessary to restart the BI Publisher Managed Server.

emctl stop oms -all

emctl start oms

emctl config oms -list_repos_details
Oracle Enterprise Manager Cloud Control 13c Release 4
Copyright (c) 1996, 2020 Oracle Corporation.  All rights reserved.
Repository Connect Descriptor : (DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SERVICE_NAME=emandb1)))
Repository User : SYSMAN

Above shows the new connetion string uses service_name. Checking in individual files mentioned earlier, all but embi-policystoremerge-jpscfg.xml and jps-config-jse.xml had the connection string changed correctly. The connectring string in file embi-policystoremerge-jpscfg.xml still refered to SID. Manually edit the connection string to use service_name. In jps-config-jse.xml there are serveral references to connection string and section under serviceInstance name="audit.db" didn't have the SID changed to service name. Make the change manually. Once done login to cloud control and check all is working as expected. If any connectivity errors are there correct them before proceeding to next steps. The EM Repos DB target shown on the console may require re-discovering and promoting



Next step is to create a CDB to plug the repos non-CDB as a PDB. The repos DB has very specific requirements when it comes to their memory parametrs, redo log file sizes, hidden parameters and etc (refer earlier post). The simplest way to accomplish this is to create a template from current non-CDB and use the template to create a the CDB. Below two commands does exactly this.
dbca -createTemplateFromDB -templateName /home/oracle/emrepos13.4.dbt -sourceDB emandb1 -sysDBAUserName sys -maintainFileLocations false  -silent

dbca -silent -createDatabase -templateName /home/oracle/emrepos13.4.dbt -gdbName emandb -sysPassword xxxx -systemPassword xxx  -emConfiguration NONE -storageType ASM -asmsnmpPassword xxxx -diskGroupName DATA -recoveryGroupName FRA -createAsContainerDatabase true 

The CDB is called emandb(different to current non-CDB repos DB name). The database created from template will have tablespaces that were created for EM repos use such as MGMT_AD4J_TS,MGMT_ECM_DEPOT_TS,MGMT_TABLESPACE. These could be dropped from the CDB to save space (alternatively edit the template so these are not created in the first place).
Shutdown the OMS as the next step is to plug the non-CDB as a PDB. For this test case used the manual method. Last set of steps are shown below. The non-CDB is plugged in as a PDB has the same name, emandb1.
SQL> CREATE PLUGGABLE DATABASE emandb1 USING '/home/oracle/emandb1_non_cdb.xml' copy;

Pluggable database created.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 EMANDB1                        MOUNTED
SQL> alter session set container=emandb1;

Session altered.

SQL> select name from v$datafile;
NAME
----------------------------------------------------------------------------------------
+DATA/EMANDB/A148AAC6957E5A34E0530500160A7405/DATAFILE/system.303.1082632693
+DATA/EMANDB/A148AAC6957E5A34E0530500160A7405/DATAFILE/sysaux.306.1082632693
+DATA/EMANDB/A148AAC6957E5A34E0530500160A7405/DATAFILE/undotbs1.304.1082632693
+DATA/EMANDB/A148AAC6957E5A34E0530500160A7405/DATAFILE/users.299.1082632693
+DATA/EMANDB/A148AAC6957E5A34E0530500160A7405/DATAFILE/oradbaudit.298.1082632693
+DATA/EMANDB/A148AAC6957E5A34E0530500160A7405/DATAFILE/mgmt_ad4j_ts.305.1082632693
+DATA/EMANDB/A148AAC6957E5A34E0530500160A7405/DATAFILE/mgmt_ecm_depot_ts.297.1082632693
+DATA/EMANDB/A148AAC6957E5A34E0530500160A7405/DATAFILE/mgmt_tablespace.307.1082632693

8 rows selected.
The new PDB now contains the datafiles related to EM related tablespaces. Complete the conversion with the following.
@?/rdbms/admin/noncdb_to_pdb.sql

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 EMANDB1                        MOUNTED
SQL> alter pluggable database open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         3 EMANDB1                        READ WRITE NO
Once the PDB is open the listener will have a service emandb1 (PDB default service) for emandb CDB instance.
Service "emandb" has 1 instance(s).
  Instance "emandb", status READY, has 1 handler(s) for this service...
Service "emandb1" has 1 instance(s).
  Instance "emandb", status READY, has 1 handler(s) for this service...
Use sqlplus with same connection string as before to check connectivity to the PDB.
sqlplus sysman@"(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SERVICE_NAME=emandb1)))"
If connectivity is fine start the OMS.
emctl start oms
Oracle Enterprise Manager Cloud Control 13c Release 4
Copyright (c) 1996, 2020 Oracle Corporation.  All rights reserved.
Starting Oracle Management Server...
WebTier Successfully Started
Oracle Management Server Successfully Started
Oracle Management Server is Up
JVMD Engine is Up
Discover the new EM repos db and related PDB targets and promote them. The dbsnmp common user in CDB will be in locked status. Unlock the dbsnmp account and give a new password.


The old EM repos db will be in down state while newly promoted CDB and PDB will be shown up state.

Once confident all is working as expected the old EM repos DB could be dropped.

Update 28/09/2021
Two incidents occured with regard to change of the connection string. The -list_repos_details showed service_name being used but there were two resources still refering SID. One is the management service.
The monitoring configuration of the management service shows SID in the connection string. Manually edit the connection string to include service_name and save. Only the connection descriptor was changed. No need to re-enter username or password (leave the defaults in place).

Similar connection string related incident could be seen for management service and repository as well.

Repository still seem to use the SID in the connection string.

To fix this issue manually edit the conenction string to include service name and save. Similar to previous incident no need to enter username or password (leave the default in place).

There were no other incidents after these changes.
This issue may have been due to not executing the "emctl config emrep". This could be done by running
emctl config emrep -conn_desc "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=console-srv)(PORT=2020)))(CONNECT_DATA=(SERVICE_NAME=emandb1)))"


Update 17/01/2022
This scenario is now documented in 13.5 upgrade guide.
Migrating the SYSMAN Schema to a Database Configured with CDB and PDB

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

Monday, March 1, 2021

Plugging in non-CDB to CDB and reusing the non-CDB Datafiles in Standby

This post shows how the use of STANDBY_PDB_SOURCE_FILE_DIRECTORY parameter could help in reusing data file in the standby when a non-CDB is plugged in as a PDB to CDB that is also in a data guard configuration.
The MOS docs on the matter (2273304.1) creating aliases when ASM is used for storage. Another MOS note (2274735.1) shows using the above parameter when cloning PDBs.
This post shows the steps for plugging in a non-CDB in data gaurd configuration and resuing the standby data files of the non-CDB with the help of STANDBY_PDB_SOURCE_FILE_DIRECTORY parameter. The database reference documentation states
the STANDBY_PDB_SOURCE_FILE_DIRECTORY specifies a directory location on the standby where source datafiles for instantiating the PDB may be found. If the datafiles are not found there, an attempt will be made to locate them in the OMF location on the standby. This parameter can also be used to try to copy files in cases where the source PDB's files are not present on the standby.
Some information on the setup, both non-CDB and CDB are running same version (19.10 in this case). Two cases are shown in this post are one using file system with OMF and another where ASM is used for storage. TDE is not used in this configuration nor on the CDB where non-CDB is plugged in.
The non-CDB data guard configuration is as follows.
DGMGRL> show configuration;

Configuration - noncdb_dg

  Protection Mode: MaxAvailability
  Members:
  noncdb  - Primary database
    noncdb2 - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 50 seconds ago)
If upgrading from a lower version this could be thought of as a data guard configuration that is already upgraded (with dbms_rolling, transient logical standby or traditional method with down time) to 19c.
The steps for plugging in the non-CDB as a PDB on primary is same as without data guard (however, autoupgrade was not used for this and non-CDB was plugged in manually). But there are few key things to make a note of. When the primary non-CDB is open in read only mode to create the descriptor file make sure that checkpoint_change# on primary and standby datafiles match.
On primary non-CDB
shutdown imemdiate;
startup mount;
alter database open read only;

select CHECKPOINT_CHANGE#,name from v$datafile;

CHECKPOINT_CHANGE# NAME
------------------ -------------------------------------------------------
            858807 /opt/data/NONCDB/datafile/o1_mf_system_j2tgk6do_.dbf
            858807 /opt/data/NONCDB/datafile/o1_mf_sysaux_j2tgkgg8_.dbf
            858807 /opt/data/NONCDB/datafile/o1_mf_undotbs1_j2tgklqr_.dbf
            858807 /opt/data/NONCDB/datafile/o1_mf_users_j2tgl0j3_.dbf
Check the same on standby non-CDB
select CHECKPOINT_CHANGE#,name from v$datafile;
            
            CHECKPOINT_CHANGE# NAME
------------------ --------------------------------------------------------
            858807 /opt/data/NONCDB2/datafile/o1_mf_system_09vne4sm_.dbf
            858807 /opt/data/NONCDB2/datafile/o1_mf_sysaux_0avne4t5_.dbf
            858807 /opt/data/NONCDB2/datafile/o1_mf_undotbs1_0bvne4tk_.dbf
            858807 /opt/data/NONCDB2/datafile/o1_mf_users_0cvne4tr_.dbf
In this case a simple clean shutdown was enough to make both sets of data files to have same checkpoint change number (the fact protection mode being max availability mode may have something to do with this). If the checkpoint change numbers are different then follow 2273304.1 to flush redo and recover the standby non-CDB data files to the same checkpoint change number as the primary non-CDB data files.
Create the non-CDB descriptor file and shutdown both primary and standby non-CDB databases.
On primary
exec dbms_pdb.describe(pdb_descr_file=>'/home/oracle/noncdb.xml');

PL/SQL procedure successfully completed.

SQL> shutdown immediate;
On standby
SQL> shutdown immediate;



The CDB data guard configuration details are as follows
DGMGRL> show configuration

Configuration - dg_19c_fs

  Protection Mode: MaxAvailability
  Members:
  testfs  - Primary database
    testfs2 - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 59 seconds ago)
Run the compatability check on the primary CDB.
set serveroutput on
declare
    compa boolean;
    begin
    compa := dbms_pdb.CHECK_PLUG_COMPATIBILITY(pdb_descr_file=>'/home/oracle/noncdb.xml');
 if compa = true then
      dbms_output.put_line('compatible');
 else
    dbms_output.put_line('not compatible');
 end if;
end;
/

compatible
Before creating the PDB set the standby_pdb_source_file_directory on the standby CDB to the location where data files of the non-CDB standby resides. If the data files of the non-CDB are on the file system (with OMF) then set the standby_pdb_source_file_directory similar to
SQL> alter system set standby_pdb_source_file_directory='/opt/data/NONCDB2/datafile' scope=both;

System altered.
If standby non-CDB was using ASM then set similar to below.
SQL> alter system set standby_pdb_source_file_directory='+DATA/NONCDB2/DATAFILE' scope=both;

System altered.
Once the standby_pdb_source_file_directory are set then plug in the non-CDB as a PDB on the primary.
CREATE PLUGGABLE DATABASE noncdbaspdb USING '/home/oracle/noncdb.xml' copy;
While plug in is happening the standby alert log will show files being copied from the standby_pdb_source_file_directory location to the OMF locations. Following is from standby alert log when file system is used.
2021-02-17T17:23:25.952694+00:00
Recovery created pluggable database NONCDBASPDB
Recovery attempting to copy datafiles for pdb-NONCDBASPDB from           source dir-/opt/data/NONCDB2/datafile
2021-02-17T17:23:30.951094+00:00
Recovery copied files for tablespace SYSTEM
Recovery successfully copied file /opt/data/TESTFS2/BB6378EF1A471937E053F00C1FAC6AAD/datafile/o1_mf_system_j2tn81ol_.dbf from /opt/data/NONCDB2/datafile/o1_mf_system_09vne4sm_.dbf
NONCDBASPDB(4):Datafile 98 added to flashback set
NONCDBASPDB(4):Successfully added datafile 98 to media recovery
NONCDBASPDB(4):Datafile #98: '/opt/data/TESTFS2/BB6378EF1A471937E053F00C1FAC6AAD/datafile/o1_mf_system_j2tn81ol_.dbf'
2021-02-17T17:23:35.458745+00:00
Recovery copied files for tablespace SYSAUX
Recovery successfully copied file /opt/data/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/datafile/o1_mf_sysaux_j2tn81ox_.dbf from /opt/data/NONCDB2/datafile/o1_mf_sysaux_0avne4t5_.dbf
NONCDBASPDB(4):Datafile 99 added to flashback set
NONCDBASPDB(4):Successfully added datafile 99 to media recovery
NONCDBASPDB(4):Datafile #99: '/opt/data/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/datafile/o1_mf_sysaux_j2tn81ox_.dbf'
2021-02-17T17:23:37.428931+00:00
Recovery copied files for tablespace UNDOTBS1
Recovery successfully copied file /opt/data/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/datafile/o1_mf_undotbs1_j2tn81oz_.dbf from /opt/data/NONCDB2/datafile/o1_mf_undotbs1_0bvne4tk_.dbf
NONCDBASPDB(4):Datafile 100 added to flashback set
NONCDBASPDB(4):Successfully added datafile 100 to media recovery
NONCDBASPDB(4):Datafile #100: '/opt/data/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/datafile/o1_mf_undotbs1_j2tn81oz_.dbf'
Recovery copied files for tablespace USERS
Recovery successfully copied file /opt/data/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/datafile/o1_mf_users_j2tn81p0_.dbf from /opt/data/NONCDB2/datafile/o1_mf_users_0cvne4tr_.dbf
NONCDBASPDB(4):Datafile 101 added to flashback set
NONCDBASPDB(4):Successfully added datafile 101 to media recovery
NONCDBASPDB(4):Datafile #101: '/opt/data/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/datafile/o1_mf_users_j2tn81p0_.dbf'


On the otherhand if ASM is used expect something similar to below on the alert log.
2021-02-18T13:06:46.114728+00:00
Recovery created pluggable database NONCDBASPDB
Recovery attempting to copy datafiles for pdb-NONCDBASPDB from           source dir-+DATA/NONCDB2/DATAFILE
2021-02-18T13:06:46.240880+00:00
NOTE: dependency between database testfs2 and diskgroup resource ora.DATA.dg is established
2021-02-18T13:06:55.953110+00:00
Recovery copied files for tablespace SYSTEM
Recovery successfully copied file +DATA/TESTFS2/BB6378EF1A471937E053F00C1FAC6AAD/DATAFILE/system.262.1064840807 from +DATA/NONCDB2/DATAFILE/system.256.1064839675
NONCDBASPDB(5):Datafile 111 added to flashback set
NONCDBASPDB(5):Successfully added datafile 111 to media recovery
NONCDBASPDB(5):Datafile #111: '+DATA/TESTFS2/BB6378EF1A471937E053F00C1FAC6AAD/DATAFILE/system.262.1064840807'
2021-02-18T13:07:04.357805+00:00
Recovery copied files for tablespace SYSAUX
Recovery successfully copied file +DATA/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/DATAFILE/sysaux.265.1064840817 from +DATA/NONCDB2/DATAFILE/sysaux.257.1064839687
NONCDBASPDB(5):Datafile 112 added to flashback set
NONCDBASPDB(5):Successfully added datafile 112 to media recovery
NONCDBASPDB(5):Datafile #112: '+DATA/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/DATAFILE/sysaux.265.1064840817'
2021-02-18T13:07:08.042371+00:00
Recovery copied files for tablespace UNDOTBS1
Recovery successfully copied file +DATA/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/DATAFILE/undotbs1.263.1064840825 from +DATA/NONCDB2/DATAFILE/undotbs1.258.1064839695
NONCDBASPDB(5):Datafile 113 added to flashback set
NONCDBASPDB(5):Successfully added datafile 113 to media recovery
NONCDBASPDB(5):Datafile #113: '+DATA/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/DATAFILE/undotbs1.263.1064840825'
Recovery copied files for tablespace USERS
Recovery successfully copied file +DATA/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/DATAFILE/users.275.1064840829 from +DATA/NONCDB2/DATAFILE/users.259.1064839697
NONCDBASPDB(5):Datafile 114 added to flashback set
NONCDBASPDB(5):Successfully added datafile 114 to media recovery
NONCDBASPDB(5):Datafile #114: '+DATA/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/DATAFILE/users.275.1064840829'
Recovery copied files for tablespace TEST
Recovery successfully copied file +DATA/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/DATAFILE/test.276.1064840829 from +DATA/NONCDB2/DATAFILE/test.260.1064839883
NONCDBASPDB(5):Datafile 115 added to flashback set
NONCDBASPDB(5):Successfully added datafile 115 to media recovery
NONCDBASPDB(5):Datafile #115: '+DATA/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/DATAFILE/test.276.1064840829'


Complete the non-CDB plug in by running noncdb_to_pdb script.
SQL> alter session set container=NONCDBASPDB;

Session altered.

SQL> @?/rdbms/admin/noncdb_to_pdb.sql

on primary 

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         4 NONCDBASPDB                    MOUNTED

SQL> alter pluggable database open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         4 NONCDBASPDB                    READ WRITE NO
On the standby the new PDB will be in mount state.
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       MOUNTED
         3 TESTPDB                        MOUNTED
         4 NONCDBASPDB                    MOUNTED
To test if all is working fine, create a test tablespace on the PDB. First identify the GUID of the newly created PDB.
SQL> select guid,name from v$pdbs;

GUID                             NAME
-------------------------------- -------------
BB8B1CFF497166F8E053F00C1FACF64E NONCDBASPDB
Create a tablespace on the primary.
SQL> create tablespace test datafile size 10m;

Tablespace created.
Check the standby alert log for the corresponding datafile being created inside the same GUID.
2021-02-17T17:29:28.946404+00:00
(4):Resize operation completed for file# 100, old size 424960K, new size 430080K
2021-02-17T17:32:20.962105+00:00
(4):Datafile 102 added to flashback set
(4):Successfully added datafile 102 to media recovery
(4):Datafile #102: '/opt/data/TESTFS2/BB8B1CFF497166F8E053F00C1FACF64E/datafile/o1_mf_test_j2tns4w1_.dbf'
If possible do a switchover and open the newly created PDB in read-write mode.
DGMGRL> switchover to testfs2;
Performing switchover NOW, please wait...
Operation requires a connection to database "testfs2"
Connecting ...
Connected to "testfs2"
Connected as SYSDBA.
New primary database "testfs2" is opening...
Oracle Clusterware is restarting database "testfs" ...
Connected to "testfs"
Connected to "testfs"
Switchover succeeded, new primary is "testfs2"

DGMGRL> show configuration

Configuration - dg_19c_fs

  Protection Mode: MaxAvailability
  Members:
  testfs2 - Primary database
    testfs  - Physical standby database

Fast-Start Failover:  Disabled

Configuration Status:
SUCCESS   (status updated 60 seconds ago)
PDB status on old standby (new primary)
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB                        READ WRITE NO
         4 NONCDBASPDB                    READ WRITE NO

This post has shown how standby_pdb_source_file_directory could be used to specify the location of the data files in standby and reuse them. It also showed when ASM is used no need to create aliases anymore.

Related Posts
Plugging non-CDB as a PDB - Manual vs Autoupgrade
Plugging non-CDB as a PDB into a CDB in the Same Host
Creating a PDB in a Data Guard Configuration

Useful metalink notes
Reusing the Source Standby Database Files When Plugging a non-CDB as a PDB into the Primary Database of a Data Guard Configuration [ID 2273304.1]
Using standby_pdb_source_file_dblink and standby_pdb_source_file_directory to Maintain Standby Databases when Performing PDB Remote Clones or Plugins [ID 2274735.1]

Friday, February 26, 2021

Plugging non-CDB as a PDB - Manual vs Autoupgrade

This post shows the the comparison between the manual method and using autoupgrade for plugging in a non-CDB as a PDB to CDB in the same host.
Manual Method
1. The non-CDB details are as follows
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
test

SQL>  select cdb from v$database;

CDB
---
NO

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/test/datafile/system.260.1030288905
+DATA/test/datafile/sysaux.261.1030288913
+DATA/test/datafile/undotbs1.262.1030288917
+DATA/test/datafile/users.264.1030288923
+DATA/TEST/DATAFILE/audit.284.1063984491
+DATA/TEST/DATAFILE/box.285.1063984495
+DATA/TEST/DATAFILE/lobs.286.1063984499
+DATA/TEST/DATAFILE/indexes.287.1063984501
+DATA/TEST/DATAFILE/repository.288.1063984505
+DATA/TEST/DATAFILE/dbaudit.289.1063984509
+DATA/TEST/DATAFILE/audindexes.290.1063984513
+DATA/TEST/DATAFILE/audlobs.291.1063984515
+DATA/TEST/DATAFILE/catbs.292.1063984519
+DATA/TEST/DATAFILE/caindexes.293.1063984523
+DATA/TEST/DATAFILE/ctbs.294.1063984527
+DATA/TEST/DATAFILE/wtbs.295.1063984529
+DATA/TEST/DATAFILE/exptbs.296.1063984533
2. Claenly shutdown the non-CDB and open in read only mode.
shutdown immediate;
startup mount;
alter database open read only;
3. Create the descriptor file for the non-CDB and shutdown the non-CDB.
SQL> exec dbms_pdb.describe(pdb_descr_file=>'/home/oracle/test_non_cdb.xml');

PL/SQL procedure successfully completed.

shutdown immediate
4. CDB details are as follows
SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
testcdb
5. Run the compatibility check on the CDB using the non-CDB descriptor file.
set serveroutput on
declare
    compa boolean;
    begin
    compa := dbms_pdb.CHECK_PLUG_COMPATIBILITY(pdb_descr_file=>'/home/oracle/test_non_cdb.xml');
 if compa = true then
      dbms_output.put_line('compatible');
 else
    dbms_output.put_line('not compatible');
 end if;
end;
/

compatible

PL/SQL procedure successfully completed.
6. As compatible status is shown run the create PDB statement
CREATE PLUGGABLE DATABASE testpdb1 USING '/home/oracle/test_non_cdb.xml' copy;

Pluggable database created.
7. This creates the PDB in mount state.
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         5 TESTPDB1                       MOUNTED
Connect to the new PDB and check all data files are available
SQL>  alter session set container=testpdb1;

Session altered.

SQL> show con_name

CON_NAME
------------------------------
TESTPDB1

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/system.305.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/sysaux.304.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/undotbs1.303.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/users.309.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audit.308.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/box.307.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/lobs.310.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/indexes.282.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/repository.280.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/dbaudit.281.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audindexes.283.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/audlobs.297.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/catbs.298.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/caindexes.299.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/ctbs.300.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/wtbs.301.1063985599
+DATA/TESTCDB/9CBA2DF91A8C7012E053F4071FAC36E9/DATAFILE/exptbs.302.1063985599

17 rows selected.
8. As the last step before opening the new PDB run noncdb_to_pdb.sql.
@?/rdbms/admin/noncdb_to_pdb.sql

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         5 TESTPDB1                       MOUNTED
SQL> alter pluggable database open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         5 TESTPDB1                       READ WRITE NO



Autoupgrade Method
The same could be acheived with few steps using autoupgrade.jar (which is now the recommended tool for database upgrades). The same non-CDB and the CDB is used earlier is used for this case as well.

1. Create a autoupgrade configuration file with both source and target home set to the same versions. In this case both non-CDB and CDB were running out of the same home. Also the other main paramtere is target_pdb_copy_option which is set to "file_name_convert=NONE" since both non-CDB and CDB are using ASM. A new name oculd be specified to be used when the non-CDB is plugged in as a PDB (uatpdb in this case). The full configuration file used is shown below.
global.autoupg_log_dir=/home/oracle/upgr_log

upg1.sid=test
upg1.source_home=/opt/app/oracle/product/19.x.0/dbhome_1
upg1.target_home=/opt/app/oracle/product/19.x.0/dbhome_1
upg1.target_cdb=testcdb
upg1.target_pdb_name=uatpdb
upg1.target_pdb_copy_option=file_name_convert=NONE
2. The version of the autoupgrade is 19.9
java -jar autoupgrade.jar -version
build.hash bf4ccd4
build.version 19.9.2
build.date 2020/08/31 13:47:51
build.max_target_version 19
build.supported_target_versions 12.2,18,19
build.type production
3. Run the autoupgrade with deploy option. This processes pluggin the non-CDB as with the copy option in the manual method.
java -jar autoupgrade.jar -config noncdb_pdb.cfg -mode deploy
4. End of the run the PDB is created and in read/write mode
SQL> show pdbs
         2 PDB$SEED                       READ ONLY  NO
         3 TESTPDB2                       MOUNTED
         4 DEVPDB                         READ WRITE NO
         5 UATPDB                         READ WRITE NO
5. The data files of the PDB are copied into directory under $asm_diskgroup/cdb_sid/pdb_guid format.
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/system.345.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/sysaux.344.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/undotbs1.343.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/users.329.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/audit.330.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/box.331.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/lobs.332.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/indexes.333.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/repository.334.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/dbaudit.335.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/audindexes.336.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/audlobs.337.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/catbs.338.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/caindexes.339.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/ctbs.340.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/wtbs.341.1064159817
+DATA/TESTCDB/BAFE73D2E50633B2E053060C1FAC8FBD/DATAFILE/exptbs.342.1064159817

17 rows selected.

The comparision shows that autoupgrade method require few steps and less manaul intervention.

Related Posts
Plugging non-CDB as a PDB into a CDB in the Same Host
Plugging in non-CDB to CDB and reusing the non-CDB Datafiles in Standby

Sunday, April 8, 2018

Plugging non-CDB as a PDB into a CDB in the Same Host

This post shows the steps of plugging a non-CDB into a CDB when both DBs reside on the same host. Both DBs run out of the same Oracle home and has the same database options (non-CDB must have either same or subset of the CDBs options).
1. Non-CDB is as follows
SQL> select cdb from v$database;

CDB
---
NO

SQL> select instance_name from v$instance;

INSTANCE_NAME
----------------
beast

SQL> select name from v$datafile;

NAME
-------------------------------------------------------------------
/opt/app/oracle/oradata/BEAST/datafile/o1_mf_system_f902ycxw_.dbf
/opt/app/oracle/oradata/BEAST/datafile/o1_mf_sysaux_f902ypt8_.dbf
/opt/app/oracle/oradata/BEAST/datafile/o1_mf_undotbs1_f902yxqx_.dbf
/opt/app/oracle/oradata/BEAST/datafile/o1_mf_users_f902zgb3_.dbf
2. Shutdown the non-CDB and open it in read only mode. Once open in read only mode connect to the non-CDB and create a non-cdb descriptor file. Once the descriptor file is created shutdown the non-CDB.
shutdown imemdiate;
startup mount;
alter database open read only;

exec dbms_pdb.describe(pdb_descr_file=>'/home/oracle/beast_non_cdb.xml');

shutdown immediate;
3. The CDB details are as follows.
SQL> select instance_name from v$instance;

INSTANCE_NAME
-------------
parakum

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         5 PDBAPP1                        READ WRITE NO
4. Connect to the CDB and run CHECK_PLUG_COMPATIBILITY to test the compatibility of the non-CDB. Following PL/SQL code could be used for this.
SQL> show con_name

CON_NAME
---------
CDB$ROOT

set serveroutput on
declare
    compa boolean;
    begin
    compa := dbms_pdb.CHECK_PLUG_COMPATIBILITY(pdb_descr_file=>'/home/oracle/beast_non_cdb.xml');
 if compa = true then
      dbms_output.put_line('compatible');
 else
    dbms_output.put_line('not compatible');
 end if;
end;
/

compatible
5. As the non-CDB is compatible, it could be safely plugged into the CDB. In preparation of this, shutdown the non-CDB.
SQL> show con_name

CON_NAME
---------
beast

SQL> shutdown immediate;


6. PDB could be created either with copy command or move. With copy command the files will be copied from non-CDB OMF locations to CDB OMF locations. At the end of the copy the non-CDB could be opened as before and copy of it will be available inside the CDB as a PDB. If the host server doesn't have enough space for a full copy of the non-CDB then move options could be used where files will be moved from non-CDB to CDB. At the end of the move, non-CDB will not be available for use since files are moved out. Following shows the use of copy command
Since non-CDB uses OMF, the file_name_convert cannot be used during the PDB creation. Using of file_name_convert will result in error (refer MOS 1912436.1 as well)
SQL> CREATE PLUGGABLE DATABASE beast USING '/home/oracle/beast_non_cdb.xml'
COPY
FILE_NAME_CONVERT = ('/opt/app/oracle/oradata/BEAST/datafile/', '/opt/app/oracle/oradata/PARAKUM/');  2    3
CREATE PLUGGABLE DATABASE beast USING '/home/oracle/beast_non_cdb.xml'
*
ERROR at line 1:
ORA-01276: Cannot add file
/opt/app/oracle/oradata/PARAKUM/o1_mf_system_f902ycxw_.dbf.  File has an Oracle
Managed Files file name.
One of the solutions is to omit file name conversion and let OMF to take care of it.
SQL>  CREATE PLUGGABLE DATABASE beast USING '/home/oracle/beast_non_cdb.xml' copy;
Alternatively source_file_name_convert could be used by specifying current location of the datafiles into the two string mappings.
CREATE PLUGGABLE DATABASE beast USING '/home/oracle/beast_non_cdb.xml'
COPY
source_file_name_convert = ('/opt/app/oracle/oradata/BEAST/datafile/', '/opt/app/oracle/oradata/BEAST/datafile/');
The first parameter in the source_file_name_convert refers to the location of the datafiles listed in the descriptor file while second location refers to the actual location of the files. Either way the result is the same.
Following command shows the use of move option and using a different name other than the non-CDB name during the PDB creation processes.
CREATE PLUGGABLE DATABASE pdbdev USING '/home/oracle/beast_non_cdb.xml' move;
At the end of the PDB creation it will be in mount mode. Do not open it until noncdb-to-pdb script is run.
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 BEAST                          MOUNTED
         5 PDBAPP1                        READ WRITE NO
7. Once the PDB is created switch to it and verify all relevant datafiles are copied. (Following outputs from PDB created with copy above).
SQL> alter session set container=beast;
Session altered.

SQL> show con_name

CON_NAME
------------------------------
BEAST

SQL> select name from v$datafile;

NAME
------------------------------------------------------------------------------------------------------
/opt/app/oracle/oradata/PARAKUM/65E1789F663C5A9DE0534D00A8C0A811/datafile/o1_mf_system_f90fmmrn_.dbf
/opt/app/oracle/oradata/PARAKUM/65E1789F663C5A9DE0534D00A8C0A811/datafile/o1_mf_sysaux_f90fmmt2_.dbf
/opt/app/oracle/oradata/PARAKUM/65E1789F663C5A9DE0534D00A8C0A811/datafile/o1_mf_undotbs1_f90fmmt3_.dbf
/opt/app/oracle/oradata/PARAKUM/65E1789F663C5A9DE0534D00A8C0A811/datafile/o1_mf_users_f90fmmt5_.dbf
8. Before opening run the noncdb-to-pdb script from within the newly created PDB
@?/rdbms/admin/noncdb_to_pdb.sql
9. Once the script finishes, open the PDB
SQL> alter pluggable database open;

Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         6 BEAST                          READ WRITE NO
10. Check alert log and PDB_PLUG_IN_VIOLATIONS view for any PDB violation during the opening. Finally backup the CDB with the newly created PDB.

Related Posts
Plugging a Non-CDB (pre-12c) into CDB Using Transportable DB (TDB) / Tablespaces (TTS)
Plugging a SE2 non-CDB as an EE PDB Using File Copying and Remote Link

Sunday, March 18, 2018

Flashback Primary DB in a Data Guard - PDB vs non-CDB vs CDB

This post shows the steps of recovering the standby after a PDB is flashback on the primary DB. Later on shows the same on a non-CDB and CDB. It's assumed that standby DB has flashback on.

Flashback a PDB in the primary CDB
12.2 introduced new features which allows creation of restore points at PDB level and then flashback an individual PDB without impacting the other PDBs or the CDB. Flashback a PDB that's plugged into a CDB in a data guard configuration would cause recovery at the standby to fail and terminate. This is because the standby PDB would have a higher SCN compared to PDB on primary that underwent a flashback. Steps below shows how to recover from this situation.
1. The flashback is done using a restore point. As such first create the restore point inside the PDB. Steps are same even if the restore point is a CDB restore point (i.e. when a restore point created in CDB is used to flashback a PDB)
SQL>  alter session set container=pdbapp1;

SQL> create restore point pdb_restore_point guarantee flashback database;

SQL> select con_id,scn,TIME,name from v$restore_point;

    CON_ID        SCN TIME                           NAME
---------- ---------- ------------------------------ ------------------
         5    5662626 27-FEB-18 15.06.47.000000000   PDB_RESTORE_POINT
2. If a DB is a CDB then application data would reside in a PDB. So it's safe to assume that restore points would be used to recover from user errors at PBD level than CDB level. To simulate some error such as accidental deletion of data from a table. Restore point is used to recover from this error.
sqlplus  asanga/asa@city7:1581/pdbapp1

SQL> select count(*) from a;

  COUNT(*)
----------
       100

SQL> truncate table a;

Table truncated.

SQL> select count(*) from a;

  COUNT(*)
----------
         0
3. Close the PDB and execute the flashback. Once complete open the PDB with resetlog option
SQL> alter session set container=pdbapp1;
Session altered.

SQL> show con_name

CON_NAME
------------------------------
PDBAPP1

SQL> alter pluggable database close;
Pluggable database altered.

SQL>  flashback pluggable database PDBAPP1 to restore point PDB_RESTORE_POINT;
Flashback complete.

SQL> alter pluggable database open resetlogs;
Pluggable database altered.

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         5 PDBAPP1                        READ WRITE NO
4. On the alert log of the primary DB following could be seen during the flashback.
PDBAPP1(5): flashback pluggable database PDBAPP1 to restore point PDB_RESTORE_POINT
2018-02-27T15:12:44.433139+00:00
PDBAPP1(5):Flashback Restore Start
PDBAPP1(5):Restore Flashback Pluggable Database PDBAPP1 (5) until change 5662627
PDBAPP1(5):Flashback Restore Complete
PDBAPP1(5):Flashback Media Recovery Start
2018-02-27T15:12:45.086123+00:00
PDBAPP1(5):Serial Media Recovery started
2018-02-27T15:12:45.233559+00:00
PDBAPP1(5):Recovery of Online Redo Log: Thread 1 Group 8 Seq 257 Reading mem 0
PDBAPP1(5):  Mem# 0: +DATA/PRODCDB/ONLINELOG/group_8.284.968237763
PDBAPP1(5):  Mem# 1: +FRA/PRODCDB/ONLINELOG/group_8.264.968237763
2018-02-27T15:12:45.245468+00:00
PDBAPP1(5):Incomplete Recovery applied until change 5662627 time 02/27/2018 15:06:47
PDBAPP1(5):Flashback Media Recovery Complete
PDBAPP1(5):Flashback Pluggable Database PDBAPP1 (5) recovered until change 5662627
PDBAPP1(5):Completed:  flashback pluggable database PDBAPP1 to restore point PDB_RESTORE_POINT
5. On the standby DB's alert log following could be seen. Note the SCN number mentioned on the standby alert log for the PDB is same as the SCN mentioned in primary. Another point to note is that, flashback of a PDB on primary doesn't affect other PDBs in primary but it impacts the entire standby as recovery is stopped. This means that flashback a single PDB on primary could stop recovery of the entire standby until standby PDB is flashback to a state where it can apply redo.
2018-02-27T16:47:45.999901+00:00
(5):Recovery of pluggable database PDBAPP1 aborted due to pluggable database open resetlog marker.
(5):To continue recovery, restore all data files for this PDB to checkpoint SCN lower than 5662627, or timestamp before 02/27/2018 15:06:47, and restart recovery
MRP0: Background Media Recovery terminated with error 39874
2018-02-27T16:47:46.008223+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_3398.trc:
ORA-39874: Pluggable Database PDBAPP1 recovery halted
ORA-39873: Restore all data files to a checkpoint SCN lower than 5662627.
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Recovery stopped due to failure in applying recovery marker (opcode 17.46).
Datafiles are recovered to a consistent state at change 5663609 but controlfile could be ahead of datafiles.
2018-02-27T16:47:46.295066+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_3398.trc:
ORA-39874: Pluggable Database PDBAPP1 recovery halted
ORA-39873: Restore all data files to a checkpoint SCN lower than 5662627.
2018-02-27T16:47:46.402997+00:00
MRP0: Background Media Recovery process shutdown (stbycdb)
The data guard broker configuration will show an error status and standby database will show redo apply has stopped.
DGMGRL> show configuration

Configuration - dg12c2

  Protection Mode: MaxAvailability
  Members:
  prodcdb - Primary database
    stbycdb - Physical standby database
      Error: ORA-16810: multiple errors or warnings detected for the member

Fast-Start Failover: DISABLED

Configuration Status:
ERROR   (status updated 5658 seconds ago)

DGMGRL> show database stbycdb

Database - stbycdb

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 0 seconds ago)
  Apply Lag:          1 minute 9 seconds (computed 0 seconds ago)
  Average Apply Rate: 5.00 KByte/s
  Real Time Query:    OFF
  Instance(s):
    stbycdb

  Database Error(s):
    ORA-16766: Redo Apply is stopped

  Database Warning(s):
    ORA-16853: apply lag has exceeded specified threshold

Database Status:
ERROR
6. To recover from this error, flashback the standby PDB to SCN lower than the the primary PDB. In a non-CDB (and in CDB) this value is obtained from the RESETLOGS_CHANGE# column in v$database view. But in CDBs this column is updated only at CDB level. If the CDB doesn't under go a resetlog then this column is not updated with the resetlog_change#. Querying within the PDB also has no effect, as that too will reflect the resetlog_change# shown at the CDB level. In this case the CDB didn't under go any resetlog so querying the v$database inside the PDB shows the following.
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       MOUNTED
         5 PDBAPP1                        MOUNTED

SQL> alter session set container=pdbapp1;
Session altered.

SQL> select resetlogs_change# from v$database;

RESETLOGS_CHANGE#
-----------------
                1
There are two places that could be used to obtain the SCN number to flashback to. First one is the alert log as highlighted above. Second place is INCARNATION_SCN column in the v$pdb_incarnation view in the primary PDB. The Oracle reference doc gives the description for INCARNATION_SCN column as "The SCN to flashback or recover to for this PDB incarnation". During testing it was found that SCN shown on the alert log is same as the one shown in v$pdb_incarnation.INCARNATION_SCN.
SQL> select incarnation_scn from v$pdb_incarnation where status='CURRENT';

INCARNATION_SCN
---------------
        5662627
7. Flashback the PDB at standby to a SCN number that is two less than the one shown in INCARNATION_SCN (INCARNATION_SCN - 2). If the PDB was open for read only then close the PDB and have it in the mount state before the flashback.
SQL> flashback pluggable database to scn 5662625;
Flashback complete.
Check the alert log for any issues. Following could be seen on the standby alert log during PDB flashback
PDBAPP1(5):flashback pluggable database to scn 5662625
2018-02-27T16:51:42.113608+00:00
PDBAPP1(5):Flashback Restore Start
PDBAPP1(5):Restore Flashback Pluggable Database PDBAPP1 (5) until change 5659443
PDBAPP1(5):Flashback Restore Complete
PDBAPP1(5):Completed: flashback pluggable database to scn 5662625
8. Start the redo apply and check the DG broker and standby database status
DGMGRL> edit database stbycdb set state='APPLY-ON';
Succeeded.

DGMGRL> show configuration

Configuration - dg12c2

  Protection Mode: MaxAvailability
  Members:
  prodcdb - Primary database
    stbycdb - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 26 seconds ago)

DGMGRL> show database stbycdb

Database - stbycdb

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 1 second ago)
  Apply Lag:          0 seconds (computed 1 second ago)
  Average Apply Rate: 66.00 KByte/s
  Real Time Query:    OFF
  Instance(s):
    stbycdb

Database Status:
SUCCESS
This conclude the first part of the post, flashback a PDB in a data guard.
As mentioned earlier the SCN to flashback the PDB at standby could be found at alert log and v$pdb_incarnation. Each time the PDB under goes a resetlog the incarnation goes up. So it's important get the SCN from the current incarnation. Output below is a new PDB (also called PDBAPP1). When the primary PDB is flashback the standby alert log has the following
2018-03-14T18:28:58.891103+00:00
(4):Recovery of pluggable database PDBAPP1 aborted due to pluggable database open resetlog marker.
(4):To continue recovery, restore all data files for this PDB to checkpoint SCN lower than 9555922, or timestamp before 03/14/2018 16:53:35, and restart recovery
MRP0: Background Media Recovery terminated with error 39874
2018-03-14T18:28:58.897371+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_10568.trc:
ORA-39874: Pluggable Database PDBAPP1 recovery halted
ORA-39873: Restore all data files to a checkpoint SCN lower than 9555922.
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Recovered data files to a consistent state at change 9556551
2018-03-14T18:28:59.052367+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_10568.trc:
ORA-39874: Pluggable Database PDBAPP1 recovery halted
ORA-39873: Restore all data files to a checkpoint SCN lower than 9555922.
2018-03-14T18:28:59.154425+00:00
MRP0: Background Media Recovery process shutdown (stbycdb)
On v$pdb_incarnation view at primary
SQL> select * from v$pdb_incarnation;

DB_INCARNATION# PDB_INCARNATION# STATUS  INCARNATION_SCN INCARNATI BEGIN_RESETLOGS_SCN BEGIN_RES END_RESETLOGS_SCN END_RESET PRIOR_DB_INCARNATION# PRIOR_PD FLA     CON_ID
--------------- ---------------- ------- --------------- --------- ------------------- --------- ----------------- --------- --------------------- -------- --- ----------
              1                3 CURRENT         9555922 14-MAR-18             9556548 14-MAR-18           9556548 14-MAR-18                     1 0        YES          4
              1                0 PARENT                1 19-JAN-18                   1 19-JAN-18                 1 19-JAN-18                     0          YES          4
When the PDB is flashback again on primary, the standby alert log and the v$pdb_incarnation view at primary
(4):Recovery of pluggable database PDBAPP1 aborted due to pluggable database open resetlog marker.
(4):To continue recovery, restore all data files for this PDB to checkpoint SCN lower than 9797566, or timestamp before 03/15/2018 10:06:43, and restart recovery
MRP0: Background Media Recovery terminated with error 39874
2018-03-15T11:41:57.572285+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_11330.trc:
ORA-39874: Pluggable Database PDBAPP1 recovery halted
ORA-39873: Restore all data files to a checkpoint SCN lower than 9797566.
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Recovery stopped due to failure in applying recovery marker (opcode 17.46).
Datafiles are recovered to a consistent state at change 9797804 but controlfile could be ahead of datafiles.
2018-03-15T11:41:57.850051+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_11330.trc:
ORA-39874: Pluggable Database PDBAPP1 recovery halted
ORA-39873: Restore all data files to a checkpoint SCN lower than 9797566.
2018-03-15T11:41:57.953757+00:00
MRP0: Background Media Recovery process shutdown (stbycdb)

DB_INCARNATION# PDB_INCARNATION# STATUS  INCARNATION_SCN INCARNATI BEGIN_RESETLOGS_SCN BEGIN_RES END_RESETLOGS_SCN END_RESET PRIOR_DB_INCARNATION# PRIOR_PD FLA     CON_ID
--------------- ---------------- ------- --------------- --------- ------------------- --------- ----------------- --------- --------------------- -------- --- ----------
              1                4 CURRENT         9797566 15-MAR-18             9797801 15-MAR-18           9797801 15-MAR-18                     1 3        YES          4
              1                3 PARENT          9555922 14-MAR-18             9556548 14-MAR-18           9556548 14-MAR-18                     1 0        YES          4
              1                0 PARENT                1 19-JAN-18                   1 19-JAN-18                 1 19-JAN-18                     0          YES          4
Flashback PDB Created With standbys=none on Primary
If the PDB was created with standbys=none, then there's nothing to be done on the standby if the PDB goes through a flashback.



Flashback Primary DB (non-CDB)
These steps shows a flashback of a non-CDB primary in a data guard configuration. The database version is 11.2.0.4 and data guard configuration is similar to an earlier post (single instance with Oracle restart).

1. Create a restore point on the primary to be used for the flashback.
SQL>  create restore point first_restore guarantee flashback database;
Restore point created.

SQL> select scn,TIME,name from v$restore_point;

       SCN TIME                                               NAME
---------- -------------------------------------------------- -------------
   6864231 27-FEB-18 03.10.15.000000000 PM                    FIRST_RESTORE
2. Simulate a user error as before
SQL> conn asanga/asa
Connected.
SQL> select count(*) from ins;

  COUNT(*)
----------
     17223

SQL> truncate table ins;
Table truncated.

SQL> select count(*) from ins;

  COUNT(*)
----------
         0
3. Start the primary in mount mode and issue the flashback command. Once flashback is complete open the primary with resetlogs
SQL> shutdown immediate;
SQL> startup mount;

SQL> FLASHBACK DATABASE TO RESTORE POINT FIRST_RESTORE;
Flashback complete.

SQL> alter database open resetlogs;
4. Select the resetlogs_change# from the primary DB
SQL>  select resetlogs_change# from v$database;

RESETLOGS_CHANGE#
-----------------
          6864233
5. Check the user error is corrected
conn asanga/asa
SQL> select count(*) from ins;

  COUNT(*)
----------
     17223
6. At this stage the redo applied on standby would have been stopped. Following could be seen on the standby alert log. Highlighted is the SCN where primary underwent resetlog.
Tue Feb 27 16:08:08 2018
RFS[14]: Assigned to RFS process 3828
RFS[14]: New Archival REDO Branch: 969203936 Current: 967399936
RFS[14]: Selected log 9 for thread 1 sequence 1 dbid 376209786 branch 969203936
A new recovery destination branch has been registered
RFS[14]: Standby in the future of new recovery destinationBranch(resetlogs_id) 969203936
Incomplete Recovery SCN: 6864715
Resetlogs SCN: 6864233
Standby Became Primary SCN: 4218629
Flashback database to SCN 4218629 to follow new branch
Flashback database to SCN 4218629 to follow new branch
RFS[14]: New Archival REDO Branch(resetlogs_id): 969203936  Prior: 967399936
RFS[14]: Archival Activation ID: 0x16b5779b Current: 0x169a808c
RFS[14]: Effect of primary database OPEN RESETLOGS
RFS[14]: Managed Standby Recovery process is active
RFS[14]: Incarnation entry added for Branch(resetlogs_id): 969203936 (stdby)
...
Tue Feb 27 16:08:09 2018
MRP0: Incarnation has changed! Retry recovery...
Errors in file /opt/app/oracle/diag/rdbms/stdby/stdby/trace/stdby_pr00_19722.trc:
ORA-19906: recovery target incarnation changed during recovery
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
...
Tue Feb 27 16:08:10 2018
Managed Standby Recovery starting Real Time Apply
Warning: Recovery target destination is in a sibling branch
of the controlfile checkpoint. Recovery will only recover
changes to datafiles.
Datafile 1 (ckpscn 6864715) is orphaned on incarnation#=2
MRP0: Detected orphaned datafiles!
Recovery will possibly be retried after flashback...
Errors in file /opt/app/oracle/diag/rdbms/stdby/stdby/trace/stdby_pr00_3859.trc:
ORA-19909: datafile 1 belongs to an orphan incarnation
ORA-01110: data file 1: '+DATA/stdby/datafile/system.258.964883351'
Managed Standby Recovery not using Real Time Apply
Recovery Slave PR00 previously exited with exception 19909
Archived Log entry 4437 added for thread 1 sequence 175 rlc 967399936 ID 0x169a808c dest 3:
Changing standby controlfile to MAXIMUM AVAILABILITY level
RFS[15]: Selected log 10 for thread 1 sequence 4 dbid 376209786 branch 969203936
Tue Feb 27 16:08:12 2018
Archived Log entry 4438 added for thread 1 sequence 3 ID 0x16b5779b dest 1:
Tue Feb 27 16:08:31 2018
MRP0: Background Media Recovery process shutdown (stdby)
7. The data guard broker would show the following status
DGMGRL> show configuration

Configuration - fz_db_dg

  Protection Mode: MaxAvailability
  Databases:
    prod  - Primary database
    stdby - Physical standby database
      Error: ORA-16810: multiple errors or warnings detected for the database

Fast-Start Failover: DISABLED

Configuration Status:
ERROR

DGMGRL>  show database stdby

Database - stdby

  Role:            PHYSICAL STANDBY
  Intended State:  APPLY-ON
  Transport Lag:   (unknown)
  Apply Lag:       0 seconds (computed 0 seconds ago)
  Apply Rate:      137.00 KByte/s
  Real Time Query: OFF
  Instance(s):
    stdby

  Database Error(s):
    ORA-16700: the standby database has diverged from the primary database
    ORA-16766: Redo Apply is stopped

Database Status:
ERROR
8. Flashback the standby to the SCN that is (RESETLOGS_CHANGE# -2 ). If the standby was open in read only mode then close and start it in mount mode.
SQL> flashback database to scn 6864231;
Flashback complete.
On standby alert log following could be seen
Tue Feb 27 16:11:46 2018
Media Recovery Log +FRA/stdby/archivelog/2018_02_27/thread_1_seq_175.459.969206891
Incomplete Recovery applied until change 6864231 time 02/27/2018 15:10:15
Flashback Media Recovery Complete
Setting recovery target incarnation to 3
Completed: flashback database to scn 6864230
9. Enable redo apply and check the data guard broker status
DGMGRL> edit database stdby set state='APPLY-ON';
Succeeded.

DGMGRL> show configuration

Configuration - fz_db_dg

  Protection Mode: MaxAvailability
  Databases:
    prod  - Primary database
    stdby - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS

DGMGRL> show database stdby ;

Database - stdby

  Role:            PHYSICAL STANDBY
  Intended State:  APPLY-ON
  Transport Lag:   0 seconds (computed 0 seconds ago)
  Apply Lag:       0 seconds (computed 0 seconds ago)
  Apply Rate:      0 Byte/s
  Real Time Query: OFF
  Instance(s):
    stdby

Database Status:
SUCCESS

Flashback Primary DB (CDB)
When the primary CDB is flashback all PDBs pluged to it also under go the flashback. Steps are similar to that of non-CDB except for few key considerations specific to CDB. These are mentioned at the end of this section.
1. Currently CDB has two PDBs plugged
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDBDEV                         READ WRITE NO
         4 PDBAPP1                        READ WRITE NO
2. Create a CDB restore point
SQL> create restore point first_restore guarantee flashback database;

Restore point created.

SQL> select scn,TIME,name,PDB_RESTORE_POINT from  v$restore_point;

       SCN TIME                           NAME                 PDB
---------- ------------------------------ -------------------- ---
  10050579 15-MAR-18 16.04.22.000000000   FIRST_RESTORE        NO
3. Similar to before simulate a failure to test the flashback.
4. Put the primary CDB into mount mode and issue the flashback command
startup mount;

SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       MOUNTED
         3 PDBDEV                         MOUNTED
         4 PDBAPP1                        MOUNTED

SQL> FLASHBACK DATABASE TO RESTORE POINT FIRST_RESTORE;

Flashback complete.

SQL> alter database open resetlogs;
4. Get the resetlogs_change# from primary CDB after opening
SQL> select resetlogs_change# from v$database;

RESETLOGS_CHANGE#
-----------------
         10050581
5. Similar to previous cases the redo apply on standby will stop. Following could be seen on alert log.
A new recovery destination branch has been registered
RFS[7]: Standby in the future of new recovery destinationBranch(resetlogs_id) 970848377
Incomplete Recovery SCN: 10050343
Resetlogs SCN: 10050581

Standby Became Primary SCN: 10049187

Flashback database to SCN 10049187 to follow new branch
Flashback database to SCN 10049187 to follow new branch
RFS[7]: New Archival REDO Branch(resetlogs_id): 970848377  Prior: 970844177
RFS[7]: Archival Activation ID: 0xb0f552e2 Current: 0xb0f5fd63
RFS[7]: Effect of primary database OPEN RESETLOGS
RFS[7]: Managed Standby Recovery process is active
2018-03-15T17:40:26.153911+00:00
RFS[7]: Incarnation entry added for Branch(resetlogs_id): 970848377 (stbycdb)
2018-03-15T17:40:26.170006+00:00
Setting recovery target incarnation to 3
2018-03-15T17:40:26.220855+00:00
MRP0: Incarnation has changed! Retry recovery...
2018-03-15T17:40:26.228354+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_3093.trc:
ORA-19906: recovery target incarnation changed during recovery
Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
Recovered data files to a consistent state at change 10050799
2018-03-15T17:40:26.525958+00:00
...
2018-03-15T17:40:32.758453+00:00
Changing standby controlfile to MAXIMUM AVAILABILITY level
RFS[6]: Selected log 9 for T-1.S-4 dbid 2963914998 branch 970848377
2018-03-15T17:40:32.943141+00:00
Archived Log entry 36 added for T-1.S-3 ID 0xb0f552e2 LAD:1
2018-03-15T17:40:48.131861+00:00
MRP0: Background Media Recovery process shutdown (stbycdb)
6. Data guard broker shows error status
DGMGRL> show configuration

Configuration - dg12c2

  Protection Mode: MaxAvailability
  Members:
  prodcdb - Primary database
    stbycdb - Physical standby database
      Error: ORA-16810: multiple errors or warnings detected for the member

Fast-Start Failover: DISABLED

Configuration Status:
ERROR   (status updated 5670 seconds ago)

DGMGRL> show database stbycdb

Database - stbycdb

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      (unknown)
  Apply Lag:          0 seconds (computed 0 seconds ago)
  Average Apply Rate: 7.00 KByte/s
  Real Time Query:    OFF
  Instance(s):
    stbycdb

  Database Error(s):
    ORA-16700: the standby database has diverged from the primary database
    ORA-16766: Redo Apply is stopped

  Database Warning(s):
    ORA-16856: transport lag could not be determined

Database Status:
ERROR
7. To resolve the issue start standby CDB in mount mode and flashback to SCN value of (RESETLOGS_CHANGE# - 2)
SQL> flashback database to scn 10050579;
Flashback complete.
Monitor the alert log for any issues. In this case flashback was able to go across creation and dropping of a tablespace
2018-03-15T17:44:41.398074+00:00
flashback database to scn 10050579
2018-03-15T17:44:41.879824+00:00
Flashback Restore Start
Flashback: created tablespace #5: 'TEST' of pdb #4 with key index #-546742896 in the controlfile.
Flashback: created OFFLINE file 'UNNAMED00152' for tablespace #5 of pdb #4 in the controlfile.
Filename was:
'+DATA/STBYCDB/67632B96894E2116E0535500A8C05DA5/DATAFILE/test.268.970853853' when dropped.
File will have to be restored from a backup and recovered.
2018-03-15T17:44:42.444166+00:00
Flashback: deleted datafile #152 in tablespace #5 of pdb #4 from control file.
Flashback: dropped tablespace #5: 'TEST' of pdb #4 from the control file.
Flashback Restore Complete
Flashback Media Recovery Start
2018-03-15T17:44:42.582223+00:00
Setting recovery target incarnation to 2
2018-03-15T17:44:42.629691+00:00
 Started logmerger process
2018-03-15T17:44:43.352732+00:00
Parallel Media Recovery started with 4 slaves
2018-03-15T17:44:43.577325+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_15/thread_1_seq_30.281.970854029
2018-03-15T17:44:43.778830+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_15/thread_1_seq_31.326.970854029
2018-03-15T17:44:43.939967+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_15/thread_1_seq_32.327.970854029
(4):Flashback recovery: Added file #152 to control file as OFFLINE and 'UNNAMED00152'
(4):because it was dropped during the flashback interval
(4):or it was added during flashback media recovery.
(4):File was originally created as:
(4):'+DATA/PRODCDB/67632B96894E2116E0535500A8C05DA5/DATAFILE/test.282.970848211'
(4):File will have to be restored from a backup or
(4):recreated using ALTER DATABASE CREATE DATAFILE command,
(4):and the file has to be onlined and recovered.
(4):Recovery deleting file #152:'/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00152' from controlfile.
(4):Recovery dropped tablespace 'TEST'
2018-03-15T17:44:44.498297+00:00
Incomplete Recovery applied until change 10050580 time 03/15/2018 16:04:22
2018-03-15T17:44:44.504472+00:00
Flashback Media Recovery Complete
2018-03-15T17:44:44.945998+00:00
Setting recovery target incarnation to 3
Completed: flashback database to scn 10050579
8. Start the redo apply and verify DG broker change
DGMGRL> edit database stbycdb set state='apply-on';
Succeeded.

DGMGRL> show configuration

Configuration - dg12c2

  Protection Mode: MaxAvailability
  Members:
  prodcdb - Primary database
    stbycdb - Physical standby database

Fast-Start Failover: DISABLED

Configuration Status:
SUCCESS   (status updated 5684 seconds ago)

DGMGRL> show database stbycdb

Database - stbycdb

  Role:               PHYSICAL STANDBY
  Intended State:     APPLY-ON
  Transport Lag:      0 seconds (computed 0 seconds ago)
  Apply Lag:          0 seconds (computed 0 seconds ago)
  Average Apply Rate: 33.00 KByte/s
  Real Time Query:    OFF
  Instance(s):
    stbycdb

Database Status:
SUCCESS

Primary CDB has PDB created with standbys=none
On 12.2 PDBs could be created only on primary DB without datafiles of the PDB being created on the standby. On standby the PDB will have recovery status disabled
SQL> select name,recovery_status from v$pdbs;

NAME       RECOVERY
---------- --------
PDB$SEED   ENABLED
PDBAPP1    ENABLED
PDBDEV     DISABLED

SQL> alter session set container=pdbdev;

SQL> select file#,name from v$datafile;

     FILE# NAME
---------- --------------------------------------------------------------------------------
       183 /opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00183
       184 /opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00184
       185 /opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00185
       186 /opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00186
The steps to flashback the CDB and then to recover the standby CDB is same as with non-CDB.

1. Create a restore point and put the CDB into mount mode and flashback the database followed by open resetlogs.
SQL> create restore point first_restore guarantee flashback database;
Restore point created.


SQL> select scn,TIME,name,PDB_RESTORE_POINT from  v$restore_point;

       SCN TIME                           NAME                           PDB
---------- ------------------------------ ------------------------------ ---
  10537244 16-MAR-18 13.22.44.000000000   FIRST_RESTORE                  NO

SQL> startup force mount;

SQL> SQL> FLASHBACK DATABASE TO RESTORE POINT FIRST_RESTORE;
Flashback complete.

SQL> alter database open resetlogs;
Database altered.
2. Standby redo apply will stop due to diverging from the primary. The unanemd files mentioned are the files of the PDB with disabled recovery.
2018-03-16T14:59:57.788003+00:00
Deleted Oracle managed file +FRA/STBYCDB/ARCHIVELOG/2018_03_16/thread_0_seq_0.314.970930797
2018-03-16T14:59:58.485425+00:00
RFS[5]: Assigned to RFS process (PID:21851)
RFS[5]: New Archival REDO Branch: 970925153 Current: 970913416
Primary database is in MAXIMUM AVAILABILITY mode
Changing standby controlfile to RESYNCHRONIZATION level
Standby controlfile consistent with primary
RFS[5]: Selected log 9 for T-1.S-3 dbid 2963914998 branch 970925153
2018-03-16T14:59:59.108930+00:00
RFS[6]: Assigned to RFS process (PID:21854)
RFS[6]: Selected log 10 for T-1.S-2 dbid 2963914998 branch 970925153
A new recovery destination branch has been registered
RFS[6]: Standby in the future of new recovery destinationBranch(resetlogs_id) 970925153
Incomplete Recovery SCN: 10537681
Resetlogs SCN: 10537246

Standby Became Primary SCN: 10516843

Flashback database to SCN 10516843 to follow new branch
Flashback database to SCN 10516843 to follow new branch
...
2018-03-16T15:00:03.991683+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_m000_21894.trc:
ORA-01110: data file 183: '/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00183'
ORA-01565: error in identifying file '/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00183'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2018-03-16T15:00:04.365763+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_m000_21894.trc:
ORA-01110: data file 184: '/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00184'
ORA-01565: error in identifying file '/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00184'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2018-03-16T15:00:04.805232+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_m000_21894.trc:
ORA-01110: data file 185: '/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00185'
ORA-01565: error in identifying file '/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00185'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2018-03-16T15:00:05.209166+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_m000_21894.trc:
ORA-01110: data file 186: '/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00186'
ORA-01565: error in identifying file '/opt/app/oracle/product/12.2.0/dbhome_1/dbs/UNNAMED00186'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
Checker run found 8 new persistent data failures
...
MRP0: Background Media Recovery process shutdown (stbycdb)
3. Get the resetlogs_change# from primary
SQL> select resetlogs_change# from v$database;

RESETLOGS_CHANGE#
-----------------
         10537246
and flashback the standby DB (same as with a CDB).
SQL> flashback database to scn 10537244;
Flashback complete.
During the flashback warnings will be issued for offline data files which could be ignored.
2018-03-16T15:03:49.487890+00:00
flashback database to scn 10537244
2018-03-16T15:03:49.840095+00:00
Flashback Restore Start
Flashback Restore Complete
Flashback Media Recovery Start
2018-03-16T15:03:50.286960+00:00
Setting recovery target incarnation to 4
2018-03-16T15:03:50.341298+00:00
 Started logmerger process
2018-03-16T15:03:51.035344+00:00
Parallel Media Recovery started with 4 slaves
2018-03-16T15:03:51.102859+00:00
Warning: Datafile 183 (+DATA/PRODCDB/6787CB93C0372211E0535500A8C052D4/DATAFILE/system.276.970921923) is offline during full database recovery and will not be recovered
Warning: Datafile 184 (+DATA/PRODCDB/6787CB93C0372211E0535500A8C052D4/DATAFILE/sysaux.275.970921923) is offline during full database recovery and will not be recovered
Warning: Datafile 185 (+DATA/PRODCDB/6787CB93C0372211E0535500A8C052D4/DATAFILE/undotbs1.277.970921923) is offline during full database recovery and will not be recovered
2018-03-16T15:03:51.270043+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_16/thread_1_seq_45.317.970930803
2018-03-16T15:03:51.510617+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_16/thread_1_seq_46.330.970930807
2018-03-16T15:03:51.688125+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_16/thread_1_seq_47.321.970930807
2018-03-16T15:03:51.840959+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_16/thread_1_seq_48.287.970930807
2018-03-16T15:03:51.987769+00:00
Incomplete Recovery applied until change 10537245 time 03/16/2018 13:22:45
2018-03-16T15:03:51.995117+00:00
Flashback Media Recovery Complete
2018-03-16T15:03:52.385714+00:00
Setting recovery target incarnation to 5
2018-03-16T15:03:52.565357+00:00
Completed: flashback database to scn 10537244
4. Finally enable redo apply.
DGMGRL> edit database stbycdb set state='apply-on';
Succeeded.
On standby alert log
2018-03-16T15:04:40.487316+00:00
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT  NODELAY
2018-03-16T15:04:40.495896+00:00
Attempt to start background Managed Standby Recovery process (stbycdb)
Starting background process MRP0
2018-03-16T15:04:40.548175+00:00
MRP0 started with pid=75, OS id=22252
2018-03-16T15:04:40.553249+00:00
MRP0: Background Managed Standby Recovery process started (stbycdb)
2018-03-16T15:04:45.608480+00:00
 Started logmerger process
2018-03-16T15:04:45.819166+00:00
Managed Standby Recovery starting Real Time Apply
2018-03-16T15:04:46.797164+00:00
Parallel Media Recovery started with 4 slaves
2018-03-16T15:04:46.866458+00:00
Warning: Datafile 183 (+DATA/PRODCDB/6787CB93C0372211E0535500A8C052D4/DATAFILE/system.276.970921923) is offline during full database recovery and will not be recovered
Warning: Datafile 184 (+DATA/PRODCDB/6787CB93C0372211E0535500A8C052D4/DATAFILE/sysaux.275.970921923) is offline during full database recovery and will not be recovered
Warning: Datafile 185 (+DATA/PRODCDB/6787CB93C0372211E0535500A8C052D4/DATAFILE/undotbs1.277.970921923) is offline during full database recovery and will not be recovered
2018-03-16T15:04:46.956819+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_16/thread_1_seq_1.278.970930809
2018-03-16T15:04:47.118435+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_16/thread_1_seq_2.314.970930803
2018-03-16T15:04:47.560091+00:00
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT  NODELAY
2018-03-16T15:04:48.937435+00:00
Media Recovery Log +FRA/STBYCDB/ARCHIVELOG/2018_03_16/thread_1_seq_3.331.970930811
2018-03-16T15:04:52.905396+00:00
Media Recovery Waiting for thread 1 sequence 4 (in transit)
2018-03-16T15:04:52.920078+00:00
Recovery of Online Redo Log: Thread 1 Group 10 Seq 4 Reading mem 0
  Mem# 0: +DATA/STBYCDB/ONLINELOG/group_10.283.970922707
  Mem# 1: +FRA/STBYCDB/ONLINELOG/group_10.324.970922711

Issues noticed
This test (CDB flashback when a PDB is having recovery disabled) was done fwe times. At one time the recovery start failed on standby after the flashback. The issue was case an ora-600 error.
2018-03-15T16:34:18.223019+00:00
Managed Standby Recovery starting Real Time Apply2018-03-15T16:34:19.670057+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_28192.trc  (incident=34209) (PDBNAME=CDB$ROOT):
ORA-00600: internal error code, arguments: [kcvaor_pdb_3], [148], [0], [0], [1], [0], [], [], [], [], [], []
Incident details in: /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/incident/incdir_34209/stbycdb_pr00_28192_i34209.trc
2018-03-15T16:34:28.897393+00:00
Use ADRCI or Support Workbench to package the incident.
See Note 411.1 at My Oracle Support for error and packaging details.
2018-03-15T16:34:28.899991+00:00
MRP0: Background Media Recovery terminated with error 600
2018-03-15T16:34:28.901477+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_pr00_28192.trc:
ORA-00600: internal error code, arguments: [kcvaor_pdb_3], [148], [0], [0], [1], [0], [], [], [], [], [], []
Managed Standby Recovery not using Real Time Apply
2018-03-15T16:34:28.952661+00:00
Completed: ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT  NODELAY
2018-03-15T16:34:29.181019+00:00
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_mrp0_28186.trc  (incident=34201) (PDBNAME=CDB$ROOT):
ORA-00600: internal error code, arguments: [kcvaor_pdb_3], [148], [0], [0], [1], [0], [], [], [], [], [], []
Incident details in: /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/incident/incdir_34201/stbycdb_mrp0_28186_i34201.trc
...
Errors in file /opt/app/oracle/diag/rdbms/stbycdb/stbycdb/trace/stbycdb_mrp0_28186.trc:
ORA-00600: internal error code, arguments: [kcvaor_pdb_3], [148], [0], [0], [1], [0], [], [], [], [], [], []
2018-03-15T16:34:32.201983+00:00
MRP0: Background Media Recovery process shutdown (stbycdb)
The trace file suggest issue is related to incarnation but none of the usual remedies worked.
cat stbycdb_pr00_28192.trc
Media Recovery apply resetlogs offline range for datafile 1, incarnation : 0
Media Recovery apply resetlogs offline range for datafile 3, incarnation : 0
Media Recovery apply resetlogs offline range for datafile 5, incarnation : 0
Media Recovery apply resetlogs offline range for datafile 7, incarnation : 0
Media Recovery apply resetlogs offline range for datafile 121, incarnation : 0
ora-600 are internal Oracle internal errors and ora-600 error look up tool didn't have any information on this (153788.1).
Other time the flashback on the standby would fail due to datafiles belonging to orphan incarnations.
RMAN> flashback database to scn 10545305;

Starting flashback at 16-MAR-18
using channel ORA_DISK_1
starting media recovery
media recovery failed
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of flashback command at 03/16/2018 15:49:16
ORA-00283: recovery session canceled due to errors
ORA-38770: FLASHBACK DATABASE failed during recovery.
ORA-19909: datafile 148 belongs to an orphan incarnation
ORA-01110: data file 148: '+DATA/STBYCDB/67632B96894E2116E0535500A8C05DA5/DATAFILE/system.282.970920351'
Refer MOS 1509932.1 for resolving such cases.

Sunday, October 15, 2017

Upgrading RAC from 12.1.0.2 to 12.2.0.1 - Database (non-CDB and CDB)

After upgrading the GI from 12.1.0.2 to 12.2.0.1 the next phase is to upgrade the database software and the actual databases. This cluster has two standard edition 2 RAC databases. One is a non-CDB while other is a CDB with just one PDB. The post shows upgrade of them of both. First is the database software upgrade. This is done as an out of place upgrade. Before upgrade commence run cluvfy with database pre-upgrade option.
[oracle@rhel12c1 ~]$ /opt/app/12.2.0/grid/bin/cluvfy stage  -pre dbinst -upgrade -src_dbhome /opt/app/oracle/product/12.1.0/dbhome_2 -dest_dbhome /opt/app/oracle/product/12.2.0/dbhome_1 -dest_version 12.2.0.1.0
12.2 has introduced a new OS group for RAC management. Add the group to oracle user, keeping the user equivalence across all nodes.
# groupadd racdba
# usermod -g oinstall -G dba,oper,asmdba,asmoper,asmadmin,backupdba,dgdba,kmdba,racdba oracle
# id oracle
uid=500(oracle) gid=502(oinstall) groups=502(oinstall),501(dba),503(oper),504(asmoper),505(asmdba),506(asmadmin),507(backupdba),508(dgdba),509(kmdba),510(racdba)
Run 12.2 installer and select software only install option.

Upgrading non-CDB

As mentioned earlier this cluster has two databases, non-CDB and CDB. This section shows the upgrading of the non-CDB. Before the upgrade make sure the sga_target is at least 2068MB. This requirement is not flagged in orachk or any other pre-req checks. If sga_target is lower than this, the upgrade would fail.
The component version and status before the upgrade is given below
COMP_ID    COMP_NAME                           VERSION    STATUS
---------- ----------------------------------- ---------- --------
CATALOG    Oracle Database Catalog Views       12.1.0.2.0 VALID
CATPROC    Oracle Database Packages and Types  12.1.0.2.0 VALID
RAC        Oracle Real Application Clusters    12.1.0.2.0 VALID
XDB        Oracle XML Database                 12.1.0.2.0 VALID
OWM        Oracle Workspace Manager            12.1.0.2.0 VALID
CONTEXT    Oracle Text                         12.1.0.2.0 VALID



Run the preupgrade.jar, the new pre-upgrade check tool available with 12.2 for pre-upgrade checks.
[oracle@rhel12c1 ~]$ $ORACLE_HOME/jdk/bin/java -jar preupgrade.jar TERMINAL
Report generated by Oracle Database Pre-Upgrade Information Tool Version
12.2.0.1.0

Upgrade-To version: 12.2.0.1.0

=======================================
Status of the database prior to upgrade
=======================================

      Database Name:  STD12C1
     Container Name:  STD12C1
       Container ID:  0
            Version:  12.1.0.2.0
         Compatible:  12.1.0.2.0
          Blocksize:  8192
           Platform:  Linux x86 64-bit
      Timezone File:  18
  Database log mode:  NOARCHIVELOG
           Readonly:  FALSE
            Edition:  SE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  VALID
  Oracle Workspace Manager               [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID


==============
BEFORE UPGRADE
==============

  Run /preupgrade_fixups.sql to complete all
  of the BEFORE UPGRADE action items below marked with '(AUTOFIXUP)'.

  REQUIRED ACTIONS
  ================
   + Adjust TABLESPACE SIZES as needed.
                                                Auto      12.2.0.1.0
     Tablespace                        Size     Extend    Min Size    Action
     ----------                     ----------  --------  ----------  ------

     SYSAUX                             550 MB  ENABLED       667 MB  None
     SYSTEM                             700 MB  ENABLED       806 MB  None
     TEMP                                21 MB  ENABLED       150 MB  None
     UNDOTBS1                           230 MB  ENABLED       400 MB  None

     Note that 12.2.0.1.0 minimum sizes are estimates.
     If you plan to upgrade multiple pluggable databases concurrently,
     then you must ensure that the UNDO tablespace size is equal to at least
     the number of pluggable databases that you upgrade concurrently,
     multiplied by that minimum.  Failing to allocate sufficient space can
     cause the upgrade to fail.

   + (AUTOFIXUP) Empty the RECYCLEBIN immediately before database upgrade.

     The database contains 179 objects in the recycle bin.

     The recycle bin must be completely empty before database upgrade.

  RECOMMENDED ACTIONS
  ===================
   + Run 12.1.0.2.0 $ORACLE_HOME/rdbms/admin/utlrp.sql to recompile invalid
     objects.  You can view the individual invalid objects with

       SET SERVEROUTPUT ON;
       EXECUTE DBMS_PREUP.INVALID_OBJECTS;

     8 objects are INVALID.

     There should be no INVALID objects in SYS/SYSTEM or user schemas before
     database upgrade.

   + Review and remove any unnecessary EVENTS.

     The database contains events.

     There are events set that should be removed before upgrade, unless your
     application vendors and/or Oracle Support state differently.  Changes
     will need to be made in the spfile.

   + (AUTOFIXUP) Gather stale data dictionary statistics prior to database
     upgrade in off-peak time using:

      EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

     Dictionary statistics do not exist or are stale (not up-to-date).

     Dictionary statistics help the Oracle optimizer find efficient SQL
     execution plans and are essential for proper upgrade timing. Oracle
     recommends gathering dictionary statistics in the last 24 hours before
     database upgrade.

     For information on managing optimizer statistics, refer to the 12.1.0.2
     Oracle Database SQL Tuning Guide.

=============
AFTER UPGRADE
=============

  Run /postupgrade_fixups.sql to complete all
  of the AFTER UPGRADE action items below marked with '(AUTOFIXUP)'.

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
   + Upgrade the database time zone version using the DBMS_DST package.

     The database is using timezone datafile version 18 and the target
     12.2.0.1.0 database ships with timezone datafile version 26.

     Oracle recommends using the most recent timezone data.  For further
     information, refer to My Oracle Support Note 1585343.1.

   + (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
     command:

       EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

     Oracle recommends gathering dictionary statistics after upgrade.

     Dictionary statistics provide essential information to the Oracle
     optimizer to help it find efficient SQL execution plans. After a
     database upgrade, statistics need to be re-gathered as there can now be
     tables that have significantly changed during the upgrade or new tables
     that do not have statistics gathered yet.


Preupgrade generated files:
    /opt/app/oracle/cfgtoollogs/std12c1/preupgrade/preupgrade_fixups.sql
    /opt/app/oracle/cfgtoollogs/std12c1/preupgrade/postupgrade_fixups.sql
Run the pre-upgrade fixup
SQL> @/opt/app/oracle/cfgtoollogs/std12c1/preupgrade/preupgrade_fixups.sql

Executing Oracle PRE-Upgrade Fixup Script

Auto-Generated by:       Oracle Preupgrade Script
                         Version: 12.2.0.1.0 Build: 1
Generated on:            2017-09-19 16:31:13

For Source Database:     STD12C1
Source Database Version: 12.1.0.2.0
For Upgrade to Version:  12.2.0.1.0

                          Fixup
Check Name                Status  Further DBA Action
----------                ------  ------------------
purge_recyclebin          Passed  None
invalid_objects_exist     Failed  Manual fixup recommended.
underscore_events         Failed  Manual fixup recommended.
dictionary_stats          Passed  None

PL/SQL procedure successfully completed.
Once the pre-ugprade checks are fixed run dbua from the 12.2 Oracle home. Select the database for upgrade, in this case the non-CDB is selected.
Timezone is upgraded at the same time as database.
Upgrade summary
Upgrade progress
Upgrade completion summary
Run the postupgrade fixup script
SQL> @/opt/app/oracle/cfgtoollogs/std12c1/preupgrade/postupgrade_fixups.sql

Auto-Generated by:       Oracle Preupgrade Script
                         Version: 12.2.0.1.0 Build: 1
Generated on:            2017-09-19 16:35:42

For Source Database:     STD12C1
Source Database Version: 12.1.0.2.0
For Upgrade to Version:  12.2.0.1.0

                          Fixup
Check Name                Status  Further DBA Action
----------                ------  ------------------
old_time_zones_exist      Passed  None
post_dictionary           Passed  None
After the upgrade the DB components version and status
COMP_ID    COMP_NAME                           VERSION    STATUS
---------- ----------------------------------- ---------- --------
CATALOG    Oracle Database Catalog Views       12.2.0.1.0 VALID
CATPROC    Oracle Database Packages and Types  12.2.0.1.0 VALID
RAC        Oracle Real Application Clusters    12.2.0.1.0 VALID
XDB        Oracle XML Database                 12.2.0.1.0 VALID
OWM        Oracle Workspace Manager            12.2.0.1.0 VALID
CONTEXT    Oracle Text                         12.2.0.1.0 VALID
The database registry history added an entry for the upgrade
ACTION_TIME                    ACTION          NAMESPACE  VERSION            ID COMMENTS
------------------------------ --------------- ---------- ---------- ---------- ----------------------------------------
                               BOOTSTRAP       DATAPATCH  12.1.0.2              RDBMS_12.1.0.2.0DBPSU_LINUX.X64_161210
                               BOOTSTRAP       DATAPATCH  12.2.0.1              RDBMS_12.2.0.1.0_LINUX.X64_170125
19-SEP-17 05.18.47.947470 PM   VIEW INVALIDATE                          8289601 view invalidation
19-SEP-17 05.20.49.419414 PM   UPGRADE         SERVER     12.2.0.1.0            Upgraded from 12.1.0.2.0
Verify the timezone upgrade
SQL> select * from v$timezone_file;

FILENAME                VERSION     CON_ID
-------------------- ---------- ----------
timezlrg_26.dat              26          0
This SE2 DB had statspack installed. Upgrade the statspack to 12.2
SQL>@?/rdbms/admin/spup12102.sql
SQL>@?/rdbms/admin/spup12200.sql
The remote_listener parameter had the new scan name added to it automatically. It also included the old scan name as well.
remote_listener  string      prod-cluster-scan.rac.domain.net:1521, prod-cluster-scan.prod-cluster.rac.domain.net:1521
Finally upgrade the database compatibility parameter
SQL> alter system set compatible='12.2.0.1.0' scope=spfile sid='*';
Upgrading CDB

The component version and status on the CDB before the upgrade is as below
    CON_ID COMP_ID    COMP_NAME                           VERSION         STATUS
---------- ---------- ----------------------------------- --------------- ----------
         1 APEX       Oracle Application Express          4.2.5.00.08     VALID
         1 CATALOG    Oracle Database Catalog Views       12.1.0.2.0      VALID
         1 CATJAVA    Oracle Database Java Packages       12.1.0.2.0      VALID
         1 CATPROC    Oracle Database Packages and Types  12.1.0.2.0      VALID
         1 CONTEXT    Oracle Text                         12.1.0.2.0      VALID
         1 JAVAVM     JServer JAVA Virtual Machine        12.1.0.2.0      VALID
         1 ORDIM      Oracle Multimedia                   12.1.0.2.0      VALID
         1 OWM        Oracle Workspace Manager            12.1.0.2.0      VALID
         1 RAC        Oracle Real Application Clusters    12.1.0.2.0      VALID
         1 XDB        Oracle XML Database                 12.1.0.2.0      VALID
         1 XML        Oracle XDK                          12.1.0.2.0      VALID

         3 APEX       Oracle Application Express          4.2.5.00.08     VALID
         3 CATALOG    Oracle Database Catalog Views       12.1.0.2.0      VALID
         3 CATJAVA    Oracle Database Java Packages       12.1.0.2.0      VALID
         3 CATPROC    Oracle Database Packages and Types  12.1.0.2.0      VALID
         3 CONTEXT    Oracle Text                         12.1.0.2.0      VALID
         3 JAVAVM     JServer JAVA Virtual Machine        12.1.0.2.0      VALID
         3 ORDIM      Oracle Multimedia                   12.1.0.2.0      VALID
         3 OWM        Oracle Workspace Manager            12.1.0.2.0      VALID
         3 RAC        Oracle Real Application Clusters    12.1.0.2.0      VALID
         3 XDB        Oracle XML Database                 12.1.0.2.0      VALID
         3 XML        Oracle XDK                          12.1.0.2.0      VALID
Similar to CDB run the preupgrade.jar from console. The output will have a section for each container (root, pdb see and all the pdbs opened).
[oracle@rhel12c1 ~]$ $ORACLE_HOME/jdk/bin/java -jar preupgrade.jar TERMINAL
Report generated by Oracle Database Pre-Upgrade Information Tool Version
12.2.0.1.0

Upgrade-To version: 12.2.0.1.0

=======================================
Status of the database prior to upgrade
=======================================

      Database Name:  STDCDB
     Container Name:  CDB$ROOT
       Container ID:  1
            Version:  12.1.0.2.0
         Compatible:  12.1.0.2.0
          Blocksize:  8192
           Platform:  Linux x86 64-bit
      Timezone File:  18
  Database log mode:  NOARCHIVELOG
           Readonly:  FALSE
            Edition:  SE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  VALID
  Oracle Workspace Manager               [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Application Express             [to be upgraded]  VALID


==============
BEFORE UPGRADE
==============

  Run /preupgrade_fixups_CDB_ROOT.sql to complete all
  of the BEFORE UPGRADE action items below marked with '(AUTOFIXUP)'.

  REQUIRED ACTIONS
  ================
   + Adjust TABLESPACE SIZES as needed.
                                                Auto      12.2.0.1.0
     Tablespace                        Size     Extend    Min Size    Action
     ----------                     ----------  --------  ----------  ------

     SYSAUX                             850 MB  ENABLED      1690 MB  None
     SYSTEM                             780 MB  ENABLED      1274 MB  None
     TEMP                                72 MB  ENABLED       150 MB  None
     UNDOTBS2                           370 MB  ENABLED       400 MB  None

     Note that 12.2.0.1.0 minimum sizes are estimates.
     If you plan to upgrade multiple pluggable databases concurrently,
     then you must ensure that the UNDO tablespace size is equal to at least
     the number of pluggable databases that you upgrade concurrently,
     multiplied by that minimum.  Failing to allocate sufficient space can
     cause the upgrade to fail.


   + (AUTOFIXUP) Empty the RECYCLEBIN immediately before database upgrade.

     The database contains 62 objects in the recycle bin.

     The recycle bin must be completely empty before database upgrade.

  RECOMMENDED ACTIONS
  ===================
   + Run 12.1.0.2.0 $ORACLE_HOME/rdbms/admin/utlrp.sql to recompile invalid
     objects.  You can view the individual invalid objects with

       SET SERVEROUTPUT ON;
       EXECUTE DBMS_PREUP.INVALID_OBJECTS;

     7 objects are INVALID.

     There should be no INVALID objects in SYS/SYSTEM or user schemas before
     database upgrade.

   + (AUTOFIXUP) Gather stale data dictionary statistics prior to database
     upgrade in off-peak time using:

      EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

     Dictionary statistics do not exist or are stale (not up-to-date).

     Dictionary statistics help the Oracle optimizer find efficient SQL
     execution plans and are essential for proper upgrade timing. Oracle
     recommends gathering dictionary statistics in the last 24 hours before
     database upgrade.

     For information on managing optimizer statistics, refer to the 12.1.0.2
     Oracle Database SQL Tuning Guide.

  INFORMATION ONLY
  ================
   + Consider upgrading APEX manually, before the database upgrade.

     The database contains APEX version 4.2.5.00.08 and will need to be
     upgraded to at least version 5.0.4.00.12.

     To reduce database upgrade time, you can upgrade APEX manually before
     the database upgrade.  Refer to My Oracle Support Note 1088970.1 for
     information on APEX installation upgrades.

=============
AFTER UPGRADE
=============

  Run /postupgrade_fixups_CDB_ROOT.sql to complete all
  of the AFTER UPGRADE action items below marked with '(AUTOFIXUP)'.

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
   + Upgrade the database time zone version using the DBMS_DST package.

     The database is using timezone datafile version 18 and the target
     12.2.0.1.0 database ships with timezone datafile version 26.

     Oracle recommends using the most recent timezone data.  For further
     information, refer to My Oracle Support Note 1585343.1.

   + (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
     command:

       EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

     Oracle recommends gathering dictionary statistics after upgrade.

     Dictionary statistics provide essential information to the Oracle
     optimizer to help it find efficient SQL execution plans. After a
     database upgrade, statistics need to be re-gathered as there can now be
     tables that have significantly changed during the upgrade or new tables
     that do not have statistics gathered yet.

Report generated by Oracle Database Pre-Upgrade Information Tool Version
12.2.0.1.0

Upgrade-To version: 12.2.0.1.0

=======================================
Status of the database prior to upgrade
=======================================

      Database Name:  STDCDB
     Container Name:  PDB$SEED
       Container ID:  2
            Version:  12.1.0.2.0
         Compatible:  12.1.0.2.0
          Blocksize:  8192
           Platform:  Linux x86 64-bit
      Timezone File:  18
  Database log mode:  NOARCHIVELOG
           Readonly:  TRUE
            Edition:  SE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  VALID
  Oracle Workspace Manager               [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Application Express             [to be upgraded]  VALID


==============
BEFORE UPGRADE
==============

  Run /preupgrade_fixups_PDB_SEED.sql to complete all
  of the BEFORE UPGRADE action items below marked with '(AUTOFIXUP)'.

  REQUIRED ACTIONS
  ================
   + Adjust TABLESPACE SIZES as needed.
                                                Auto      12.2.0.1.0
     Tablespace                        Size     Extend    Min Size    Action
     ----------                     ----------  --------  ----------  ------

     SYSAUX                             495 MB  ENABLED      1384 MB  None
     SYSTEM                             270 MB  ENABLED       759 MB  None
     TEMP                                62 MB  ENABLED       150 MB  None

     Note that 12.2.0.1.0 minimum sizes are estimates.
     If you plan to upgrade multiple pluggable databases concurrently,
     then you must ensure that the UNDO tablespace size is equal to at least
     the number of pluggable databases that you upgrade concurrently,
     multiplied by that minimum.  Failing to allocate sufficient space can
     cause the upgrade to fail.

  RECOMMENDED ACTIONS
  ===================
   + Run 12.1.0.2.0 $ORACLE_HOME/rdbms/admin/utlrp.sql to recompile invalid
     objects.  You can view the individual invalid objects with

       SET SERVEROUTPUT ON;
       EXECUTE DBMS_PREUP.INVALID_OBJECTS;

     11 objects are INVALID.

     There should be no INVALID objects in SYS/SYSTEM or user schemas before
     database upgrade.

   + (AUTOFIXUP) Gather stale data dictionary statistics prior to database
     upgrade in off-peak time using:

      EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

     Dictionary statistics do not exist or are stale (not up-to-date).

     Dictionary statistics help the Oracle optimizer find efficient SQL
     execution plans and are essential for proper upgrade timing. Oracle
     recommends gathering dictionary statistics in the last 24 hours before
     database upgrade.

     For information on managing optimizer statistics, refer to the 12.1.0.2
     Oracle Database SQL Tuning Guide.

  INFORMATION ONLY
  ================
   + Consider upgrading APEX manually, before the database upgrade.

     The database contains APEX version 4.2.5.00.08 and will need to be
     upgraded to at least version 5.0.4.00.12.

     To reduce database upgrade time, you can upgrade APEX manually before
     the database upgrade.  Refer to My Oracle Support Note 1088970.1 for
     information on APEX installation upgrades.

=============
AFTER UPGRADE
=============

  Run /postupgrade_fixups_PDB_SEED.sql to complete all
  of the AFTER UPGRADE action items below marked with '(AUTOFIXUP)'.

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
   + Upgrade the database time zone version using the DBMS_DST package.

     The database is using timezone datafile version 18 and the target
     12.2.0.1.0 database ships with timezone datafile version 26.

     Oracle recommends using the most recent timezone data.  For further
     information, refer to My Oracle Support Note 1585343.1.

   + (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
     command:

       EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

     Oracle recommends gathering dictionary statistics after upgrade.

     Dictionary statistics provide essential information to the Oracle
     optimizer to help it find efficient SQL execution plans. After a
     database upgrade, statistics need to be re-gathered as there can now be
     tables that have significantly changed during the upgrade or new tables
     that do not have statistics gathered yet.


Report generated by Oracle Database Pre-Upgrade Information Tool Version
12.2.0.1.0

Upgrade-To version: 12.2.0.1.0

=======================================
Status of the database prior to upgrade
=======================================

      Database Name:  STDCDB
     Container Name:  STDPDB
       Container ID:  3
            Version:  12.1.0.2.0
         Compatible:  12.1.0.2.0
          Blocksize:  8192
           Platform:  Linux x86 64-bit
      Timezone File:  18
  Database log mode:  NOARCHIVELOG
           Readonly:  FALSE
            Edition:  SE

  Oracle Component                       Upgrade Action    Current Status
  ----------------                       --------------    --------------
  Oracle Server                          [to be upgraded]  VALID
  JServer JAVA Virtual Machine           [to be upgraded]  VALID
  Oracle XDK for Java                    [to be upgraded]  VALID
  Real Application Clusters              [to be upgraded]  VALID
  Oracle Workspace Manager               [to be upgraded]  VALID
  Oracle Text                            [to be upgraded]  VALID
  Oracle XML Database                    [to be upgraded]  VALID
  Oracle Java Packages                   [to be upgraded]  VALID
  Oracle Multimedia                      [to be upgraded]  VALID
  Oracle Application Express             [to be upgraded]  VALID


==============
BEFORE UPGRADE
==============

  Run /preupgrade_fixups_STDPDB.sql to complete all
  of the BEFORE UPGRADE action items below marked with '(AUTOFIXUP)'.

  REQUIRED ACTIONS
  ================
   + Adjust TABLESPACE SIZES as needed.
                                                Auto      12.2.0.1.0
     Tablespace                        Size     Extend    Min Size    Action
     ----------                     ----------  --------  ----------  ------

     SYSAUX                             525 MB  ENABLED      1411 MB  None
     SYSTEM                             290 MB  ENABLED       785 MB  None
     TEMP                                62 MB  ENABLED       150 MB  None

     Note that 12.2.0.1.0 minimum sizes are estimates.
     If you plan to upgrade multiple pluggable databases concurrently,
     then you must ensure that the UNDO tablespace size is equal to at least
     the number of pluggable databases that you upgrade concurrently,
     multiplied by that minimum.  Failing to allocate sufficient space can
     cause the upgrade to fail.

   + (AUTOFIXUP) Empty the RECYCLEBIN immediately before database upgrade.

     The database contains 16 objects in the recycle bin.

     The recycle bin must be completely empty before database upgrade.

  RECOMMENDED ACTIONS
  ===================
   + Run 12.1.0.2.0 $ORACLE_HOME/rdbms/admin/utlrp.sql to recompile invalid
     objects.  You can view the individual invalid objects with

       SET SERVEROUTPUT ON;
       EXECUTE DBMS_PREUP.INVALID_OBJECTS;

     85 objects are INVALID.

     There should be no INVALID objects in SYS/SYSTEM or user schemas before
     database upgrade.

   + (AUTOFIXUP) Gather stale data dictionary statistics prior to database
     upgrade in off-peak time using:

      EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

     Dictionary statistics do not exist or are stale (not up-to-date).

     Dictionary statistics help the Oracle optimizer find efficient SQL
     execution plans and are essential for proper upgrade timing. Oracle
     recommends gathering dictionary statistics in the last 24 hours before
     database upgrade.

     For information on managing optimizer statistics, refer to the 12.1.0.2
     Oracle Database SQL Tuning Guide.

  INFORMATION ONLY
  ================
   + Consider upgrading APEX manually, before the database upgrade.

     The database contains APEX version 4.2.5.00.08 and will need to be
     upgraded to at least version 5.0.4.00.12.

     To reduce database upgrade time, you can upgrade APEX manually before
     the database upgrade.  Refer to My Oracle Support Note 1088970.1 for
     information on APEX installation upgrades.

=============
AFTER UPGRADE
=============

  Run /postupgrade_fixups_STDPDB.sql to complete all
  of the AFTER UPGRADE action items below marked with '(AUTOFIXUP)'.

  REQUIRED ACTIONS
  ================
  None

  RECOMMENDED ACTIONS
  ===================
   + Upgrade the database time zone version using the DBMS_DST package.

     The database is using timezone datafile version 18 and the target
     12.2.0.1.0 database ships with timezone datafile version 26.

     Oracle recommends using the most recent timezone data.  For further
     information, refer to My Oracle Support Note 1585343.1.

   + (AUTOFIXUP) Gather dictionary statistics after the upgrade using the
     command:

       EXECUTE DBMS_STATS.GATHER_DICTIONARY_STATS;

     Oracle recommends gathering dictionary statistics after upgrade.

     Dictionary statistics provide essential information to the Oracle
     optimizer to help it find efficient SQL execution plans. After a
     database upgrade, statistics need to be re-gathered as there can now be
     tables that have significantly changed during the upgrade or new tables
     that do not have statistics gathered yet.


Preupgrade generated files:
    /opt/app/oracle/cfgtoollogs/stdcdb/preupgrade/preupgrade_fixups.sql
    /opt/app/oracle/cfgtoollogs/stdcdb/preupgrade/postupgrade_fixups.sql
As seen from output above each section has it's own pre and post upgrade script. However the final pre and post upgrade scripts (preupgrade_fixups.sql and postupgrade_fixups.sql) mentioned have the same content as those individual container specific scripts. Moreover they have container specif sections that will only run on the specified container. These *upgrade_fixups scripts could be run in all the containers using catcon.pl as below.
$ cd /opt/app/oracle/product/12.1.0/dbhome_2/rdbms/admin/
$  $ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -e -b preupgrade_fixups /opt/app/oracle/cfgtoollogs/stdcdb/preupgrade/preupgrade_fixups.sql
catcon: ALL catcon-related output will be written to preupgrade_fixups_catcon_30484.lst
catcon: See preupgrade_fixups*.log files for output generated by scripts
catcon: See preupgrade_fixups_*.lst files for spool files, if any
catcon.pl: completed successfully
Once the preupgrade scripts have completed, run dbua to begin CDB upgrade.
Select the PDBs upgraded at the same time as CDB. As this is a SE2 only single PDB is allwoed and that single PDB is upgraded along with the CDB.
The other steps are similar to that of non-CDB. Below is the pre-upgrade summary
Upgrade progress
Post upgrade summary
Run the post upgrade script on all containers using catcon.pl
 $ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -e -b postupgrade_fixups /opt/app/oracle/cfgtoollogs/stdcdb/preupgrade/postupgrade_fixups.sql
catcon: ALL catcon-related output will be written to [/opt/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/postupgrade_fixups_catcon_11556.lst]
catcon: See [/opt/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/postupgrade_fixups*.log] files for output generated by scripts
catcon: See [/opt/app/oracle/product/12.2.0/dbhome_1/rdbms/admin/postupgrade_fixups*.lst] files for spool files, if any

catcon.pl: completed successfully
Component status and version after the upgrade
    CON_ID COMP_ID         COMP_NAME                           STATUS   VERSION
---------- --------------- ----------------------------------- -------- ---------------
         1 CATALOG         Oracle Database Catalog Views       VALID    12.2.0.1.0
         1 CATPROC         Oracle Database Packages and Types  VALID    12.2.0.1.0
         1 JAVAVM          JServer JAVA Virtual Machine        VALID    12.2.0.1.0
         1 XML             Oracle XDK                          VALID    12.2.0.1.0
         1 CATJAVA         Oracle Database Java Packages       VALID    12.2.0.1.0
         1 RAC             Oracle Real Application Clusters    VALID    12.2.0.1.0
         1 XDB             Oracle XML Database                 VALID    12.2.0.1.0
         1 OWM             Oracle Workspace Manager            VALID    12.2.0.1.0
         1 CONTEXT         Oracle Text                         VALID    12.2.0.1.0
         1 ORDIM           Oracle Multimedia                   VALID    12.2.0.1.0
         1 APEX            Oracle Application Express          VALID    5.0.4.00.12

         3 CATALOG         Oracle Database Catalog Views       VALID    12.2.0.1.0
         3 CATPROC         Oracle Database Packages and Types  VALID    12.2.0.1.0
         3 JAVAVM          JServer JAVA Virtual Machine        VALID    12.2.0.1.0
         3 XML             Oracle XDK                          VALID    12.2.0.1.0
         3 CATJAVA         Oracle Database Java Packages       VALID    12.2.0.1.0
         3 RAC             Oracle Real Application Clusters    VALID    12.2.0.1.0
         3 XDB             Oracle XML Database                 VALID    12.2.0.1.0
         3 OWM             Oracle Workspace Manager            VALID    12.2.0.1.0
         3 CONTEXT         Oracle Text                         VALID    12.2.0.1.0
         3 ORDIM           Oracle Multimedia                   VALID    12.2.0.1.0
         3 APEX            Oracle Application Express          VALID    5.0.4.00.12
Database registry history for each container
    CON_ID ACTION          NAMESPACE  VERSION         COMMENTS
---------- --------------- ---------- --------------- ----------------------------------------
         1 BOOTSTRAP       DATAPATCH  12.1.0.2        RDBMS_12.1.0.2.0DBPSU_LINUX.X64_161210
         1 BOOTSTRAP       DATAPATCH  12.2.0.1        RDBMS_12.2.0.1.0_LINUX.X64_170125
         1 VIEW INVALIDATE                            view invalidation
         1 UPGRADE         SERVER     12.2.0.1.0      Upgraded from 12.1.0.2.0

         3 BOOTSTRAP       DATAPATCH  12.1.0.2        RDBMS_12.1.0.2.0DBPSU_LINUX.X64_161210
         3 BOOTSTRAP       DATAPATCH  12.2.0.1        RDBMS_12.2.0.1.0_LINUX.X64_170125
         3 VIEW INVALIDATE                            view invalidation
         3 UPGRADE         SERVER     12.2.0.1.0      Upgraded from 12.1.0.2.0
Check the timezone on root and PDB
SQL> select * from v$timezone_file;

FILENAME                VERSION     CON_ID
-------------------- ---------- ----------
timezlrg_26.dat              26          0

SQL> alter session set container=stdpdb;
SQL> select * from v$timezone_file;

FILENAME                VERSION     CON_ID
-------------------- ---------- ----------
timezlrg_26.dat              26          0
If statspack is configured on PDB then upgrade it 12.2. Change the line
connect perfstat/&&perfstat_password
to
connect perfstat/&&perfstat_password@&&tns_alias
in both spup12102.sql and spup12200.sql. Then create a script with below content (replace password and tns alias values as needed) and run with catcon.pl. (Refer 2020285.1 for more)
cat statup.sql
define perfstat_password='perfstat'
define tns_alias='stdpdb'
@?/rdbms/admin/spup12102.sql;
@?/rdbms/admin/spup12200.sql;

$ORACLE_HOME/perl/bin/perl catcon.pl -n 1 -e -b statup -c stdpdb statup.sql
Same as CDB the remote_listener parameter had the new scan name added to it automatically. It also had the old scan name as well.
remote_listener  string      prod-cluster-scan.rac.domain.net:1521, prod-cluster-scan.prod-cluster.rac.domain.net:1521
Finally upgrade the compatible parameter on the CDB.
SQL> alter system set compatible='12.2.0.1.0' scope=spfile sid='*';
That concludes the upgrading of the databases.

Now that all the databases in the cluster are upgraded, increase the ASM related compatible parameters to 12.2
alter diskgroup fra SET attribute 'compatible.asm'='12.2.0.1.0';
alter diskgroup DATA  SET attribute 'compatible.asm'='12.2.0.1.0';
alter diskgroup fra set attribute 'compatible.rdbms'='12.2.0.1.0';
alter diskgroup data set attribute 'compatible.rdbms'='12.2.0.1.0';
alter diskgroup clusfs  SET attribute 'compatible.asm'='12.2.0.1.0';
alter diskgroup clusfs set attribute 'compatible.rdbms'='12.2.0.1.0';
alter diskgroup GIMR  SET attribute 'compatible.asm'='12.2.0.1.0';
alter diskgroup GIMR set attribute 'compatible.rdbms'='12.2.0.1.0';

GROUP_NUMBER NAME                      VALUE
------------ ------------------------- ---------------
           1 compatible.asm            12.2.0.1.0
           1 compatible.rdbms          12.2.0.1.0
           2 compatible.asm            12.2.0.1.0
           2 compatible.rdbms          12.2.0.1.0
           3 compatible.asm            12.2.0.1.0
           3 compatible.rdbms          12.2.0.1.0
           4 compatible.asm            12.2.0.1.0
           4 compatible.rdbms          12.2.0.1.0
As mentioned in previous post, upgrade adds new oracle user accounts with default passwords. Change the default passwords.

Finally run
orachk -u -o post
to check post upgrade status.

Related Posts
Upgrading RAC from 11.2.0.4 to 12.2.0.1 - Database
Upgrading 11.2.0.3 (11gR2) Database to 12.1.0.1 (12c) Using DBUA
Upgrading from 11.2.0.3 to 12.1.0.1 RAC
Upgrade Oracle Database 12c1 from 12.1.0.1 to 12.1.0.2
Upgrading 12c CDB and PDB from 12.1.0.1 to 12.1.0.2
Upgrading RAC from 11.2.0.4 to 12.1.0.2 - Database
Upgrading RAC from 12.1.0.1 to 12.1.0.2 - Database
Upgrading RAC from 11.2.0.3 to 11.2.0.4 - Database