24 July, 2021

Opening a Lagging Standby Database (to verify data ?)

 As shown in my previous blog post, you can create a Standby Database that lags the Primary by not applying Redo immediately but "waiting" for a specified interval.  It continues to receive and  ArchiveLogs but simply applies each only after the "wait interval".


So, first, the status at the Primary:

oracle19c>echo $ORACLE_SID
ORCLCDB
oracle19c>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Jul 24 18:03:12 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> select systimestamp, database_role, current_scn from v$database;

SYSTIMESTAMP                                                   DATABASE_ROLE    CURRENT_SCN
-------------------------------------------------------------- ---------------- -----------
24-JUL-21 06.03.32.106863 PM +08:00                            PRIMARY             13258062

SQL> alter session set container=ORCLPDB1;

Session altered.

SQL> select * from hemant.job_tracking_tbl order by 1;

JOB_END_TIME                                                       JOB_ID     DB_SCN
-------------------------------------------------------------- ---------- ----------
24-JUL-21 04.57.21.676949 PM                                            1   13239134
24-JUL-21 05.04.29.870877 PM                                            2   13241261
24-JUL-21 05.30.17.962275 PM                                            3   13246616
24-JUL-21 05.39.10.912969 PM                                            4   13247859
24-JUL-21 05.40.20.865467 PM                                            5   13248159
24-JUL-21 05.50.23.930352 PM                                            6   13252182
24-JUL-21 06.00.27.037797 PM                                            7   13257658

7 rows selected.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/archivelog/ORCLCDB
Oldest online log sequence     310
Next log sequence to archive   312
Current log sequence           312
SQL>


Now, the status at STDB2 (the Standby that is lagging with an enforced 60minutes delay

From the alert.log :
2021-07-24T17:51:15.716720+08:00
PR00 (PID:2924): Media Recovery Log /opt/oracle/archivelog/STDB21_303_1036108814.dbf
PR00 (PID:2924): Media Recovery Delayed for 59 minute(s) T-1.S-304
2021-07-24T17:57:26.299295+08:00
PR00 (PID:2924): Media Recovery Log /opt/oracle/archivelog/STDB21_304_1036108814.dbf
2021-07-24T17:57:44.580258+08:00
PR00 (PID:2924): Media Recovery Delayed for 60 minute(s) T-1.S-305
2021-07-24T18:00:32.550708+08:00
 rfs (PID:3452): Archived Log entry 52 added for B-1036108814.T-1.S-311 ID 0xa7521ccd LAD:3
2021-07-24T18:00:33.444329+08:00
 rfs (PID:3452): Selected LNO:4 for T-1.S-312 dbid 2778483057 branch 1036108814


oracle19c>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Jul 24 18:05:53 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database open read only;

Database altered.

SQL> select systimestamp, database_role, open_mode, current_scn from v$database;

SYSTIMESTAMP                                        DATABASE_ROLE    OPEN_MODE    CURRENT_SCN
--------------------------------------------------- ---------------- ------------ -----------
24-JUL-21 06.06.51.313616 PM +08:00                 PHYSICAL STANDBY READ ONLY       13239390

SQL>
SQL> alter pluggable database orclpdb1 open read only;

Pluggable database altered.

SQL> alter session set container=ORCLPDB1;

Session altered.

SQL> select * from hemant.job_tracking_tbl order by 1;

CURRENT_TIMESTAMP                                                  JOB_ID CURRENT_SCN
-------------------------------------------------------------- ---------- -----------
24-JUL-21 04.57.21.676949 PM                                            1    13239134

SQL>


The Primary database is at Log Sequence#312. This Standby has applied only Sequence#304. Let me resume Recovery for some more time and then check the Standby again.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
oracle19c>echo $ORACLE_SID
STDB2
oracle19c>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Jul 24 18:11:12 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             318767104 bytes
Database Buffers          872415232 bytes
Redo Buffers                7639040 bytes
Database mounted.
SQL> alter database recover managed standby database using archived logfile disconnect from session;

Database altered.

SQL>
SQL> quit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
oracle19c>


Later ... from the STDB2 alert log :

2021-07-24T18:40:22.531574+08:00
PR00 (PID:29990): Media Recovery Log /opt/oracle/archivelog/STDB21_309_1036108814.dbf
PR00 (PID:29990): Media Recovery Delayed for 59 minute(s) T-1.S-310
2021-07-24T18:40:43.574486+08:00
 rfs (PID:531): No SRLs available for T-1
2021-07-24T18:40:43.743506+08:00
 rfs (PID:531): Opened log for T-1.S-317 dbid 2778483057 branch 1036108814
2021-07-24T18:40:43.762715+08:00
ARC3 (PID:29836): Archived Log entry 57 added for T-1.S-316 ID 0xa7521ccd LAD:1
2021-07-24T18:40:43.762785+08:00
ARC3 (PID:29836): Archive log for T-1.S-316 available in 60 minute(s)
2021-07-24T18:49:27.636427+08:00
PR00 (PID:29990): Media Recovery Log /opt/oracle/archivelog/STDB21_310_1036108814.dbf
PR00 (PID:29990): Media Recovery Delayed for 60 minute(s) T-1.S-311
2021-07-24T18:50:45.257290+08:00
 rfs (PID:531): Archived Log entry 58 added for B-1036108814.T-1.S-317 ID 0xa7521ccd LAD:3
2021-07-24T18:50:46.045279+08:00
 rfs (PID:531): Selected LNO:4 for T-1.S-318 dbid 2778483057 branch 1036108814


oracle19c>echo $ORACLE_SID
STDB2
oracle19c>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Jul 24 18:51:27 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database open read only;

Database altered.

SQL> alter pluggable database orclpdb1 open read only;

Pluggable database altered.

SQL> alter session set container=orclpdb1;

Session altered.

SQL>
SQL> select * from hemant.job_tracking_tbl order by 1;

JOB_END_TIME                                                       JOB_ID     DB_SCN
-------------------------------------------------------------- ---------- ----------
24-JUL-21 04.57.21.676949 PM                                            1   13239134
24-JUL-21 05.04.29.870877 PM                                            2   13241261
24-JUL-21 05.30.17.962275 PM                                            3   13246616
24-JUL-21 05.39.10.912969 PM                                            4   13247859
24-JUL-21 05.40.20.865467 PM                                            5   13248159
24-JUL-21 05.50.23.930352 PM                                            6   13252182

6 rows selected.

SQL>
SQL> select systimestamp from dual;

SYSTIMESTAMP
---------------------------------------------------------------------------
24-JUL-21 06.53.31.159094 PM +08:00

SQL>


So, now at 18:47, STDB2 has applied Sequence#310 and the database now shows data that came through that ArchiveLog. Upto JOB_ID=6, JOB_END_TIME=05:50:23pm
The Primary has already progressed further.

SQL> l
  1* select * from hemant.job_tracking_tbl order by 1
SQL> /

JOB_END_TIME                                                       JOB_ID     DB_SCN
-------------------------------------------------------------- ---------- ----------
24-JUL-21 04.57.21.676949 PM                                            1   13239134
24-JUL-21 05.04.29.870877 PM                                            2   13241261
24-JUL-21 05.30.17.962275 PM                                            3   13246616
24-JUL-21 05.39.10.912969 PM                                            4   13247859
24-JUL-21 05.40.20.865467 PM                                            5   13248159
24-JUL-21 05.50.23.930352 PM                                            6   13252182
24-JUL-21 06.00.27.037797 PM                                            7   13257658
24-JUL-21 06.10.33.163203 PM                                            8   13259223
24-JUL-21 06.20.36.839944 PM                                            9   13261275
24-JUL-21 06.22.46.972310 PM                                           10   13261560
24-JUL-21 06.30.39.787880 PM                                           11   13262799
24-JUL-21 06.37.18.623659 PM                                           12   13263658
24-JUL-21 06.40.41.713016 PM                                           13   13264263
24-JUL-21 06.50.43.755835 PM                                           14   13265798

14 rows selected.

SQL>


So, the operative methods at the Standby are :
 For Recovery :
1.  alter database recover managed standby database USING ARCHIVED LOGFILE disconnect from session

To Open and Query :
1. alter database recover managed standby database CANCEL
2. alter database OPEN READ ONLY
3. alter pluggable database <pdbname>   OPEN READ ONLY

To resume Recovery :
1. shutdown immediate
2. startup mount
3. alter database recover managed standby database USING ARCHIVED LOGFILE disconnect from session

While the Primary must specify a DELAY value in the log_archive_dest_n parameter for this destination Standby




20 July, 2021

A Standby that lags the Primary by a deliberate Delay

 As I noted in my previous blog post, with multiple Standby databases, you can have one or more of them, lagging the Primary. This allows the organisation a database that can be quickly opened for data recovery in case someone makes a mistake and deletes data or drops tables/objects from the Primary and the delete/drop has already been replicated to the first Standby.

Here is a quick demo.

At the Primary I have :

SQL> alter system archive log current;

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/archivelog/ORCLCDB
Oldest online log sequence     280
Next log sequence to archive   282
Current log sequence           282
SQL>


At the first Standby "STDBYDB", I have :

2021-07-20T17:50:05.870763+08:00
PR00 (PID:2912): Media Recovery Waiting for T-1.S-282 (in transit)
2021-07-20T17:50:06.354006+08:00
ARC3 (PID:2736): Archived Log entry 35 added for T-1.S-281 ID 0xa7521ccd LAD:1
2021-07-20T17:50:06.396543+08:00
 rfs (PID:3263): Archival of T-1.S-281 complete
2021-07-20T17:50:06.527483+08:00
 rfs (PID:3263): Selected LNO:4 for T-1.S-282 dbid 2778483057 branch 1036108814
2021-07-20T17:50:07.008298+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 282 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdbredo01.log


At the second Standby "STDB2", I have :

2021-07-20T17:50:09.484608+08:00
PR00 (PID:2975): Media Recovery Waiting for T-1.S-282 (in transit)
2021-07-20T17:50:09.500278+08:00
 rfs (PID:3216): Opened log for T-1.S-282 dbid 2778483057 branch 1036108814
2021-07-20T17:50:09.527462+08:00
ARC3 (PID:2867): Archived Log entry 22 added for T-1.S-281 ID 0xa7521ccd LAD:1


To introduce a delay in applying ArchiveLogs at STDBY, I specify the DELAY parameter at the Primary database  :

SQL> show parameter log_archive_dest_3

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_3                   string      SERVICE=STDB2 ASYNC VALID_FOR=
                                                 (ONLINE_LOGFILES,PRIMARY_ROLE)
                                                  DB_UNIQUE_NAME=STDB2
log_archive_dest_30                  string
log_archive_dest_31                  string
SQL>  alter system set log_archive_dest_3='SERVICE=STDB2 DELAY=60 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDB2';

System altered.

SQL> show parameter log_archive_dest_3

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_3                   string      SERVICE=STDB2 DELAY=60 ASYNC V
                                                 ALID_FOR=(ONLINE_LOGFILES,PRIM
                                                 ARY_ROLE) DB_UNIQUE_NAME=STDB2
log_archive_dest_30                  string
log_archive_dest_31                  string
SQL>


So, I have introduced a lag of 60minutes for STDB2.  Over the next 60minutes, the Primary will continue generating Redo and ArchiveLogs and both Standbys will be receiving them.  But STDB2 will apply them only after 60minutes.  

However, to enforce this, I must also cause the Standby to *not* use Real Time Apply, so I must change the RECOVER command at the Standby  Note, however, that this must be done on the Standby first !  The Standby must start it's recovery with "USING ARCHIVED LOGFILE" *before* the Primary sets a DELAY value for the target log_archive_dest_n

oracle19c>echo $ORACLE_SID
STDB2
oracle19c>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jul 20 18:14:26 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database recover managed standby database using archived logfile disconnect from session;

Database altered.

SQL>


If I do not change the RECOVER command at the Standby to explicitly specify "USING ARCHIVED LOGFILE", it still defaults to Real Time Apply and ignores the DELAY specified by the Primary. I get the message in STDB2 alert log :

 rfs (PID:13712): WARN: Managed Standby Recovery started with REAL TIME APPLY
 rfs (PID:13712): WARN: DELAY 60 minutes specified at primary ignored


I review the alert log files for all 3 databases about an hour later.

This is the first Standby (STDBYDB)

2021-07-20T19:10:57.161885+08:00
PR00 (PID:2912): Media Recovery Waiting for T-1.S-297 (in transit)
2021-07-20T19:10:57.324337+08:00
 rfs (PID:3263): Selected LNO:4 for T-1.S-297 dbid 2778483057 branch 1036108814
2021-07-20T19:10:58.401720+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 297 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdbredo01.log
2021-07-20T19:14:39.910894+08:00
ARC3 (PID:2736): Archived Log entry 51 added for T-1.S-297 ID 0xa7521ccd LAD:1
2021-07-20T19:14:39.943728+08:00
 rfs (PID:3263): Standby controlfile consistent with primary
2021-07-20T19:14:40.136187+08:00
 rfs (PID:3263): Selected LNO:4 for T-1.S-298 dbid 2778483057 branch 1036108814
2021-07-20T19:14:40.136811+08:00
PR00 (PID:2912): Media Recovery Waiting for T-1.S-298 (in transit)
2021-07-20T19:14:41.180355+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 298 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdbredo01.log

SQL> show parameter db_unique_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      STDBYDB
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
   13123569

SQL>


And this is the Second Standby (STDB2) :

2021-07-20T19:10:58.180405+08:00
 rfs (PID:21331): No SRLs available for T-1
2021-07-20T19:10:58.319036+08:00
ARC0 (PID:2857): Archived Log entry 37 added for T-1.S-296 ID 0xa7521ccd LAD:1
2021-07-20T19:10:58.319358+08:00
ARC0 (PID:2857): Archive log for T-1.S-296 available in 60 minute(s)
2021-07-20T19:10:58.320321+08:00
 rfs (PID:21331): Opened log for T-1.S-297 dbid 2778483057 branch 1036108814
2021-07-20T19:14:40.363888+08:00
 rfs (PID:21331): Archived Log entry 38 added for B-1036108814.T-1.S-297 ID 0xa7521ccd LAD:3
2021-07-20T19:14:40.782081+08:00
 rfs (PID:21331): Selected LNO:4 for T-1.S-298 dbid 2778483057 branch 1036108814
2021-07-20T19:15:12.430015+08:00
PR00 (PID:26793): Media Recovery Log /opt/oracle/archivelog/STDB21_286_1036108814.dbf
PR00 (PID:26793): Media Recovery Delayed for 60 minute(s) T-1.S-287

SQL> show parameter db_unique_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      STDB2
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
   13108691

SQL>


So, while the first Standby (STDBYDB) has already applied and archived Sequence#297 and is currently applying Sequence#298 from the Standby logfile, the second Standby (STDB2) has archived Sequence#297 and received Sequence#298 but notifies that Sequence#286 is currently being applied and the apply Sequence#297 is delayed by 60minutes.
I can also run an SCN_TO_TIMESTAMP query in the Primary (this cannot be executed on a Standby that is not OPEN) :

SQL> select scn_to_timestamp(13123569) At_STDBYDB from dual;

AT_STDBYDB
---------------------------------------------------------------------------
20-JUL-21 07.13.39.000000000 PM

SQL> select scn_to_timestamp(13108691) At_STDB2 from dual;

AT_STDB2
---------------------------------------------------------------------------
20-JUL-21 06.15.07.000000000 PM

SQL>


This shows that STDB2 is lagging by about 60minutes
So, if any "bad action"  (deletion of data or dropping of objects) is detected at the Primary (and a Flashback option is not available), the Standby can be OPENed Read Only to view the data as it was 1hour ago.  
I'll show that option in my next blog post.



15 July, 2021

Creating [1 or more] Additional Standby Database[s]

 In my previous demos, I've shown 1 Standby (STDBYDB) for the Primary (ORCLCDB).

However, an organisation may choose to have additional Standby Databases.  

Note that each Standby Database must be licensed.  If the Primary is licensed by Processor count (say 32 processors), each Standby must also be licensed by Processor count, although the Standbys may be running on servers with fewer processors, thus needing smaller licensing than the Primary.

Why would an organisation have additional Standbys ?  Multiple reasons

1.  Having additional Disaster Recovery Data Centres.  Thus, with 2 DRCs in addition to the Production, there may be 2 Standby Databases.

2. Choosing to have a Standby that can be used to run Reporting Queries when it is OPENed READ ONLY for, say, 4hours a day.  [If the organisation has the Active Dataguard Licence, the Standby can be running Reporting Queries all 24hours]  Without the Active Dataguard Licence, Recovery has to be stopped at this Standby for those 4hours, though it will continue to receive and Archive Redo from the Primary.  Once the 4hour window is closed, Recovery can resumed and the Standby will apply all the "pending" Redo [from the ArchiveLogs that it has received] to "catch-up" to the Primary

3. To test D.R. scenarios, whereby a secondary Standby is opened for Read-Write operations, without impacting the actual Production and first Standby instance which continue to be in-sync throughout the D.R. testing.  The Standby may be opened as a Snapshot Standby

4. To have an environment that can be opened day-time hours for UAT while it is resynced (i.e. Redo Apply done) with the Primary every night.  This will require the Standby to have Flashback Restore Points created and reverted to each day.

5. To have a Standby that is lagging the Primary by, say, 30minutes or 1hour or 4hours deliberately.  This allows the organisation a database that can be quickly opened for data recovery in case someone makes a mistake and deletes data or drops tables/objects from the Primary and the delete/drop has already been replicated to the first Standby.

6. To run [additional] Database Backups at a Standby DRC.  I prefer that the Primary and each Standby be running local database backups.

7. To migrate the Production Primary to a new Data Centre via a Standby built and refreshed over a week and then a Switchover executed during a weekend downtime.

8. To migrate the Production Primary to new  Server Hardware via a Standby built and refreshed over a week and then a Switchover executed during a weekend downtime.


I have built my Second Standby with these parameters :

initSTDB2.ora :

*.audit_file_dest='/opt/oracle/admin/STDB2/adump'
*.audit_sys_operations=false
*.audit_trail='none'
*.commit_logging='batch'
*.commit_wait='nowait'
*.compatible='19.0.0'
*.control_files='/opt/oracle/oradata/STDB2/control01.ctl','/opt/oracle/oradata/STDB2/control02.ctl'
*.db_block_size=8192
*.db_create_file_dest='/opt/oracle/oradata'
*.db_file_name_convert='/opt/oracle/oradata/ORCLCDB','/opt/oracle/oradata/STDB2'
*.db_name='ORCLCDB'
*.db_recovery_file_dest_size=10G
*.db_recovery_file_dest='/opt/oracle/FRA/STDB2'
*.db_unique_name='STDB2'
*.diagnostic_dest='/opt/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=STDB2XDB)'
*.enable_pluggable_database=true
*.fal_server='ORCLCDB'
*.filesystemio_options='setall'
*.local_listener='LISTENER_STDB2'
*.log_archive_config='DG_CONFIG=(ORCLCDB, STDBYDB, STDB2)'
*.log_archive_dest_1='LOCATION=/opt/oracle/archivelog/STDB2'
###*.log_archive_dest_2='SERVICE=ORCLCDB SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=ORCLCDB'
*.log_file_name_convert='/opt/oracle/oradata/ORCLCDB','/opt/oracle/oradata/STDB2'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=384m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=1152m
*.standby_file_management='AUTO'
*.undo_tablespace='UNDOTBS1'


and listener.ora :
LISTENER_STDB2 =
(DESCRIPTION_LIST =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 0.0.0.0)(PORT = 1532))
  )
)

SID_LIST_LISTENER_STDB2 =
 (SID_LIST=
  (SID_DESC =
   (ORACLE_HOME = /opt/oracle/product/19c/dbhome_1)
   (SID_NAME = STDB2)
   )
 )

and the password file copied from the Primary -- although Oracle will copy the password file in recent versions, I still prefer to do it myself
oracle19c>pwd
/opt/oracle/product/19c/dbhome_1/dbs
oracle19c>ls orapw$ORACLE_SID
orapwSTDB2
oracle19c>


Note how I have disabled log_archive_dest_2.  In this case, this Standby will never be part of a Role Reversal done either by Switchover or Failover [where it could become a Primary in the D.R. Data Centre and ship Redo to the old Primary in the Production Data Centre]

oracle19c>lsnrctl start listener_STDB2

LSNRCTL for Linux: Version 19.0.0.0.0 - Production on 15-JUL-2021 22:07:14

Copyright (c) 1991, 2019, Oracle.  All rights reserved.

Starting /opt/oracle/product/19c/dbhome_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 19.0.0.0.0 - Production
System parameter file is /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Log messages written to /opt/oracle/diag/tnslsnr/ora19cs1/listener_stdb2/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1532)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=0.0.0.0)(PORT=1532)))
STATUS of the LISTENER
------------------------
Alias                     listener_STDB2
Version                   TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date                15-JUL-2021 22:07:14
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /opt/oracle/product/19c/dbhome_1/network/admin/listener.ora
Listener Log File         /opt/oracle/diag/tnslsnr/ora19cs1/listener_stdb2/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1532)))
Services Summary...
Service "STDB2" has 1 instance(s).
  Instance "STDB2", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
oracle19c>
oracle19c>echo $ORACLE_SID
STDB2
oracle19c>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jul 15 22:21:47 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             318767104 bytes
Database Buffers          872415232 bytes
Redo Buffers                7639040 bytes
SQL>


Then, at the Primary :

SQL> show parameter log_archive_config

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_config                   string      DG_CONFIG=(ORCLCDB, STDBYDB)
SQL> alter system set log_archive_config='DG_CONFIG=(ORCLCDB, STDBYDB, STDB2)';  -- note that this update is also done at the first Standy STDBYDB2

System altered.

SQL> show parameter log_archive_dest_2

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2                   string      SERVICE=STDBYDB SYNC AFFIRM VA
                                                 LID_FOR=(ONLINE_LOGFILES,PRIMA
                                                 RY_ROLE) DB_UNIQUE_NAME=STDBYD
                                                 B
log_archive_dest_20                  string
log_archive_dest_21                  string
log_archive_dest_22                  string
log_archive_dest_23                  string
log_archive_dest_24                  string
log_archive_dest_25                  string
log_archive_dest_26                  string
log_archive_dest_27                  string
log_archive_dest_28                  string
log_archive_dest_29                  string
SQL> show parameter log_archive_dest_3

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_3                   string
log_archive_dest_30                  string
log_archive_dest_31                  string
SQL> alter system set log_archive_dest_3='SERVICE=STDB2 ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDB2';

System altered.

SQL>


Note that log_archive_dest_2 is set to SYNC AFFIRM but log_archive_dest_3 is set to ASYNC and [NOAFFIRM]. Because I can afford a slight lag (latency) for this Standby.  Maybe it is at a Data Centre that is much further away, increasing the latency.



Then, I copy the Primary to the new Standby using RMAN (see the previous example)

-- assuming that the tnsnames.ora at the Primary is updated to include "STDB2"

oracle19c>rman target sys/manager auxiliary sys/manager@STDB2

Recovery Manager: Release 19.0.0.0.0 - Production on Thu Jul 15 22:24:00 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCLCDB (DBID=2778483057)
connected to auxiliary database: ORCLCDB (not mounted)

RMAN> duplicate target database for standby from active database dorecover;

Starting Duplicate Db at 15-JUL-21
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=21 device type=DISK
allocated channel: ORA_AUX_DISK_2
channel ORA_AUX_DISK_2: SID=256 device type=DISK
current log archived

contents of Memory Script:
{
   backup as copy reuse
   passwordfile auxiliary format  '/opt/oracle/product/19c/dbhome_1/dbs/orapwSTDB2'   ;
}
executing Memory Script

Starting backup at 15-JUL-21
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=273 device type=DISK
allocated channel: ORA_DISK_2
channel ORA_DISK_2: SID=274 device type=DISK

....
....
....
....
....

Finished Duplicate Db at 15-JUL-21

RMAN>


After that I shutdown and restart the new Standby and enable Recovery

SQL> shutdown immediate;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             318767104 bytes
Database Buffers          872415232 bytes
Redo Buffers                7639040 bytes
Database mounted.
SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL>



Let me now verify that the Primary is shipping Redo to *2* Standbys

2021-07-15T22:49:55.328276+08:00
ALTER SYSTEM ARCHIVE LOG
2021-07-15T22:49:56.801388+08:00
LGWR (PID:6404): SRL selected to archive T-1.S-272
LGWR (PID:6404): SRL selected for T-1.S-272 for LAD:2
LGWR (PID:6404): SRL selected to archive T-1.S-272. However, all SRLs are currently active
2021-07-15T22:49:57.005260+08:00
Thread 1 advanced to log sequence 272 (LGWR switch)
  Current log# 2 seq# 272 mem# 0: /opt/oracle/oradata/ORCLCDB/redo02.log
2021-07-15T22:49:57.973514+08:00
NET  (PID:28568): Archived Log entry 588 added for T-1.S-271 ID 0xa7521ccd LAD:1
2021-07-15T22:49:59.487773+08:00
TT03 (PID:8344): SRL selected for T-1.S-272 for LAD:3
2021-07-15T22:50:06.667866+08:00
ALTER SYSTEM ARCHIVE LOG
2021-07-15T22:50:07.669103+08:00
LGWR (PID:6404): SRL selected to archive T-1.S-273
LGWR (PID:6404): SRL selected for T-1.S-273 for LAD:2
LGWR (PID:6404): SRL selected to archive T-1.S-273. However, all SRLs are currently active
2021-07-15T22:50:07.862847+08:00
Thread 1 advanced to log sequence 273 (LGWR switch)
  Current log# 3 seq# 273 mem# 0: /opt/oracle/oradata/ORCLCDB/redo03.log
2021-07-15T22:50:08.191087+08:00
NET  (PID:28568): Archived Log entry 592 added for T-1.S-272 ID 0xa7521ccd LAD:1
2021-07-15T22:52:42.492619+08:00
ALTER SYSTEM ARCHIVE LOG
2021-07-15T22:52:42.988590+08:00
LGWR (PID:6404): SRL selected to archive T-1.S-274
LGWR (PID:6404): SRL selected for T-1.S-274 for LAD:2
LGWR (PID:6404): SRL selected to archive T-1.S-274. However, all SRLs are currently active
2021-07-15T22:52:43.059342+08:00
Thread 1 advanced to log sequence 274 (LGWR switch)
  Current log# 1 seq# 274 mem# 0: /opt/oracle/oradata/ORCLCDB/redo01.log
2021-07-15T22:52:43.142797+08:00
NET  (PID:28568): Archived Log entry 594 added for T-1.S-273 ID 0xa7521ccd LAD:1
2021-07-15T22:52:43.917398+08:00
TT03 (PID:8344): SRL selected for T-1.S-274 for LAD:3



and

SQL> select protection_mode from v$database;

PROTECTION_MODE
--------------------
MAXIMUM AVAILABILITY

SQL>


Thus, we can see that the Primary is shipping Redo to both "LAD2" and "LAD3"

While the first Standby (STDBYDB) shows :

ARC2 (PID:23577): Archived Log entry 26 added for T-1.S-272 ID 0xa7521ccd LAD:1
2021-07-15T22:50:07.448944+08:00
 rfs (PID:23634): Archival of T-1.S-272 complete
2021-07-15T22:50:07.533082+08:00
PR00 (PID:23765): Media Recovery Waiting for T-1.S-273 (in transit)
2021-07-15T22:50:07.668714+08:00
 rfs (PID:23634): Selected LNO:4 for T-1.S-273 dbid 2778483057 branch 1036108814
2021-07-15T22:50:09.298541+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 273 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdbredo01.log
2021-07-15T22:52:42.921683+08:00
 rfs (PID:23634): Standby controlfile consistent with primary
 rfs (PID:23634): No SRLs available for T-1
 rfs (PID:23634): Waiting for T-1.S-273 archival to complete
2021-07-15T22:52:42.929839+08:00
ARC0 (PID:23569): Archived Log entry 27 added for T-1.S-273 ID 0xa7521ccd LAD:1
2021-07-15T22:52:42.935444+08:00
 rfs (PID:23634): Archival of T-1.S-273 complete
2021-07-15T22:52:42.988242+08:00
 rfs (PID:23634): Selected LNO:4 for T-1.S-274 dbid 2778483057 branch 1036108814
2021-07-15T22:52:43.001151+08:00
PR00 (PID:23765): Media Recovery Waiting for T-1.S-274 (in transit)
2021-07-15T22:52:43.002924+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 274 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdbredo01.log


and

SQL> select protection_mode from v$database;

PROTECTION_MODE
--------------------
MAXIMUM AVAILABILITY

SQL> 


And the new Standby (STDB2) shows :

Recovery of Online Redo Log: Thread 1 Group 4 Seq 272 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDB2/stdbredo01.log
2021-07-15T22:50:08.467719+08:00
 rfs (PID:23637): No SRLs available for T-1
2021-07-15T22:50:08.530396+08:00
PR00 (PID:23655): Media Recovery Waiting for T-1.S-273 (in transit)
2021-07-15T22:50:08.532241+08:00
 rfs (PID:23637): Opened log for T-1.S-273 dbid 2778483057 branch 1036108814
2021-07-15T22:50:08.532340+08:00
ARC0 (PID:23450): Archived Log entry 13 added for T-1.S-272 ID 0xa7521ccd LAD:1
2021-07-15T22:52:43.299392+08:00
 rfs (PID:23637): Archived Log entry 14 added for B-1036108814.T-1.S-273 ID 0xa7521ccd LAD:3
2021-07-15T22:52:43.917098+08:00
 rfs (PID:23637): Selected LNO:4 for T-1.S-274 dbid 2778483057 branch 1036108814
2021-07-15T22:52:44.137685+08:00
PR00 (PID:23655): Media Recovery Log /opt/oracle/archivelog/STDB21_273_1036108814.dbf
PR00 (PID:23655): Media Recovery Waiting for T-1.S-274 (in transit)
2021-07-15T22:52:44.576855+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 274 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDB2/stdbredo01.log


and

SQL> select protection_mode from v$database;

PROTECTION_MODE
--------------------
MAXIMUM PERFORMANCE

SQL>


So, now the Primary is shipping Redo to 2 Standbys. The first Standby (STDBYDB) is in MAXIMUM AVAILABILITY mode, the second Standby (STDB2) is in MAXIMUM PERFORMANCE mode.
(For simplicity, I haven't created additional Standby Redo Logs, I have only Standby Redo Log at Primary and each of the Standbys --- it is group#4, filename "stdbredo01.log" in the listing above)

    

In the next blog post, I will explore how to have STDB2 deliberately lagging the Primary by 30minutes 60minutes (use case 5 in the list at the beginning of this blog post)  {updated to 60minutes)


10 July, 2021

Failover to a Standby with Data Loss

 One scenario I consider when testing a Standby Database -- actually testing a Disaster Recovery  site --  is to simulate complete loss of the Primary Database (at the Production site)

Previously, I have demonstrated two methods of "Destructive" Disaster Recovery site testing :

1. Being able to Switchover to the Standby (at a Disaster Recovery site), verifying that transactions created at the Disaster Recovery site do actually flow back to the Production site and, finally, reverting both databases to their pre-test image)

2. Opening a Standby Database as a Snapshot Standby, verify that it is writable and, finally, reverting it to being a "normal" Standby


But what if you want to simulate complete loss of the Production site (Primary database) -- signifying that you may have even lost some transactions, but needing to open the Standby for Read-Write operations ?  OR you actually encounter such a situation where the Primary goes down when the Standby is lagging ? 

On my Primary I had these configured for MAXIMUM AVAILABILITY (with SYNC and AFFIRM for log_archive_dest_2) :

SQL>alter system set log_archive_dest_2='SERVICE=STDBYDB SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=STDBYDB';

System altered.

SQL>
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             822083584 bytes
Database Buffers          369098752 bytes
Redo Buffers                7639040 bytes
Database mounted.
SQL>
SQL> alter database SET STANDBY DATABASE TO MAXIMIZE AVAILABILITY ;

Database altered.

SQL> shutdown
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             822083584 bytes
Database Buffers          369098752 bytes
Redo Buffers                7639040 bytes
Database mounted.
Database opened.
SQL>
SQL> select protection_mode, open_mode, database_role from v$database;

PROTECTION_MODE      OPEN_MODE            DATABASE_ROLE
-------------------- -------------------- ----------------
MAXIMUM AVAILABILITY READ WRITE           PRIMARY

SQL>


This is information of the Primary Database (at the Production site)  when Primary and Standby are in sync :

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/archivelog/ORCLCDB
Oldest online log sequence     235
Next log sequence to archive   237
Current log sequence           237
SQL>


And this is at the Standby Database (at the Disaster Recovery site) :
 
 rfs (PID:4415): Changing standby controlfile to MAXIMUM AVAILABILITY mode
 rfs (PID:4415): Changing standby controlfile to RESYNCHRONIZATION level
 rfs (PID:4415): Standby controlfile consistent with primary
 
Recovery of Online Redo Log: Thread 1 Group 5 Seq 237 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdbredo02.log



My Standby database / site goes down for a short while.  
So the Primary reports :

LGWR (PID:4280): Failed to archive LNO:1 T-1.S-238, error=3113
LGWR (PID:4280): Error 1041 disconnecting from LAD:2 standby host 'STDBYDB'
2021-07-10T17:58:05.264661+08:00
Thread 1 advanced to log sequence 239 (LGWR switch)
  Current log# 2 seq# 239 mem# 0: /opt/oracle/oradata/ORCLCDB/redo02.log
2021-07-10T17:58:05.390312+08:00
ARC1 (PID:4345): Archived Log entry 524 added for T-1.S-238 ID 0xa7521ccd LAD:1


and sometime later

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/archivelog/ORCLCDB
Oldest online log sequence     242
Next log sequence to archive   244
Current log sequence           244
SQL> select current_scn from v$database;

CURRENT_SCN
-----------
   12768459

SQL>


We now know that the Standby (last applying Online Redo Sequence#237 [it went on to 238 before the Instance/Server crashed]) is lagging behind the Primary (current Redo Log 244, SCN 12768459 .

Reminder : The configuration is in MAXIMUM AVAILABILITY mode (not MAXIMUM PROTECTION).

Now, my Primary goes down.

So the FAILOVER must be issued from the Standby when I bring it up.  Let my try that now

SQL> startup mount;
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             436207616 bytes
Database Buffers          754974720 bytes
Redo Buffers                7639040 bytes
Database mounted.
SQL> create restore point before_failover guarantee flashback database;

Restore point created.

SQL>
SQL> select protection_mode, open_mode, database_role from v$database;

PROTECTION_MODE      OPEN_MODE            DATABASE_ROLE
-------------------- -------------------- ----------------
MAXIMUM AVAILABILITY MOUNTED              PHYSICAL STANDBY

SQL> show parameter db_unique_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      STDBYDB
SQL>
SQL> alter database failover to STDBYDB;

Database altered.

SQL>
SQL> select protection_mode, open_mode, database_role from v$database;

PROTECTION_MODE      OPEN_MODE            DATABASE_ROLE
-------------------- -------------------- ----------------
MAXIMUM PERFORMANCE  MOUNTED              PRIMARY

SQL> alter database open;

Database altered.

SQL>


Let's see what the alert log on the Standby shows

ARC1 (PID:6205): FAL: Error 12541 connecting to ORCLCDB for fetching gap sequence

2021-07-10T18:04:34.507622+08:00
RVWR started with pid=45, OS id=11261
2021-07-10T18:04:38.704492+08:00
Allocating 8388608 bytes in shared pool for flashback generation buffer.
Allocated 5430064 bytes in shared pool for flashback generation buffer
2021-07-10T18:04:39.802983+08:00
Created guaranteed restore point BEFORE_FAILOVER

2021-07-10T18:05:50.402988+08:00
alter database failover to STDBYDB
2021-07-10T18:05:50.403086+08:00
.... (PID:6240): The Time Management Interface (TMI) is being enabled for role transition
.... (PID:6240): information.  This will result in messages beingoutput to the alert log
.... (PID:6240): file with the prefix 'TMI: '.  This is being enabled to make the timing of
.... (PID:6240): the various stages of the role transition available for diagnostic purposes.
.... (PID:6240): This output will end when the role transition is complete.
TMI: dbsdrv failover to target BEGIN 2021-07-10 18:05:50.403742
Terminal Recovery requested in process 6240
TMI: adbdrv termRecovery BEGIN 2021-07-10 18:05:50.408509
2021-07-10T18:05:50.494984+08:00
Attempt to do a Terminal Recovery (STDBYDB)
TMI: adbdrv termRecovery END 2021-07-10 18:05:50.495053
2021-07-10T18:05:50.495642+08:00
Media Recovery Start: Managed Standby Recovery (STDBYDB)
 Started logmerger process
2021-07-10T18:05:50.532463+08:00
PR00 (PID:11393): Managed Standby Recovery not using Real Time Apply
max_pdb is 5
2021-07-10T18:05:51.094491+08:00
Parallel Media Recovery started with 2 slaves
2021-07-10T18:05:51.233396+08:00
stopping change tracking
2021-07-10T18:05:51.583393+08:00
PR00 (PID:11393): Begin: SRL archival
PR00 (PID:11393): End: SRL archival
PR00 (PID:11393): Terminal Recovery timestamp is '07/10/2021 18:05:51'
PR00 (PID:11393): Terminal Recovery: applying standby redo logs.
PR00 (PID:11393): Terminal Recovery: thread 1 seq# 238 redo required
2021-07-10T18:05:51.682050+08:00
PR00 (PID:11393): Terminal Recovery:
2021-07-10T18:05:51.685886+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 238 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdbredo01.log
Terminal Recovery finished with No-Data-Loss
2021-07-10T18:05:51.985957+08:00
Incomplete Recovery applied until change 12767732 time 07/10/2021 17:57:59
2021-07-10T18:05:52.074427+08:00
Media Recovery Complete (STDBYDB)
2021-07-10T18:05:52.655358+08:00
Terminal Recovery: successful completion
PR00 (PID:11393): Forcing ARSCN to IRSCN for TR SCN:0x0000000000c2d1f4
PR00 (PID:11393): Attempt to set limbo arscn SCN:0x0000000000c2d1f4 irscn SCN:0x0000000000c2d1f4
PR00 (PID:11393): Resetting standby activation ID 2807176397 (0xa7521ccd)
stopping change tracking
2021-07-10T18:05:52.873082+08:00
ALTER DATABASE SWITCHOVER TO PRIMARY (STDBYDB)
2021-07-10T18:05:52.873684+08:00
Maximum wait for role transition is 15 minutes.
TMI: kcv_commit_to_so_to_primary wait for MRP to finish BEGIN 2021-07-10 18:05:52.873693
TMI: kcv_commit_to_so_to_primary wait for MRP to finish END 2021-07-10 18:05:52.873771
TMI: kcv_commit_to_so_to_primary Switchover from physical BEGIN 2021-07-10 18:05:52.874148
Backup controlfile written to trace file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_ora_6240.trc
2021-07-10T18:05:53.571015+08:00
Standby terminal recovery start SCN: 12767670
RESETLOGS after complete recovery through change 12767732
NET  (PID:6240): ORL pre-clearing operation disabled by switchover
Online log /opt/oracle/oradata/STDBYDB/redo01.log: Thread 1 Group 1 was previously cleared
Online log /opt/oracle/oradata/STDBYDB/redo02.log: Thread 1 Group 2 was previously cleared
Online log /opt/oracle/oradata/STDBYDB/redo03.log: Thread 1 Group 3 was previously cleared
2021-07-10T18:05:53.907884+08:00
Standby became primary SCN: 12767669
2021-07-10T18:05:53.908157+08:00
Setting recovery target incarnation to 4
2021-07-10T18:05:53.966494+08:00
NET  (PID:6240): RT: Role transition work is not done
NET  (PID:6240): The Time Management Interface (TMI) is being enabled for role transition
NET  (PID:6240): information.  This will result in messages beingoutput to the alert log
NET  (PID:6240): file with the prefix 'TMI: '.  This is being enabled to make the timing of
NET  (PID:6240): the various stages of the role transition available for diagnostic purposes.
NET  (PID:6240): This output will end when the role transition is complete.
NET  (PID:6240): Redo network throttle feature is disabled at mount time
2021-07-10T18:05:54.087343+08:00
NET  (PID:6240): Database role cleared from PHYSICAL STANDBY [kcvs.c:1030]
Switchover: Complete - Database mounted as primary
TMI: kcv_commit_to_so_to_primary Switchover from physical END 2021-07-10 18:05:54.088069
TMI: dbsdrv failover to target END 2021-07-10 18:05:54.088135
Failover completed with No-Data-Loss.
Completed: alter database failover to STDBYDB
2021-07-10T18:06:33.754882+08:00
alter database open
2021-07-10T18:06:33.755022+08:00
TMI: adbdrv open database BEGIN 2021-07-10 18:06:33.754898
Ping without log force is disabled:
  instance mounted in exclusive mode.
2021-07-10T18:06:33.945688+08:00
Crash Recovery excluding pdb 2 which was cleanly closed.
2021-07-10T18:06:33.945807+08:00
Crash Recovery excluding pdb 4 which was cleanly closed.
Endian type of dictionary set to little
2021-07-10T18:06:33.999216+08:00
Assigning activation ID 2848626420 (0xa9ca96f4)
2021-07-10T18:06:34.009104+08:00
LGWR (PID:6045): LAD:2 is UNSYNCHRONIZED
2021-07-10T18:06:34.503600+08:00
Thread 1 advanced to log sequence 2 (thread open)
2021-07-10T18:06:34.503635+08:00
ARC3 (PID:6209): Becoming the 'no SRL' ARCH
2021-07-10T18:06:34.503832+08:00
Redo log for group 2, sequence 2 is not located on DAX storage
Thread 1 opened at log sequence 2
  Current log# 2 seq# 2 mem# 0: /opt/oracle/oradata/STDBYDB/redo02.log
Successful open of redo thread 1
2021-07-10T18:06:34.521347+08:00
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
stopping change tracking
2021-07-10T18:06:34.662361+08:00
TT03 (PID:11461): Sleep 5 seconds and then try to clear SRLs in 2 time(s)
2021-07-10T18:06:34.883461+08:00
ARC0 (PID:6199): Archived Log entry 259 added for T-1.S-1 ID 0xa9ca96f4 LAD:1
2021-07-10T18:06:35.784688+08:00
Undo initialization recovery: err:0 start: 1407469 end: 1407660 diff: 191 ms (0.2 seconds)
[6240] Successfully onlined Undo Tablespace 2.
Undo initialization online undo segments: err:0 start: 1407660 end: 1408339 diff: 679 ms (0.7 seconds)
Undo initialization finished serial:0 start:1407469 end:1408406 diff:937 ms (0.9 seconds)
Dictionary check beginning
2021-07-10T18:06:36.927538+08:00
Dictionary check complete
Verifying minimum file header compatibility for tablespace encryption for pdb 1..
Verifying file header compatibility for tablespace encryption completed for pdb 1
Database Characterset is AL32UTF8
No Resource Manager plan active
2021-07-10T18:06:39.177858+08:00


TT00 (PID:6201): Error 12541 received logging on to the standby
TT00 (PID:6201): Check whether the listener is up and running.
2021-07-10T18:06:39.185611+08:00
TT03 (PID:11461): Sleep 5 seconds and then try to clear SRLs in 3 time(s)
2021-07-10T18:06:39.733886+08:00
joxcsys_required_dirobj_exists: directory object exists with required path /opt/oracle/product/19c/dbhome_1/javavm/admin/, pid 6240 cid 1
replication_dependency_tracking turned off (no async multimaster replication found)
2021-07-10T18:06:42.855357+08:00
LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete
Starting background process AQPC
2021-07-10T18:06:43.050601+08:00
AQPC started with pid=50, OS id=11483
PDB$SEED(2):Autotune of undo retention is turned on.
2021-07-10T18:06:44.060956+08:00
PDB$SEED(2):Endian type of dictionary set to little
2021-07-10T18:06:44.314613+08:00
TT03 (PID:11461): Enabling archival of deferred physical standby SRLs
2021-07-10T18:06:44.532641+08:00
TT03 (PID:11461): Archived Log entry 260 added for T-1.S-238 ID 0xa7521ccd LAD:1
2021-07-10T18:06:44.681960+08:00
PDB$SEED(2):Undo initialization finished serial:0 start:1416557 end:1416557 diff:0 ms (0.0 seconds)
PDB$SEED(2):Pluggable database PDB$SEED dictionary check beginning
2021-07-10T18:06:48.986311+08:00
PDB$SEED(2):Pluggable Database PDB$SEED Dictionary check complete
PDB$SEED(2):Database Characterset for PDB$SEED is AL32UTF8
2021-07-10T18:07:04.127503+08:00
PDB$SEED(2):Opening pdb with no Resource Manager plan active
2021-07-10T18:07:05.037256+08:00
QPI: opatch file present, opatch
QPI: qopiprep.bat file present
2021-07-10T18:07:06.501677+08:00
Starting background process CJQ0
2021-07-10T18:07:06.511870+08:00
CJQ0 started with pid=47, OS id=11538
Completed: alter database open


Note the messages 

 PR00 (PID:11393): Terminal Recovery:
2021-07-10T18:05:51.685886+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 238 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdbredo01.log
Terminal Recovery finished with No-Data-Loss
2021-07-10T18:05:51.985957+08:00
Incomplete Recovery applied until change 12767732 time 07/10/2021 17:57:59
2021-07-10T18:05:52.074427+08:00
Media Recovery Complete (STDBYDB)
2021-07-10T18:05:52.655358+08:00
Terminal Recovery: successful completion

Standby terminal recovery start SCN: 12767670

Standby became primary SCN: 12767669

Failover completed with No-Data-Loss.
Completed: alter database failover to STDBYDB


The Standby completed Recovery to Sequence#238 and SCN 12767669 which are much lower then the last known ArchiveLog (Sequence#243) and SCN (something higher than 12768459).

I had expected to see an ORA-16472 error requiring the usage of the "ALTER DATABASE ACTIVATE STANDBY DATABASE" command.  Unfortunately, in this case, the Standby assumes that there are no transactions from the Primary and assumes that there is no Data Loss !

So, the next time you do a Failover, you have to be careful to identify whether there is actual Data Loss if you are unable to access the Primary database.

Now, at the Standby I can query

SQL> select scn_to_timestamp(12767669) from dual;

SCN_TO_TIMESTAMP(12767669)
---------------------------------------------------------------------------
10-JUL-21 05.48.25.000000000 PM

SQL>


which certainly tells me that the last transaction at the Standby is as of  05:48pm (approximately,  the SCN_TO_TIMESTAMP provides us an approximate time only), even though I startup the Standby at 06:04pm.  
Fortunately, when I can access the Primary and read the alert.log, I find that the Primary went down after 06:02pm, with the last ArchiveLog generated at 6:00pm


2021-07-10T18:00:12.509208+08:00
Thread 1 advanced to log sequence 244 (LGWR switch)
  Current log# 1 seq# 244 mem# 0: /opt/oracle/oradata/ORCLCDB/redo01.log
2021-07-10T18:00:12.634091+08:00
ARC2 (PID:4347): Archived Log entry 529 added for T-1.S-243 ID 0xa7521ccd LAD:1


So I can confirm that there IS Data Loss !

FYI , ORA-16472 is :


oracle19c>oerr ora 16472
16472, 0000, "failover failed due to data loss"
// *Cause:  The database was in MaxAvailability or MaxProtection mode but
//          terminal recovery finished with data loss.
// *Action: For a data loss failover, issue ALTER DATABASE ACTIVATE STANDBY
//          DATABASE command.
oracle19c>


This signifies that a FAILOVER command has not succeeded and an ALTER DATABASE ACTIVATE STANDBY DATABASE must be issued.

30 June, 2021

Using a Snapshot Standby Database for [destructive] D.R. Testing

 In a previous blog post I have demonstrated how to use the Flashback Database feature to allow you to open a Standby Database for "destructive" testing (whereby you make changes that you want discarded later) and then revert all the changes with the FLASHBACK DATABASE command.

Another method is to open the existing Standby Database as a Snapshot Standby.

Essentially, the steps are :

1. Ensure that an FRA (instance parameters "db_recovery_file_dest" and "db_recovery_file_dest_size") is configured

2. If the Standby is in Recovery mode, stop recovery and confirm that it is only in MOUNT mode

3. Convert the Standby to a Snapshot Standby with "alter database convert to snapshot standby"

4. Open the Standby as a Read/Write database with "alter database open read write"

5. Begin Read/Write operations (i.e. what I call "destructive" testing which consists of updates to the database that you need discarded later so that it can resync with the Primary)

6. Continue using the Primary while the Standby is being tested.  The Standby will continue receiving Archive Logs from the Primary but will hold them and not apply them to the database

7. At the end of testing, revert to the MOUNT state and convert the Standby back to a [normal] Physical Standby with "alter database convert to physical standby"

8. Resume Recovery of the Standby database. You will see the Standby rollback all changes made at Step 5 and then apply all the Primary Archive Logs from Step 6 till it does a "catch-up" and is in sync with the Primary

Snapshot Standby actually uses the Flashback Database feature but you do *not* have to configure Flashback Database in either the Primary or Standby  -- note that any database change that prevents usage of Flashback Database will prevent you from converting the Snapshot Standby to a Physical Standby at Step 7.



Currently, the Standby is receiving and applying Redo :

PR00 (PID:25362): Media Recovery Waiting for T-1.S-24 (in transit)
2021-06-29T23:15:22.056684+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 24 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdredo04.log
2021-06-29T23:15:51.519366+08:00
ARC2 (PID:25135): Archived Log entry 6 added for T-1.S-24 ID 0xa998aceb LAD:1
2021-06-29T23:15:51.614140+08:00
 rfs (PID:28617): Primary database is in MAXIMUM PERFORMANCE mode
2021-06-29T23:15:51.625100+08:00
PR00 (PID:25362): Media Recovery Waiting for T-1.S-25
2021-06-29T23:15:51.674786+08:00
 rfs (PID:28617): Selected LNO:4 for T-1.S-25 dbid 2778483057 branch 1074297871
2021-06-29T23:15:52.671617+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 25 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdredo04.log


So, now, I chose to convert it to a Snapshot Standby.

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> show parameter db_recovery_file_dest

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest                string      /opt/oracle/FRA/STDBYDB
db_recovery_file_dest_size           big integer 10G
SQL> alter database convert to snapshot standby;

Database altered.

SQL> alter database open read write;

Database altered.

SQL> quit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
STDBYDB>


This is what I see in the Standby alert log now ...

2021-06-29T23:18:07.359020+08:00
alter database recover managed standby database cancel
2021-06-29T23:18:07.360109+08:00
PR00 (PID:25362): MRP0: Background Media Recovery cancelled with status 16037
2021-06-29T23:18:07.360231+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_pr00_25362.trc:
ORA-16037: user requested cancel of managed recovery operation
PR00 (PID:25362): Managed Standby Recovery not using Real Time Apply
Recovery interrupted!
2021-06-29T23:18:08.769438+08:00
Recovered data files to a consistent state at change 13251952
stopping change tracking
2021-06-29T23:18:08.770983+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_pr00_25362.trc:
ORA-16037: user requested cancel of managed recovery operation
2021-06-29T23:18:08.887583+08:00
Background Media Recovery process shutdown (STDBYDB)
2021-06-29T23:18:09.362417+08:00
Managed Standby Recovery Canceled (STDBYDB)
Completed: alter database recover managed standby database cancel
2021-06-29T23:18:21.398899+08:00alter database convert to snapshot standby
Starting background process RVWR
2021-06-29T23:18:21.820131+08:00
RVWR started with pid=45, OS id=29682
2021-06-29T23:18:24.330193+08:00
Allocating 8388608 bytes in shared pool for flashback generation buffer.
Allocated 4664520 bytes in shared pool for flashback generation buffer
Created guaranteed restore point SNAPSHOT_STANDBY_REQUIRED_06/29/2021 23:18:21
.... (PID:29031): Killing 5 processes (PIDS:28412,28617,28424,28422,28426) (all RFS) in order to disallow current and future RFS connections. Requested by OS process 29031
2021-06-29T23:18:25.156848+08:00
Process termination requested for pid 28617 [source = rdbms], [info = 2] [request issued by pid: 29031, uid: 54321]
2021-06-29T23:18:25.156966+08:00
Process termination requested for pid 28412 [source = rdbms], [info = 2] [request issued by pid: 29031, uid: 54321]
2021-06-29T23:18:25.156976+08:00
Process termination requested for pid 28424 [source = rdbms], [info = 2] [request issued by pid: 29031, uid: 54321]
2021-06-29T23:18:25.157075+08:00
Process termination requested for pid 28422 [source = rdbms], [info = 2] [request issued by pid: 29031, uid: 54321]
2021-06-29T23:18:25.157085+08:00
Process termination requested for pid 28426 [source = rdbms], [info = 2] [request issued by pid: 29031, uid: 54321]
2021-06-29T23:18:27.449097+08:00
.... (PID:29031): Database role changed from PHYSICAL STANDBY to SNAPSHOT STANDBY [kcvs.c:3111]
.... (PID:29031): Begin: SRL archival
.... (PID:29031): End: SRL archival
2021-06-29T23:18:28.867461+08:00
RESETLOGS after incomplete recovery UNTIL CHANGE 13251952 time 06/29/2021 23:18:06
Resetting resetlogs activation ID 2845355243 (0xa998aceb)
Online log /opt/oracle/oradata/STDBYDB/redo01.log: Thread 1 Group 1 was previously cleared
Online log /opt/oracle/oradata/STDBYDB/redo02.log: Thread 1 Group 2 was previously cleared
Online log /opt/oracle/oradata/STDBYDB/redo03.log: Thread 1 Group 3 was previously cleared
2021-06-29T23:18:30.336562+08:00
Standby became primary SCN: 13251950
2021-06-29T23:18:30.337002+08:00
Setting recovery target incarnation to 5
2021-06-29T23:18:31.503592+08:00
**********************************************************************
WARNING: The LOG_ARCHIVE_CONFIG parameter has NOT been defined but
remote Data Guard destinations have been configured.  Oracle strongly
recommends that this parameter is set when using Data Guard as
described in the Data Guard manuals.
**********************************************************************
.... (PID:29031): Redo network throttle feature is disabled at mount time
CONVERT TO SNAPSHOT STANDBY: Complete - Database mounted as snapshot standby
Completed: alter database convert to snapshot standby
2021-06-29T23:18:37.046934+08:00
alter database open read write
2021-06-29T23:18:37.175569+08:00
Ping without log force is disabled:
  instance mounted in exclusive mode.
2021-06-29T23:18:37.305328+08:00
Crash Recovery excluding pdb 2 which was cleanly closed.
2021-06-29T23:18:37.305440+08:00
Crash Recovery excluding pdb 4 which was cleanly closed.
Endian type of dictionary set to little
2021-06-29T23:18:37.380920+08:00
Assigning activation ID 2847610391 (0xa9bb1617)
Redo log for group 1, sequence 1 is not located on DAX storage
Thread 1 opened at log sequence 1
  Current log# 1 seq# 1 mem# 0: /opt/oracle/oradata/STDBYDB/redo01.log
Successful open of redo thread 1
2021-06-29T23:18:37.409372+08:00
MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
stopping change tracking
2021-06-29T23:18:37.410681+08:00
ARC2 (PID:25135): Becoming the 'no SRL' ARCH
2021-06-29T23:18:38.408371+08:00
Undo initialization recovery: err:0 start: 3634303 end: 3634511 diff: 208 ms (0.2 seconds)
[29031] Successfully onlined Undo Tablespace 2.
Undo initialization online undo segments: err:0 start: 3634511 end: 3635110 diff: 599 ms (0.6 seconds)
Undo initialization finished serial:0 start:3634303 end:3635201 diff:898 ms (0.9 seconds)
Dictionary check beginning
2021-06-29T23:18:39.390552+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_dbw0_24923.trc:
ORA-01186: file 201 failed verification tests
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '/opt/oracle/oradata/STDBYDB/temp01.dbf'
2021-06-29T23:18:39.390607+08:00
File 201 not verified due to error ORA-01157
2021-06-29T23:18:39.457218+08:00
Dictionary check complete
Verifying minimum file header compatibility for tablespace encryption for pdb 1..
Verifying file header compatibility for tablespace encryption completed for pdb 1
2021-06-29T23:18:39.548199+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_dbw0_24923.trc:
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '/opt/oracle/oradata/STDBYDB/temp01.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2021-06-29T23:18:39.549816+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_dbw0_24923.trc:
ORA-01186: file 201 failed verification tests
ORA-01157: cannot identify/lock data file 201 - see DBWR trace file
ORA-01110: data file 201: '/opt/oracle/oradata/STDBYDB/temp01.dbf'
2021-06-29T23:18:39.550371+08:00
File 201 not verified due to error ORA-01157
2021-06-29T23:18:39.587875+08:00
Re-creating tempfile /opt/oracle/oradata/STDBYDB/temp01.dbf
Database Characterset is AL32UTF8
2021-06-29T23:18:40.528004+08:00
No Resource Manager plan active
2021-06-29T23:18:41.713001+08:00
**********************************************************
WARNING: Files may exists in db_recovery_file_dest
that are not known to the database. Use the RMAN command
CATALOG RECOVERY AREA to re-catalog any such files.
If files cannot be cataloged, then manually delete them
using OS command.
One of the following events caused this:
1. A backup controlfile was restored.
2. A standby controlfile was restored.
3. The controlfile was re-created.
4. db_recovery_file_dest had previously been enabled and
   then disabled.
**********************************************************
2021-06-29T23:18:42.808166+08:00
joxcsys_required_dirobj_exists: directory object exists with required path /opt/oracle/product/19c/dbhome_1/javavm/admin/, pid 29031 cid 1
replication_dependency_tracking turned off (no async multimaster replication found)
2021-06-29T23:18:45.099661+08:00
LOGSTDBY: Validating controlfile with logical metadata
LOGSTDBY: Validation complete
Starting background process AQPC
2021-06-29T23:18:45.252140+08:00
AQPC started with pid=44, OS id=29833
PDB$SEED(2):Autotune of undo retention is turned on.
2021-06-29T23:18:46.281751+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_dbw0_24923.trc:
ORA-01157: cannot identify/lock data file 202 - see DBWR trace file
ORA-01110: data file 202: '/opt/oracle/oradata/STDBYDB/pdbseed/temp012019-05-04_23-32-15-038-PM.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2021-06-29T23:18:46.283068+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_dbw0_24923.trc:
ORA-01186: file 202 failed verification tests
ORA-01157: cannot identify/lock data file 202 - see DBWR trace file
ORA-01110: data file 202: '/opt/oracle/oradata/STDBYDB/pdbseed/temp012019-05-04_23-32-15-038-PM.dbf'
2021-06-29T23:18:46.283122+08:00
File 202 not verified due to error ORA-01157
2021-06-29T23:18:46.299502+08:00
PDB$SEED(2):Endian type of dictionary set to little
PDB$SEED(2):Undo initialization finished serial:0 start:3642756 end:3642756 diff:0 ms (0.0 seconds)
PDB$SEED(2):Pluggable database PDB$SEED dictionary check beginning
PDB$SEED(2):Pluggable Database PDB$SEED Dictionary check complete
PDB$SEED(2):Database Characterset for PDB$SEED is AL32UTF8
2021-06-29T23:18:47.274699+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_dbw0_24923.trc:
ORA-01157: cannot identify/lock data file 202 - see DBWR trace file
ORA-01110: data file 202: '/opt/oracle/oradata/STDBYDB/pdbseed/temp012019-05-04_23-32-15-038-PM.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2021-06-29T23:18:47.275063+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_dbw0_24923.trc:
ORA-01186: file 202 failed verification tests
ORA-01157: cannot identify/lock data file 202 - see DBWR trace file
ORA-01110: data file 202: '/opt/oracle/oradata/STDBYDB/pdbseed/temp012019-05-04_23-32-15-038-PM.dbf'
2021-06-29T23:18:47.275116+08:00
File 202 not verified due to error ORA-01157
2021-06-29T23:18:47.278375+08:00
PDB$SEED(2):Re-creating tempfile /opt/oracle/oradata/STDBYDB/pdbseed/temp012019-05-04_23-32-15-038-PM.dbf
2021-06-29T23:18:53.913930+08:00
PDB$SEED(2):Opening pdb with no Resource Manager plan active
2021-06-29T23:18:56.010088+08:00
QPI: opatch file present, opatch
QPI: qopiprep.bat file present
2021-06-29T23:18:56.556712+08:00
Starting background process CJQ0
2021-06-29T23:18:56.567311+08:00
CJQ0 started with pid=61, OS id=29890
Completed: alter database open read write
2021-06-29T23:18:56.718602+08:00
Errors in file /opt/oracle/diag/rdbms/stdbydb/STDBYDB/trace/STDBYDB_dbw0_24923.trc:
ORA-01157: cannot identify/lock data file 203 - see DBWR trace file
ORA-01110: data file 203: '/opt/oracle/oradata/STDBYDB/ORCLPDB1/temp01.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7
2021-06-29T23:19:00.397276+08:00
Setting Resource Manager plan SCHEDULER[0x4D53]:DEFAULT_MAINTENANCE_PLAN via scheduler window
Setting Resource Manager CDB plan DEFAULT_MAINTENANCE_PLAN via parameter
2021-06-29T23:19:01.355946+08:00


Ignore the error messages relating to the tempfile for pdbseed. For the Pluggable Database "ORCLPDB1", I have to actually OPEN it and then add the TEMPFILE

SQL> alter pluggable database orclpdb1 open;

Pluggable database altered.

SQL>
SQL> alter session set container=ORCLPDB1;

Session altered.

SQL> alter tablespace temp add tempfile '/opt/oracle/oradata/STDBYDB/ORCLPDB1/temp01.dbf' size 100M;

Tablespace altered.

SQL>


2021-06-29T23:31:16.350347+08:00
ORCLPDB1(3):alter pluggable database orclpdb1 open
ORCLPDB1(3):Autotune of undo retention is turned on.
2021-06-29T23:31:16.983648+08:00
ORCLPDB1(3):Endian type of dictionary set to little
2021-06-29T23:31:17.656064+08:00
ORCLPDB1(3):Undo initialization recovery: err:0 start: 4393577 end: 4393759 diff: 182 ms (0.2 seconds)
2021-06-29T23:31:18.148370+08:00
ORCLPDB1(3):[1962] Successfully onlined Undo Tablespace 2.
ORCLPDB1(3):Undo initialization online undo segments: err:0 start: 4393759 end: 4394252 diff: 493 ms (0.5 seconds)
ORCLPDB1(3):Undo initialization finished serial:0 start:4393577 end:4394295 diff:718 ms (0.7 seconds)
ORCLPDB1(3):Pluggable database ORCLPDB1 dictionary check beginning
ORCLPDB1(3):Dropping offline tempfile '/opt/oracle/oradata/STDBYDB/ORCLPDB1/temp01.dbf'
ORCLPDB1(3):Pluggable Database ORCLPDB1 Dictionary check complete
ORCLPDB1(3):Database Characterset for ORCLPDB1 is AL32UTF8
ORCLPDB1(3):*********************************************************************
ORCLPDB1(3):WARNING: The following temporary tablespaces in container(ORCLPDB1)
ORCLPDB1(3):         contain no files.
ORCLPDB1(3):         This condition can occur when a backup controlfile has
ORCLPDB1(3):         been restored.  It may be necessary to add files to these
ORCLPDB1(3):         tablespaces.  That can be done using the SQL statement:
ORCLPDB1(3):
ORCLPDB1(3):         ALTER TABLESPACE tablespace_name ADD TEMPFILE
ORCLPDB1(3):
ORCLPDB1(3):         Alternatively, if these temporary tablespaces are no longer
ORCLPDB1(3):         needed, then they can be dropped.
ORCLPDB1(3):           Empty temporary tablespace: TEMP
ORCLPDB1(3):*********************************************************************
2021-06-29T23:31:23.694969+08:00
ORCLPDB1(3):Opening pdb with no Resource Manager plan active
ORCLPDB1(3):joxcsys_required_dirobj_exists: directory object exists with required path /opt/oracle/product/19c/dbhome_1/javavm/admin/, pid 1962 cid 3
2021-06-29T23:31:24.744735+08:00
Pluggable database ORCLPDB1 opened read write
ORCLPDB1(3):Completed: alter pluggable database orclpdb1 open
2021-06-29T23:36:08.893763+08:00
ORCLPDB1(3):alter tablespace temp add tempfile '/opt/oracle/oradata/STDBYDB/ORCLPDB1/temp01.dbf' size 100M
ORCLPDB1(3):Completed: alter tablespace temp add tempfile '/opt/oracle/oradata/STDBYDB/ORCLPDB1/temp01.dbf' size 100M


Now, my database with ORACLE_SID=STDBYDB is actually open in Read Write mode and I can execute transactions in it.

STDBYDB>sqlplus hemant/hemant@STDBYPDB1

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 29 23:39:25 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Last Successful login time: Fri Jun 25 2021 16:44:27 +08:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> create table my_dummy_table as select * from dba_objects;

Table created.

SQL> insert into my_dummy_table select * from dba_objects;

72825 rows created.

SQL> commit;

Commit complete.

SQL>


Meanwhile, this Standby has been receiving Archive Logs from Sequence#26 onwards from the Primary but not applying them (not that the last one being applied before I converted this to a Snapshot Standby was Sequence#25 (if you scroll up this post and see the alert log entries):

2021-06-29T23:40:05.613462+08:00
 rfs (PID:6610): Selected LNO:5 for T-1.S-26 dbid 2778483057 branch 1074297871
2021-06-29T23:40:06.191335+08:00
ARC3 (PID:25137): Archived Log entry 7 added for T-1.S-25 ID 0xa998aceb LAD:1
2021-06-29T23:41:31.588385+08:00
 rfs (PID:6610): Selected LNO:4 for T-1.S-27 dbid 2778483057 branch 1074297871
2021-06-29T23:41:32.457688+08:00
ARC1 (PID:25133): Archived Log entry 8 added for T-1.S-26 ID 0xa998aceb LAD:1
2021-06-29T23:41:34.786546+08:00
 rfs (PID:6610): Selected LNO:5 for T-1.S-28 dbid 2778483057 branch 1074297871
2021-06-29T23:41:34.972948+08:00
ARC2 (PID:25135): Archived Log entry 9 added for T-1.S-27 ID 0xa998aceb LAD:1
2021-06-29T23:41:38.291575+08:00
 rfs (PID:6610): Selected LNO:4 for T-1.S-29 dbid 2778483057 branch 1074297871
2021-06-29T23:41:38.359875+08:00
ARC3 (PID:25137): Archived Log entry 10 added for T-1.S-28 ID 0xa998aceb LAD:1


After I am done with my testing (the "my_dummy_table" creation and insert statement simulate multiple transactions), I can revert this to a Physical Standby

STDBYDB>echo $ORACLE_SID
STDBYDB
STDBYDB>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Tue Jun 29 23:48:50 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> select database_role, open_mode from v$database;

DATABASE_ROLE    OPEN_MODE
---------------- --------------------
SNAPSHOT STANDBY READ WRITE

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             436207616 bytes
Database Buffers          754974720 bytes
Redo Buffers                7639040 bytes
Database mounted.
SQL> alter database convert to physical standby;

Database altered.

SQL> alter database recover managed standby database disconnect from session;

Database altered.

SQL>
SQL> select database_role, open_mode from v$database;

DATABASE_ROLE    OPEN_MODE
---------------- --------------------
PHYSICAL STANDBY MOUNTED

SQL>


And if I check the alert log

2021-06-29T23:49:00.581987+08:00
Shutting down ORACLE instance (immediate) (OS id: 10178)
2021-06-29T23:49:02.106249+08:00
Stopping background process SMCO
2021-06-29T23:49:03.176041+08:00
Shutting down instance: further logons disabled
2021-06-29T23:49:03.419275+08:00
Stopping background process CJQ0
Stopping background process MMNL
2021-06-29T23:49:04.473142+08:00
Stopping background process MMON
2021-06-29T23:49:06.521607+08:00
alter pluggable database all close immediate
2021-06-29T23:49:06.659467+08:00
ORCLPDB1(3):JIT: pid 10178 requesting stop
ORCLPDB1(3):Buffer Cache flush deferred for PDB 3
2021-06-29T23:49:08.769129+08:00
Pluggable database ORCLPDB1 closed
Completed: alter pluggable database all close immediate
PDB$SEED(2):JIT: pid 10178 requesting stop
PDB$SEED(2):Buffer Cache flush deferred for PDB 2
License high water mark = 9
2021-06-29T23:49:09.947301+08:00
Dispatchers and shared servers shutdown

Data Pump shutdown on PDB: 1 in progress
2021-06-29T23:49:09.947665+08:00
Process termination requested for pid 6610 [source = rdbms], [info = 2] [request issued by pid: 10178, uid: 54321]
2021-06-29T23:49:09.947758+08:00
2021-06-29T23:49:09.947758+08:00
Process termination requested for pid 32278 [source = rdbms], [info = 2] [request issued by pid: 10178, uid: 54321]
2021-06-29T23:49:12.026734+08:00
ALTER DATABASE CLOSE NORMAL
2021-06-29T23:49:12.053755+08:00
Stopping Emon pool
alter pluggable database all close immediate
Completed: alter pluggable database all close immediate
2021-06-29T23:49:13.207695+08:00

IM on ADG: Start of Empty Journal

IM on ADG: End of Empty Journal
Stopping Emon pool
stopping change tracking
2021-06-29T23:49:14.508126+08:00
Shutting down archive processes
2021-06-29T23:49:14.508360+08:00
TT00 (PID:25129): Gap Manager exiting
2021-06-29T23:49:15.508649+08:00
Archiving is disabled
2021-06-29T23:49:15.509020+08:00
ARC3 (PID:25137): ARCH shutting down
ARC3 (PID:25137): Archival stopped
2021-06-29T23:49:15.509302+08:00
ARC2 (PID:25135): ARCH shutting down
ARC2 (PID:25135): Archival stopped
2021-06-29T23:49:15.509646+08:00
ARC1 (PID:25133): ARCH shutting down
ARC1 (PID:25133): Archival stopped
2021-06-29T23:49:15.509894+08:00
ARC0 (PID:25127): ARCH shutting down
ARC0 (PID:25127): Archival stopped
2021-06-29T23:49:16.509551+08:00
Thread 1 closed at log sequence 1
Successful close of redo thread 1
2021-06-29T23:49:16.512464+08:00
Buffer Cache invalidation for all PDBs started
Buffer Cache invalidation for all PDBs complete
Completed: ALTER DATABASE CLOSE NORMAL
ALTER DATABASE DISMOUNT
Shutting down archive processes
Archiving is disabled
Completed: ALTER DATABASE DISMOUNT
2021-06-29T23:49:17.721725+08:00
.... (PID:10178): Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
2021-06-29T23:49:18.723216+08:00
JIT: pid 10178 requesting stop
.... (PID:10178): Archival disabled due to shutdown: 1089
Shutting down archive processes
Archiving is disabled
JIT: pid 10178 requesting stop
2021-06-29T23:49:18.753899+08:00
Stopping background process VKTM
2021-06-29T23:49:31.362905+08:00
Instance shutdown complete (OS id: 10178)
2021-06-29T23:49:40.001253+08:00
Starting ORACLE instance (normal) (OS id: 10479)
2021-06-29T23:49:40.008425+08:00
****************************************************
 Sys-V shared memory will be used for creating SGA
 ****************************************************
2021-06-29T23:49:40.009279+08:00
**********************************************************************
2021-06-29T23:49:40.009331+08:00
Dump of system resources acquired for SHARED GLOBAL AREA (SGA)

2021-06-29T23:49:40.009453+08:00
 Per process system memlock (soft) limit = 128G
2021-06-29T23:49:40.009507+08:00
.... 
.... removed normal alert log messages for instance startup
....
2021-06-29T23:49:42.110291+08:00
ALTER DATABASE   MOUNT
2021-06-29T23:49:44.864639+08:00
Using default pga_aggregate_limit of 2048 MB
2021-06-29T23:49:46.335191+08:00
.... (PID:10659): Database role set to SNAPSHOT STANDBY [kcvfdb.c:8281]
**********************************************************************
WARNING: The LOG_ARCHIVE_CONFIG parameter has NOT been defined but
remote Data Guard destinations have been configured.  Oracle strongly
recommends that this parameter is set when using Data Guard as
described in the Data Guard manuals.
**********************************************************************
.... (PID:10659): Redo network throttle feature is disabled at mount time
2021-06-29T23:49:46.670017+08:00
Successful mount of redo thread 1, with mount id 2847556374
2021-06-29T23:49:46.671968+08:00
Allocating 8388608 bytes in shared pool for flashback generation buffer.
Allocated 8086776 bytes in shared pool for flashback generation buffer
Starting background process RVWR
2021-06-29T23:49:46.682551+08:00
RVWR started with pid=38, OS id=10680
2021-06-29T23:49:46.973026+08:00
Database mounted in Exclusive Mode
Lost write protection disabled
.... (PID:10659): Using STANDBY_ARCHIVE_DEST parameter default value as /opt/oracle/archivelog/STDBYDB [krsd.c:18141]
.... (PID:10659): STARTING ARCH PROCESSES
Starting background process ARC0
2021-06-29T23:49:47.204833+08:00
TT00 (PID:10683): Gap Manager starting
2021-06-29T23:49:47.212662+08:00
ARC0 started with pid=40, OS id=10685
2021-06-29T23:49:47.223092+08:00
.... (PID:10659): ARC0: Archival started
.... (PID:10659): STARTING ARCH PROCESSES COMPLETE
2021-06-29T23:49:47.223272+08:00
ARC0 (PID:10685): Becoming a 'no FAL' ARCH
Completed: ALTER DATABASE   MOUNT
ARC0 (PID:10685): Becoming the 'no SRL' ARCH
2021-06-29T23:49:48.204507+08:00
TMON (PID:10658): STARTING ARCH PROCESSES
Starting background process ARC1
Starting background process ARC2
2021-06-29T23:49:48.213579+08:00
ARC1 started with pid=41, OS id=10688
Starting background process ARC3
2021-06-29T23:49:48.223493+08:00
ARC2 started with pid=42, OS id=10690
TMON (PID:10658): ARC1: Archival started
TMON (PID:10658): ARC2: Archival started
2021-06-29T23:49:48.233487+08:00
ARC3 started with pid=43, OS id=10692
TMON (PID:10658): ARC3: Archival started
TMON (PID:10658): STARTING ARCH PROCESSES COMPLETE
2021-06-29T23:49:50.907722+08:00
 rfs (PID:10708): Selected LNO:4 for T-1.S-29 dbid 2778483057 branch 1074297871
2021-06-29T23:49:56.957932+08:00
alter database convert to physical standby
2021-06-29T23:49:56.958049+08:00
ALTER DATABASE CONVERT TO PHYSICAL STANDBY (STDBYDB)
2021-06-29T23:49:56.977719+08:00
.... (PID:10686): Killing 2 processes (PIDS:10706,10708) (all RFS) in order to disallow current and future RFS connections. Requested by OS process 10686
2021-06-29T23:49:56.977988+08:00
Process termination requested for pid 10708 [source = rdbms], [info = 2] [request issued by pid: 10686, uid: 54321]
2021-06-29T23:49:56.978145+08:00
Process termination requested for pid 10706 [source = rdbms], [info = 2] [request issued by pid: 10686, uid: 54321]
2021-06-29T23:49:59.623973+08:00
Flashback Restore Start
2021-06-29T23:50:06.211660+08:00
Flashback Restore Complete
Drop guaranteed restore point
Stopping background process RVWR
2021-06-29T23:50:08.169218+08:00
Deleted Oracle managed file /opt/oracle/FRA/STDBYDB/STDBYDB/flashback/o1_mf_jfpgfxwn_.flb
Deleted Oracle managed file /opt/oracle/FRA/STDBYDB/STDBYDB/flashback/o1_mf_jfpgg215_.flb
Guaranteed restore point  dropped
2021-06-29T23:50:08.204353+08:00
.... (PID:10686): Database role cleared from SNAPSHOT STANDBY [kcvs.c:8837]
Clearing standby activation ID 2847610391 (0xa9bb1617)
The primary database controlfile was created using the
'MAXLOGFILES 16' clause.
There is space for up to 13 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 209715200;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 209715200;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 209715200;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 209715200;
Offline data file 5 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 6 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 8 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 27 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 28 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 29 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
Offline data file 30 marked as online during convert to standby or switchover to standby.
Restore of backup may be required if the file is not physically accessible.
.... (PID:10686): Database role changed from PRIMARY to PHYSICAL STANDBY [kcvs.c:8842]
.... (PID:10686): RT: Role transition work is not done
**********************************************************************
WARNING: The LOG_ARCHIVE_CONFIG parameter has NOT been defined but
remote Data Guard destinations have been configured.  Oracle strongly
recommends that this parameter is set when using Data Guard as
described in the Data Guard manuals.
**********************************************************************
.... (PID:10686): Redo network throttle feature is disabled at mount time
Physical Standby Database mounted.
2021-06-29T23:50:08.445082+08:00
In-memory operation on ADG is currently only supported on Engineered systems and PaaS.
inmemory_adg_enabled is turned off automatically.
Please contact our support team for EXADATA solutions
CONVERT TO PHYSICAL STANDBY: Complete - Database mounted as physical standby
Completed: alter database convert to physical standby
2021-06-29T23:50:08.945385+08:00
 rfs (PID:11113): Primary database is in MAXIMUM PERFORMANCE mode
2021-06-29T23:50:09.052749+08:00
 rfs (PID:11113): Selected LNO:4 for T-1.S-29 dbid 2778483057 branch 1074297871
2021-06-29T23:50:28.597419+08:00
alter database recover managed standby database disconnect from session
2021-06-29T23:50:28.602993+08:00
Attempt to start background Managed Standby Recovery process (STDBYDB)
Starting background process MRP0
2021-06-29T23:50:28.613186+08:00
MRP0 started with pid=46, OS id=11197
2021-06-29T23:50:28.614021+08:00
Background Managed Standby Recovery process started (STDBYDB)
2021-06-29T23:50:33.639389+08:00
 Started logmerger process
2021-06-29T23:50:33.675757+08:00
PR00 (PID:11203): Managed Standby Recovery starting Real Time Apply
max_pdb is 5
2021-06-29T23:50:33.879309+08:00
Parallel Media Recovery started with 2 slaves
2021-06-29T23:50:34.023681+08:00
stopping change tracking
2021-06-29T23:50:34.043787+08:00
TT02 (PID:11209): Waiting for all non-current ORLs to be archived
2021-06-29T23:50:34.043942+08:00
TT02 (PID:11209): All non-current ORLs have been archived
TT02 (PID:11209): Clearing ORL LNO:1 /opt/oracle/oradata/STDBYDB/redo01.log
Clearing online log 1 of thread 1 sequence number 1
2021-06-29T23:50:34.621214+08:00
Completed: alter database recover managed standby database disconnect from session
2021-06-29T23:50:35.522538+08:00
PR00 (PID:11203): Media Recovery Log /opt/oracle/archivelog/STDBYDB/1_25_1074297871.dbf
2021-06-29T23:50:43.531488+08:00
PR00 (PID:11203): Media Recovery Log /opt/oracle/archivelog/STDBYDB/1_26_1074297871.dbf
2021-06-29T23:50:45.201867+08:00
TT02 (PID:11209): Clearing ORL LNO:1 complete
2021-06-29T23:50:45.330739+08:00
PR00 (PID:11203): Media Recovery Log /opt/oracle/archivelog/STDBYDB/1_27_1074297871.dbf
2021-06-29T23:50:45.523635+08:00
PR00 (PID:11203): Media Recovery Log /opt/oracle/archivelog/STDBYDB/1_28_1074297871.dbf
PR00 (PID:11203): Media Recovery Waiting for T-1.S-29 (in transit)
2021-06-29T23:50:45.747920+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 29 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdredo04.log
2021-06-29T23:50:50.908827+08:00
TT02 (PID:11209): Waiting for all non-current ORLs to be archived
2021-06-29T23:50:50.908947+08:00
TT02 (PID:11209): All non-current ORLs have been archived
2021-06-29T23:57:47.333206+08:00
PR00 (PID:11203): Media Recovery Waiting for T-1.S-30
2021-06-29T23:57:47.338144+08:00
ARC3 (PID:10692): Archived Log entry 11 added for T-1.S-29 ID 0xa998aceb LAD:1
2021-06-29T23:57:47.351366+08:00
 rfs (PID:14591): Primary database is in MAXIMUM PERFORMANCE mode
2021-06-29T23:57:47.397285+08:00
 rfs (PID:14591): Selected LNO:4 for T-1.S-30 dbid 2778483057 branch 1074297871
2021-06-29T23:57:48.392151+08:00
Recovery of Online Redo Log: Thread 1 Group 4 Seq 30 Reading mem 0
  Mem# 0: /opt/oracle/oradata/STDBYDB/stdredo04.log


We can see that it actually did a FLASHBACK DATABASE and DROP GUARANTEED RESTORE POINT(including deletion of Flashback Logs) between 2021-06-29T23:49:59.623973+08:00  and   2021-06-29T23:50:08.169218+08:00.
(This is, effectively, the same method that I demonstrated in the earlier blog post).  After converting to a Physical Standby it applied Archive Logs from Sequence#25 (which was incompletely applied as it was only in Real Time Apply mode at the first conversion to a Snapshot Standby) to Sequence#29 and even the new Sequence#30 being applied in Real Time Apply mode.

But what are the messages relating to datafiles 5, 6, 8, 27,28, 29, 30 ?  The first few are for PDBSEED -- which we know does not get updated and the last 4 are for a PDB called "RMANCAT" which I did *not* OPEN.  


SQL> l
  1  select f.con_id, f.file#, p.name as pdb_name, f.name
  2  from v$datafile f, v$pdbs p
  3  where f.con_id=p.con_id
  4  and f.file# in (5,6,8, 27, 28, 29, 30)
  5* order by 1,2
SQL> /

    CON_ID      FILE# PDB_NAME NAME
---------- ---------- -------- --------------------------------------------------------------------------------
         2          5 PDB$SEED /opt/oracle/oradata/STDBYDB/pdbseed/system01.dbf
         2          6 PDB$SEED /opt/oracle/oradata/STDBYDB/pdbseed/sysaux01.dbf
         2          8 PDB$SEED /opt/oracle/oradata/STDBYDB/pdbseed/undotbs01.dbf
         4         27 RMANCAT  /opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_syst
                               em_jckz3qym_.dbf

         4         28 RMANCAT  /opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_sysa
                               ux_jckz3qy8_.dbf

         4         29 RMANCAT  /opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_undo
                               tbs1_jckz3r04_.dbf

         4         30 RMANCAT  /opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_rman
                               _tbs_jckz3r09_.dbf


7 rows selected.

SQL>


Since these PDBs were *NOT* opened when the database was operating as a Snaphot Standby, they did not get updated.  I can actually ignore the message.  The datafiles are present but were simply not updated.  I do know that the datafiles are present and the RMANCAT PDB is being updated by operations on the Primary.

STDBYDB>cd /opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile
STDBYDB>ls -l
total 860192
-rw-r-----. 1 oracle oinstall 104865792 Jun 30 00:14 o1_mf_rman_tbs_jckz3r09_.dbf
-rw-r-----. 1 oracle oinstall 377495552 Jun 30 00:14 o1_mf_sysaux_jckz3qy8_.dbf
-rw-r-----. 1 oracle oinstall 293609472 Jun 30 00:14 o1_mf_system_jckz3qym_.dbf
-rw-r-----. 1 oracle oinstall 104865792 Jun 30 00:14 o1_mf_undotbs1_jckz3r04_.dbf
STDBYDB>


Also, I can ignore the messages relating to creation of Standby Redo Logs as I already have 3 Standby Redo Logs in the database.

SQL> l
  1  select l.group#, l.status, f.member, l.bytes/1048576
  2  from v$standby_log l, v$logfile f
  3* where l.group#=f.group#
SQL> /

    GROUP# STATUS     MEMBER                                           L.BYTES/1048576
---------- ---------- ------------------------------------------------ ---------------
         4 UNASSIGNED /opt/oracle/oradata/STDBYDB/stdredo04.log                    200
         5 ACTIVE     /opt/oracle/oradata/STDBYDB/stdredo05.log                    200
         6 UNASSIGNED /opt/oracle/oradata/STDBYDB/stdredo06.log                    200

SQL> !ls -l /opt/oracle/oradata/STDBYDB/stdred*
-rw-r-----. 1 oracle oinstall 209715712 Jun 30 00:16 /opt/oracle/oradata/STDBYDB/stdredo04.log
-rw-r-----. 1 oracle oinstall 209715712 Jun 30 00:22 /opt/oracle/oradata/STDBYDB/stdredo05.log
-rw-r-----. 1 oracle oinstall 209715712 Jun 29 23:06 /opt/oracle/oradata/STDBYDB/stdredo06.log

SQL>



Finally : This was a demonstration of opening a Standby of a MultiTenant Database as a Snapshot, opening a selected PDB (ORCLPDB1) without having to open all the PDBs, executing transactions and then reverting the whole CDB back to a Physical Standby.


04 June, 2021

Restoring a Standby Database to the Primary

 When you lose the Primary database, you can restore a backup of the Standby to the Primary.  

Update : This method can also be used to restore a Standby to another server as an independent Primary, except that you must decide the Recovery Point (ArchiveLog Sequence# and make those ArchiveLogs available either from the Standby server or the actual source Primary server)


First, I start with a backup of the Standby :



SQL> select
  2  i.host_name, i.status,
  3  d.dbid, d.name, d.controlfile_type, d.database_role, d.current_scn
  4  from v$instance i, v$database d
  5  /

HOST_NAME        STATUS             DBID NAME      CONTROL DATABASE_ROLE    CURRENT_SCN
---------------- ------------ ---------- --------- ------- ---------------- -----------
ora19cs1         MOUNTED      2778483057 ORCLCDB   STANDBY PHYSICAL STANDBY    12445248

SQL> !echo $ORACLE_SID
STDBYDB

SQL>
SQL> alter database recover managed standby database cancel;

Database altered.

SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
oracle19c>
oracle19c>rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Thu Jun 3 22:29:59 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCLCDB (DBID=2778483057, not open)

RMAN> backup as compressed backupset database;

Starting backup at 03-JUN-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=19 device type=DISK
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=/opt/oracle/oradata/STDBYDB/system01.dbf
input datafile file number=00003 name=/opt/oracle/oradata/STDBYDB/sysaux01.dbf
input datafile file number=00004 name=/opt/oracle/oradata/STDBYDB/undotbs01.dbf
input datafile file number=00007 name=/opt/oracle/oradata/STDBYDB/users01.dbf
channel ORA_DISK_1: starting piece 1 at 03-JUN-21
channel ORA_DISK_1: finished piece 1 at 03-JUN-21
piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp tag=TAG20210603T223042 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00010 name=/opt/oracle/oradata/STDBYDB/ORCLPDB1/sysaux01.dbf
input datafile file number=00012 name=/opt/oracle/oradata/STDBYDB/ORCLPDB1/users01.dbf
input datafile file number=00009 name=/opt/oracle/oradata/STDBYDB/ORCLPDB1/system01.dbf
input datafile file number=00011 name=/opt/oracle/oradata/STDBYDB/ORCLPDB1/undotbs01.dbf
input datafile file number=00026 name=/opt/oracle/oradata/STDBYDB/8812E29864F47615E0530100007FA424/datafile/o1_mf_data_min_j36xw6vr_.dbf
channel ORA_DISK_1: starting piece 1 at 03-JUN-21
channel ORA_DISK_1: finished piece 1 at 03-JUN-21
piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp tag=TAG20210603T223042 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00028 name=/opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_sysaux_j80dl94j_.dbf
input datafile file number=00027 name=/opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_system_j80dl8qy_.dbf
input datafile file number=00029 name=/opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_undotbs1_j80dl96d_.dbf
input datafile file number=00030 name=/opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_rman_tbs_j80f1p8x_.dbf
channel ORA_DISK_1: starting piece 1 at 03-JUN-21
channel ORA_DISK_1: finished piece 1 at 03-JUN-21
piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp tag=TAG20210603T223042 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=/opt/oracle/oradata/STDBYDB/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/opt/oracle/oradata/STDBYDB/pdbseed/system01.dbf
input datafile file number=00008 name=/opt/oracle/oradata/STDBYDB/pdbseed/undotbs01.dbf
channel ORA_DISK_1: starting piece 1 at 03-JUN-21
channel ORA_DISK_1: finished piece 1 at 03-JUN-21
piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp tag=TAG20210603T223042 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
Finished backup at 03-JUN-21

Starting Control File and SPFILE Autobackup at 03-JUN-21
piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_06_03/o1_mf_s_1074102643_jckt126x_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 03-JUN-21

RMAN>


Let's say that some of the datafiles on my Primary are corrupt and I need to restore the Primary database from this Standby backup.  (Alternately, instead of restoring to the actual Primary, I might be planning to build a new Primary, maybe at a different Data Centre, from the Standby backup)
Let's assume that I had captured this information about the Primary before I lost the datafiles of the Primary  (I don't really need all this, I just need to know the Archive Log Sequence#s from the alert.log) :

SQL> select
  2  i.host_name, i.status,
  3  d.dbid, d.name, d.controlfile_type, d.database_role, d.current_scn
  4  from v$instance i, v$database d
  5  /

HOST_NAME        STATUS             DBID NAME      CONTROL DATABASE_ROLE    CURRENT_SCN
---------------- ------------ ---------- --------- ------- ---------------- -----------
ora19cP1         OPEN         2778483057 ORCLCDB   CURRENT PRIMARY             12770765

SQL>
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/archivelog/ORCLCDB
Oldest online log sequence     224
Next log sequence to archive   226
Current log sequence           226
SQL>
SQL> select sequence#, next_change#
  2  from v$archived_log
  3  where sequence# > 215
  4  order by 1
  5  /

 SEQUENCE# NEXT_CHANGE#
---------- ------------
       216     12439207
       216     12439207
       217     12545592
       218     12645850
       219     12746127
       220     12760012
       221     12760153
       222     12760157
       223     12760486
       224     12770051
       225     12770693

11 rows selected.

SQL>


Given that the Standby had SCN 12445248, after the RESTORE, I must RECOVER from SEQUENCE#217.
So I begin to restore the Standby backup which I've copied to the /var/tmp folder on the Primary / New Primary Server.  My ORACLE_SID here is ORCLCDB.


oracle19c>cd /var/tmp
oracle19c>tar xvf STDBYDB_bak.TAR
oracle19c>cd STDBYDB
oracle19c>pwd
/var/tmp/STDBYDB
oracle19c>ls -l
total 0
drwxr-x---. 3 oracle oinstall 23 May 22  2020 88129263B99F4BBDE0530100007F7BDF
drwxr-x---. 3 oracle oinstall 23 May 22  2020 8812E29864F47615E0530100007FA424
drwxr-x---. 5 oracle oinstall 60 Jun  3 22:33 autobackup
drwxr-x---. 5 oracle oinstall 60 Jun  3 22:30 backupset
drwxr-x---. 3 oracle oinstall 23 Apr 21 22:38 C07D1F2BA98C23D0E0530100007F7D34
drwxr-x---. 2 oracle oinstall  6 Mar 27  2020 flashback
drwxr-x---. 2 oracle oinstall  6 Mar 26  2020 onlinelog
oracle19c>
oracle19c>echo $ORACLE_SID
ORCLCDB
oracle19c>rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Thu Jun 3 23:11:01 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database (not started)

RMAN> startup nomount;

Oracle instance started

Total System Global Area    1207955552 bytes

Fixed Size                     9134176 bytes
Variable Size                822083584 bytes
Database Buffers             369098752 bytes
Redo Buffers                   7639040 bytes

RMAN> restore PRIMARY controlfile from
2> '/var/tmp/STDBYDB/autobackup/2021_06_03/o1_mf_s_1074102643_jckt126x_.bkp';

Starting restore at 03-JUN-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=20 device type=DISK

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/opt/oracle/oradata/ORCLCDB/control01.ctl
output file name=/opt/oracle/oradata/ORCLCDB/control02.ctl
Finished restore at 03-JUN-21

RMAN> alter database mount;

released channel: ORA_DISK_1
Statement processed

RMAN>


I now have the Standby Controlfile restored as a Primary Controlfile.
Next, I must remove information about unavailable backups and catalog only the backups that I have copied from the Standby.


RMAN> crosscheck backup;

Starting implicit crosscheck backup at 03-JUN-21
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=24 device type=DISK
Crosschecked 19 objects
Finished implicit crosscheck backup at 03-JUN-21

Starting implicit crosscheck copy at 03-JUN-21
using channel ORA_DISK_1
Finished implicit crosscheck copy at 03-JUN-21

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36yyqqo_.bkp RECID=21 STAMP=1065202775
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36z0h1w_.bkp RECID=22 STAMP=1065202831
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36z1lx8_.bkp RECID=23 STAMP=1065202866
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_02_22/o1_mf_s_1065202724_j36z2q4m_.bkp RECID=24 STAMP=1065202903
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_02_22/o1_mf_annnn_TAG20210222T174817_j36zh2k1_.bkp RECID=25 STAMP=1065203298
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_02_22/o1_mf_s_1065203261_j36zl5fz_.bkp RECID=26 STAMP=1065203397
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g4j55_.bkp RECID=27 STAMP=1070491024
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g4hv6_.bkp RECID=28 STAMP=1070491023
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g5qmn_.bkp RECID=29 STAMP=1070491063
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g5v6j_.bkp RECID=30 STAMP=1070491067
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g6nhq_.bkp RECID=31 STAMP=1070491092
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g6p4q_.bkp RECID=32 STAMP=1070491093
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g7j4f_.bkp RECID=33 STAMP=1070491119
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g7gj2_.bkp RECID=34 STAMP=1070491118
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_04_21/o1_mf_s_1070490998_j80g8k1q_.bkp RECID=35 STAMP=1070491152
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp RECID=36 STAMP=1074292243
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp RECID=37 STAMP=1074292298
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp RECID=38 STAMP=1074292334
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp RECID=39 STAMP=1074292359
Crosschecked 19 objects


RMAN>

RMAN> delete noprompt expired backup;

using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
21      21      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36yyqqo_.bkp
22      22      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36z0h1w_.bkp
23      23      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36z1lx8_.bkp
24      24      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_02_22/o1_mf_s_1065202724_j36z2q4m_.bkp
25      25      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_02_22/o1_mf_annnn_TAG20210222T174817_j36zh2k1_.bkp
26      26      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_02_22/o1_mf_s_1065203261_j36zl5fz_.bkp
27      27      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g4j55_.bkp
28      28      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g4hv6_.bkp
29      29      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g5qmn_.bkp
30      30      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g5v6j_.bkp
31      31      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g6nhq_.bkp
32      32      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g6p4q_.bkp
33      33      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g7j4f_.bkp
34      34      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g7gj2_.bkp
35      35      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_04_21/o1_mf_s_1070490998_j80g8k1q_.bkp
36      36      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp
37      37      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp
38      38      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp
39      39      1   1   EXPIRED     DISK        /opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36yyqqo_.bkp RECID=21 STAMP=1065202775
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36z0h1w_.bkp RECID=22 STAMP=1065202831
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_02_22/o1_mf_nnndf_TAG20210222T173935_j36z1lx8_.bkp RECID=23 STAMP=1065202866
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_02_22/o1_mf_s_1065202724_j36z2q4m_.bkp RECID=24 STAMP=1065202903
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_02_22/o1_mf_annnn_TAG20210222T174817_j36zh2k1_.bkp RECID=25 STAMP=1065203298
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_02_22/o1_mf_s_1065203261_j36zl5fz_.bkp RECID=26 STAMP=1065203397
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g4j55_.bkp RECID=27 STAMP=1070491024
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g4hv6_.bkp RECID=28 STAMP=1070491023
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g5qmn_.bkp RECID=29 STAMP=1070491063
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g5v6j_.bkp RECID=30 STAMP=1070491067
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g6nhq_.bkp RECID=31 STAMP=1070491092
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g6p4q_.bkp RECID=32 STAMP=1070491093
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g7j4f_.bkp RECID=33 STAMP=1070491119
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_04_21/o1_mf_nnndf_TAG20210421T223703_j80g7gj2_.bkp RECID=34 STAMP=1070491118
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/autobackup/2021_04_21/o1_mf_s_1070490998_j80g8k1q_.bkp RECID=35 STAMP=1070491152
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp RECID=36 STAMP=1074292243
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp RECID=37 STAMP=1074292298
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp RECID=38 STAMP=1074292334
deleted backup piece
backup piece handle=/opt/oracle/FRA/STDBYDB/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp RECID=39 STAMP=1074292359
Deleted 19 EXPIRED objects


RMAN>


RMAN> catalog start with '/var/tmp/STDBYDB';

searching for all files that match the pattern /var/tmp/STDBYDB

List of Files Unknown to the Database
=====================================
File Name: /var/tmp/STDBYDB_bak.TAR
File Name: /var/tmp/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp
File Name: /var/tmp/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp
File Name: /var/tmp/STDBYDB/autobackup/2021_06_03/o1_mf_s_1074102643_jckt126x_.bkp
File Name: /var/tmp/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp
File Name: /var/tmp/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp

Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /var/tmp/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp
File Name: /var/tmp/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp
File Name: /var/tmp/STDBYDB/autobackup/2021_06_03/o1_mf_s_1074102643_jckt126x_.bkp
File Name: /var/tmp/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp
File Name: /var/tmp/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp

List of Files Which Were Not Cataloged
=======================================
File Name: /var/tmp/STDBYDB_bak.TAR
  RMAN-07517: Reason: The file header is corrupted

RMAN>

RMAN> list backup;


List of Backup Sets
===================


BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
40      Full    119.55M    DISK        00:00:20     03-JUN-21
        BP Key: 40   Status: AVAILABLE  Compressed: YES  Tag: TAG20210603T223042
        Piece Name: /var/tmp/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp
  List of Datafiles in backup set 40
  Container ID: 2, PDB Name: PDB$SEED
  File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- --------- ----------- ------ ----
  5       Full 4931679    20-MAY-20              NO    /opt/oracle/oradata/STDBYDB/pdbseed/system01.dbf
  6       Full 4931679    20-MAY-20              NO    /opt/oracle/oradata/STDBYDB/pdbseed/sysaux01.dbf
  8       Full 4931679    20-MAY-20              NO    /opt/oracle/oradata/STDBYDB/pdbseed/undotbs01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
41      Full    150.14M    DISK        00:00:32     03-JUN-21
        BP Key: 41   Status: AVAILABLE  Compressed: YES  Tag: TAG20210603T223042
        Piece Name: /var/tmp/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp
  List of Datafiles in backup set 41
  Container ID: 3, PDB Name: ORCLPDB1
  File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- --------- ----------- ------ ----
  9       Full 12441929   01-JUN-21 12444076     NO    /opt/oracle/oradata/STDBYDB/ORCLPDB1/system01.dbf
  10      Full 12441973   01-JUN-21              NO    /opt/oracle/oradata/STDBYDB/ORCLPDB1/sysaux01.dbf
  11      Full 12442030   01-JUN-21 12444077     NO    /opt/oracle/oradata/STDBYDB/ORCLPDB1/undotbs01.dbf
  12      Full 12442056   01-JUN-21              NO    /opt/oracle/oradata/STDBYDB/ORCLPDB1/users01.dbf
  26      Full 12442098   01-JUN-21              NO    /opt/oracle/oradata/STDBYDB/8812E29864F47615E0530100007FA424/datafile/o1_mf_data_min_j36xw6vr_.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
42      Full    17.95M     DISK        00:00:02     03-JUN-21
        BP Key: 42   Status: AVAILABLE  Compressed: NO  Tag: TAG20210603T223304
        Piece Name: /var/tmp/STDBYDB/autobackup/2021_06_03/o1_mf_s_1074102643_jckt126x_.bkp
  SPFILE Included: Modification time: 03-JUN-21
  SPFILE db_unique_name: STDBYDB
  Standby Control File Included: Ckp SCN: 12445249     Ckp time: 01-JUN-21

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
43      Full    318.54M    DISK        00:00:45     03-JUN-21
        BP Key: 43   Status: AVAILABLE  Compressed: YES  Tag: TAG20210603T223042
        Piece Name: /var/tmp/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp
  List of Datafiles in backup set 43
  File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- --------- ----------- ------ ----
  1       Full 12441752   01-JUN-21 12444640     NO    /opt/oracle/oradata/STDBYDB/system01.dbf
  3       Full 12441842   01-JUN-21 12445226     NO    /opt/oracle/oradata/STDBYDB/sysaux01.dbf
  4       Full 12441901   01-JUN-21 12445227     NO    /opt/oracle/oradata/STDBYDB/undotbs01.dbf
  7       Full 12441924   01-JUN-21              NO    /opt/oracle/oradata/STDBYDB/users01.dbf

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ ---------------
44      Full    121.72M    DISK        00:00:22     03-JUN-21
        BP Key: 44   Status: AVAILABLE  Compressed: YES  Tag: TAG20210603T223042
        Piece Name: /var/tmp/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp
  List of Datafiles in backup set 44
  Container ID: 4, PDB Name: RMANCAT
  File LV Type Ckp SCN    Ckp Time  Abs Fuz SCN Sparse Name
  ---- -- ---- ---------- --------- ----------- ------ ----
  27      Full 11082204   21-APR-21              NO    /opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_system_j80dl8qy_.dbf
  28      Full 11082204   21-APR-21              NO    /opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_sysaux_j80dl94j_.dbf
  29      Full 11082204   21-APR-21              NO    /opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_undotbs1_j80dl96d_.dbf
  30      Full 11082204   21-APR-21              NO    /opt/oracle/oradata/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_rman_tbs_j80f1p8x_.dbf

RMAN>

RMAN> quit


Recovery Manager complete.
oracle19c>


So I have now CATALOGed all the backups that I copied over from the Standby server.
Before I proceed with the RESTORE, I verify the "database" information in the controlfile :


oracle19c>echo $ORACLE_SID
ORCLCDB
oracle19c>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Jun 3 23:37:54 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL> col host_name format a16
SQL> select
  2  i.host_name, i.status,
  3  d.dbid, d.name, d.controlfile_type, d.database_role, d.current_scn
  4  from v$instance i, v$database d
  5  /

HOST_NAME        STATUS             DBID NAME      CONTROL DATABASE_ROLE    CURRENT_SCN
---------------- ------------ ---------- --------- ------- ---------------- -----------
ora19cP1         MOUNTED      2778483057 ORCLCDB   BACKUP  PRIMARY                    0

SQL>
SQL> show parameter db_create

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest                  string      /opt/oracle/oradata
db_create_online_log_dest_1          string
db_create_online_log_dest_2          string
db_create_online_log_dest_3          string
db_create_online_log_dest_4          string
db_create_online_log_dest_5          string
SQL>
SQL> create pfile from spfile;

File created.

SQL> shutdown;
ORA-01109: database not open


Database dismounted.
ORACLE instance shut down.
SQL>  --- at this point modify the created pfile to set DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT
SQL> !tail -2 $ORACLE_HOME/dbs/initORCLCDB.ora
*.db_file_name_convert='STDBYDB','ORCLCDB'
*.log_file_name_convert='STDBYDB','ORCLCDB'

SQL>
SQL> startup mount pfile='$ORACLE_HOME/dbs/initORCLCDB.ora';
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             822083584 bytes
Database Buffers          369098752 bytes
Redo Buffers                7639040 bytes
Database mounted.
SQL> show parameter file_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_file_name_convert                 string      STDBYDB, ORCLCDB
log_file_name_convert                string      STDBYDB, ORCLCDB
pdb_file_name_convert                string
SQL>



This shows that I have the correct database controlfile based on the DBID and NAME and that database will now be a PRIMARY, not a Standby.
I cannot check the SCN because the database is not OPEN (in fact, it hasn't been RESTOREd yet !)
However, I had to set DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT because the file names in the control file had STDBYDB in the path and db_create_file_dest would not overwrite that.

I can now proceed to RESTORE database :
SQL> quit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0
oracle19c>rman target /

Recovery Manager: Release 19.0.0.0.0 - Production on Thu Jun 3 23:58:05 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCLCDB (DBID=2778483057, not open)

RMAN> restore database;

Starting restore at 03-JUN-21
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=259 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /opt/oracle/oradata/ORCLCDB/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /opt/oracle/oradata/ORCLCDB/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /opt/oracle/oradata/ORCLCDB/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /opt/oracle/oradata/ORCLCDB/users01.dbf
channel ORA_DISK_1: reading from backup piece /var/tmp/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp
channel ORA_DISK_1: piece handle=/var/tmp/STDBYDB/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckswmk4_.bkp tag=TAG20210603T223042
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00005 to /opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf
channel ORA_DISK_1: restoring datafile 00006 to /opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00008 to /opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf
channel ORA_DISK_1: reading from backup piece /var/tmp/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp
channel ORA_DISK_1: piece handle=/var/tmp/STDBYDB/88129263B99F4BBDE0530100007F7BDF/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckt07r9_.bkp tag=TAG20210603T223042
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00009 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf
channel ORA_DISK_1: restoring datafile 00010 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00011 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00012 to /opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
channel ORA_DISK_1: restoring datafile 00026 to /opt/oracle/oradata/ORCLCDB/8812E29864F47615E0530100007FA424/datafile/o1_mf_data_min_jcky1j3g_.dbf
channel ORA_DISK_1: reading from backup piece /var/tmp/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp
channel ORA_DISK_1: piece handle=/var/tmp/STDBYDB/8812E29864F47615E0530100007FA424/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jcksybw9_.bkp tag=TAG20210603T223042
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00027 to /opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_system_j80dl8qy_.dbf
channel ORA_DISK_1: restoring datafile 00028 to /opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_sysaux_j80dl94j_.dbf
channel ORA_DISK_1: restoring datafile 00029 to /opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_undotbs1_j80dl96d_.dbf
channel ORA_DISK_1: restoring datafile 00030 to /opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_rman_tbs_j80f1p8x_.dbf
channel ORA_DISK_1: reading from backup piece /var/tmp/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp
channel ORA_DISK_1: piece handle=/var/tmp/STDBYDB/C07D1F2BA98C23D0E0530100007F7D34/backupset/2021_06_03/o1_mf_nnndf_TAG20210603T223042_jckszgbr_.bkp tag=TAG20210603T223042
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 04-JUN-21

RMAN>
RMAN> quit


Recovery Manager complete.


I can now proceed to RECOVER the database. Note how I had identified that I would need the ArchiveLogs from SEQUENCE#217 onwards.  Here, either I already have the ArchiveLogs on-disk (if I am restoring the database to the Primary)  OR have copied them from the Old Primary server to the New Primary Server (if I am building the database with a RESTORE on a new Server)
oracle19c>sqlplus '/ as sysdba'

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Jun 4 00:00:48 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.


Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.3.0.0.0

SQL>
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 12441752 generated at 06/01/2021 17:33:06 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_217_1036108814.dbf
ORA-00280: change 12441752 for thread 1 is in sequence #217


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12545592 generated at 06/03/2021 14:12:45 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_218_1036108814.dbf
ORA-00280: change 12545592 for thread 1 is in sequence #218
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_217_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12645850 generated at 06/03/2021 14:19:21 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_219_1036108814.dbf
ORA-00280: change 12645850 for thread 1 is in sequence #219
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_218_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12746127 generated at 06/03/2021 14:21:22 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_220_1036108814.dbf
ORA-00280: change 12746127 for thread 1 is in sequence #220
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_219_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12760012 generated at 06/03/2021 15:04:16 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_221_1036108814.dbf
ORA-00280: change 12760012 for thread 1 is in sequence #221
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_220_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12760153 generated at 06/03/2021 15:04:42 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_222_1036108814.dbf
ORA-00280: change 12760153 for thread 1 is in sequence #222
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_221_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12760157 generated at 06/03/2021 15:04:43 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_223_1036108814.dbf
ORA-00280: change 12760157 for thread 1 is in sequence #223
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_222_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12760486 generated at 06/03/2021 22:43:35 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_224_1036108814.dbf
ORA-00280: change 12760486 for thread 1 is in sequence #224
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_223_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12770051 generated at 06/03/2021 22:45:50 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_225_1036108814.dbf
ORA-00280: change 12770051 for thread 1 is in sequence #225
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_224_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00279: change 12770693 generated at 06/03/2021 22:45:55 needed for thread 1
ORA-00289: suggestion : /opt/oracle/archivelog/ORCLCDB/1_226_1036108814.dbf
ORA-00280: change 12770693 for thread 1 is in sequence #226
ORA-00278: log file '/opt/oracle/archivelog/ORCLCDB/1_225_1036108814.dbf' no longer needed for this recovery


Specify log: {RET=suggested | filename | AUTO | CANCEL}

ORA-00308: cannot open archived log '/opt/oracle/archivelog/ORCLCDB/1_226_1036108814.dbf'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 7


SQL>
SQL> alter database open resetlogs;

Database altered.

SQL>
SQL> select
  2  i.host_name, i.status,
  3  d.dbid, d.name, d.controlfile_type, d.database_role, d.current_scn
  4  from v$instance i, v$database d
  5  /

HOST_NAME        STATUS             DBID NAME      CONTROL DATABASE_ROLE    CURRENT_SCN
---------------- ------------ ---------- --------- ------- ---------------- -----------
ora19cP1         OPEN         2778483057 ORCLCDB   CURRENT PRIMARY             12773006

SQL>
SQL> select name from v$datafile order by 1;

NAME
------------------------------------------------------------------------------------------------------------------------------------
/opt/oracle/oradata/ORCLCDB/8812E29864F47615E0530100007FA424/datafile/o1_mf_data_min_jckz2yvk_.dbf
/opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_rman_tbs_jckz3r09_.dbf
/opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_sysaux_jckz3qy8_.dbf
/opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_system_jckz3qym_.dbf
/opt/oracle/oradata/ORCLCDB/C07D1F2BA98C23D0E0530100007F7D34/datafile/o1_mf_undotbs1_jckz3r04_.dbf
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/sysaux01.dbf
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/system01.dbf
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/undotbs01.dbf
/opt/oracle/oradata/ORCLCDB/ORCLPDB1/users01.dbf
/opt/oracle/oradata/ORCLCDB/pdbseed/sysaux01.dbf
/opt/oracle/oradata/ORCLCDB/pdbseed/system01.dbf
/opt/oracle/oradata/ORCLCDB/pdbseed/undotbs01.dbf
/opt/oracle/oradata/ORCLCDB/sysaux01.dbf
/opt/oracle/oradata/ORCLCDB/system01.dbf
/opt/oracle/oradata/ORCLCDB/undotbs01.dbf
/opt/oracle/oradata/ORCLCDB/users01.dbf

16 rows selected.

SQL> 
SQL> create spfile from pfile;

File created.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup;
ORACLE instance started.

Total System Global Area 1207955552 bytes
Fixed Size                  9134176 bytes
Variable Size             822083584 bytes
Database Buffers          369098752 bytes
Redo Buffers                7639040 bytes
Database mounted.
Database opened.
SQL>
SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /opt/oracle/product/19c/dbhome
                                                 _1/dbs/spfileORCLCDB.ora
SQL>
SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /opt/oracle/archivelog/ORCLCDB
Oldest online log sequence     3
Next log sequence to archive   5
Current log sequence           5
SQL> alter system archive log current;

System altered.

SQL>


(Note : I removed the "<" and ">" signs around the "RET" to preservve HTML formatting)

If I had the Online Redo Logs still available on-disk, I could have done a COMPLETE Recovery of the INCOMPLETE Recovery until SEQUENCE#225.  Transactions in SEQUENCE#226 are lost because they were in the Online Redo Log that hadn't been Archived out at the Primary.

Earlier, my Primary was at SCN 12770765,  now (with the INCOMPLETE Recovery) it has been recovered to some transaction at around SCN 12773005 or thereabouts (because the OPEN RESETLOGS also increments the SCN).


Thus, I have restored from a Standby backup as of SCN 12445248 on server ora19cs1, where the ORACLE_SID and file names were STDBYDB  to SCN 12773005 as a new Primary on server ora19cP1 where the ORACLE_SID and file names are ORCLCDB

Of course, since this was an INCOMPLETE Recovery and I have created a new Incarnation of the Primary, I have to FLASHBACK the Standby to a Lower SCN  OR  Rebuild the Standby.
Had I been able to do a COMPLETE Recovery, I could have simply resumed DataGuard between the Primary and the Standby.

Note :  If the Restored Database is no longer to be a Primary in a DataGuard configuration, you can unset LOG_ARCHIVE_DEST_x  (where x is 2 or greater) and drop any Standby Log files currently defined.