Disclaimer

Saturday, 23 November 2024

RECOVER STANDBY DATABASE FROM SERVICE - 12cR2, 18c, 19c

 

Problem Scenario

  • Issue: The archive log was deleted from the primary site before being shipped to the standby site.
  • Effect: The standby database logs errors in its alert log, and synchronization between the primary and standby databases is broken.
  • Pre-12cR2 Manual Recovery Challenges: Administrators had to:
    1. Identify missing logs.
    2. Transfer logs manually from backups.
    3. Apply logs to the standby database using manual recovery commands.
    Starting from 12cR2, the RECOVER FROM SERVICE command automates this process.
RECOVER STANDBY DATABASE FROM SERVICE ORCLDB;
***************************************************

[oracle@rac201db ~]$ . oraenv
ORACLE_SID = [ORCLDBDG] ?
The Oracle base remains unchanged with value /applications/oracle/d19.3.0/oracle_base
[oracle@rac201db ~]$
[oracle@rac201db ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Feb 23 12:00:36 2023
Version 19.17.0.0.0

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


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

SQL>
SQL>
SQL> SELECT ARCH.THREAD# "Thread",
       ARCH.SEQUENCE# "Last Sequence Received",
       APPL.SEQUENCE# "Last Sequence Applied",
       (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
FROM
(SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
(SELECT THREAD# ,SEQUENCE# FROM V$LO  2  G_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
WHERE ARCH.THREAD# = APPL.THREAD#;   3    4    5    6    7    8

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                   1767                  1597        170
         2                   1739                  1599        140

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

Database altered.

SQL> col group# for a15
SQL> set lines 200 pages 200;
SQL> /

PROCESS                     STATUS                               GROUP#             THREAD#  SEQUENCE#
--------------------------- ------------------------------------ --------------- ---------- ----------
ARCH                        CLOSING                              14                       1       1767
ARCH                        CLOSING                              15                       1       1766
ARCH                        CLOSING                              20                       2       1739
ARCH                        CLOSING                              21                       2       1738
DGRD                        ALLOCATED                            N/A                      0          0
DGRD                        ALLOCATED                            N/A                      0          0
RFS                         RECEIVING                            12                       2       1740
RFS                         IDLE                                 6                        1       1768
RFS                         IDLE                                 N/A                      0          0
RFS                         IDLE                                 N/A                      0          0
RFS                         IDLE                                 N/A                      0          0
RFS                         IDLE                                 N/A                      0          0
RFS                         IDLE                                 N/A                      0          0
RFS                         IDLE                                 N/A                      0          0
RFS                         IDLE                                 N/A                      1          0
RFS                         IDLE                                 N/A                      1          0

16 rows selected.

SQL>
SQL> exit
Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.17.0.0.0


[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$
[oracle@rac201db ~]$ cd /applications/oracle/d19.3.0/oracle_home/network/admin
[oracle@rac201db admin]$
[oracle@rac201db admin]$ ls -lrt
total 12
-rw-r--r--. 1 oracle oinstall 1536 Feb 14  2018 shrept.lst
drwxr-xr-x. 2 oracle oinstall 4096 Apr 17  2019 samples
-rw-r--r--. 1 oracle oinstall  892 Feb  8 15:16 tnsnames.ora
[oracle@rac201db admin]$
[oracle@rac201db admin]$
[oracle@rac201db admin]$
[oracle@rac201db admin]$
[oracle@rac201db admin]$ vi tnsnames.ora
[oracle@rac201db admin]$
[oracle@rac201db admin]$
[oracle@rac201db admin]$ cd
[oracle@rac201db ~]$
[oracle@rac201db ~]$ rman target / catalog rman/rman@RMANDB

Recovery Manager: Release 19.0.0.0.0 - Production on Thu Feb 23 12:07:29 2023
Version 19.17.0.0.0

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

connected to target database: ORCLDB (DBID=2362613747, not open)
connected to recovery catalog database
PL/SQL package rman.DBMS_RCVCAT version 19.09.00.00. in RCVCAT database is not current
PL/SQL package rman.DBMS_RCVMAN version 19.09.00.00 in RCVCAT database is not current

RMAN>

RMAN>

RMAN>

RMAN>

RMAN>

RMAN> RECOVER STANDBY DATABASE FROM SERVICE ORCLDB;

Starting recover at 23.02.23

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 2

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 2
Oracle instance started

Total System Global Area  154081949208 bytes

Fixed Size                    18343448 bytes
Variable Size              62277025792 bytes
Database Buffers           91268055040 bytes
Redo Buffers                 518524928 bytes

contents of Memory Script:
{
   restore standby controlfile from service  'ORCLDB';
   alter database mount standby database;
}
executing Memory Script

Starting restore at 23.02.23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=508 device type=DISK

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:04
output file name=+DATA/ORCLDBDG/control01.ctl
output file name=+DATA/ORCLDBDG/control02.ctl
Finished restore at 23.02.23

released channel: ORA_DISK_1
Statement processed

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 20992
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 0

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 20992
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 0

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 20992
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 0
Executing: alter system set standby_file_management=manual

contents of Memory Script:
{
   reset database to incarnation  5410536;
}
executing Memory Script

database reset to incarnation 5410536

contents of Memory Script:
{
  recover database from service  'ORCLDB';
}
executing Memory Script

Starting recover at 23.02.23
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1013 device type=DISK
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
destination for restore of datafile 00001: +DATA/ORCLDBDG/system01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
destination for restore of datafile 00002: +DATA/ORCLDBDG/ORCL_DE/ORCL_DE01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:20:05
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
destination for restore of datafile 00003: +DATA/ORCLDBDG/sysaux01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
destination for restore of datafile 00004: +DATA/ORCLDBDG/undotbs01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:02:26
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
destination for restore of datafile 00005: +DATA/ORCLDBDG/undotbs02.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:02:45
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
destination for restore of datafile 00007: +DATA/ORCLDBDG/users01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
destination for restore of datafile 00008: +DATA/ORCLDBDG/rit/rit_01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_DISK_1: starting incremental datafile backup set restore
channel ORA_DISK_1: using network backup set from service ORCLDB
destination for restore of datafile 00009: +DATA/ORCLDBDG/tivoliorts01.dbf
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01

starting media recovery

archived log file name=+ARCH/ORCLDBDG/ARCHIVELOG/2023_02_23/thread_1_seq_1769.765.1129551647 thread=1 sequence=1769
archived log file name=+ARCH/ORCLDBDG/ARCHIVELOG/2023_02_23/thread_2_seq_1741.766.1129551837 thread=2 sequence=1741
archived log file name=+ARCH/ORCLDBDG/ARCHIVELOG/2023_02_23/thread_1_seq_1770.767.1129552571 thread=1 sequence=1770
media recovery complete, elapsed time: 00:00:10

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1
Finished recover at 23.02.23
Executing: alter system set standby_file_management=auto
Finished recover at 23.02.23

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1

RMAN>

RMAN>

RMAN> report schema;


DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1
Report of database schema for database with db_unique_name ORCLDBDG

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    1110     SYSTEM               YES     +DATA/ORCLDBDG/system01.dbf
2    162952   ORCL_DE               NO      +DATA/ORCLDBDG/ORCL_DE/ORCL_DE01.dbf
3    2710     SYSAUX               NO      +DATA/ORCLDBDG/sysaux01.dbf
4    12605    UNDOTBS1             YES     +DATA/ORCLDBDG/undotbs01.dbf
5    11984    UNDOTBS2             YES     +DATA/ORCLDBDG/undotbs02.dbf
7    50       USERS                NO      +DATA/ORCLDBDG/users01.dbf
8    1024     RIT                  NO      +DATA/ORCLDBDG/rit/rit_01.dbf
9    1024     TIVOLIORTS           NO      +DATA/ORCLDBDG/tivoliorts01.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       +DATA/ORCLDBDG/temp01.dbf
2    500      TIVOLIORTEMPTS       5120        +DATA/ORCLDBDG/tivoliortempts01.dbf

DBGSQL:     RCVCAT> begin   dbms_rcvcat.initDiFlags(difl2  => :l_difl2, difl3            => :l_difl3, di2flg           => :l_di2flg); end;
DBGSQL:        sqlcode = 6550
DBGSQL:         B :l_difl2 = 4608
DBGSQL:         B :l_difl3 = 128
DBGSQL:         B :l_di2flg = 1

RMAN>

RMAN> exit


Recovery Manager complete.

Below Queries executed while Restoration was running:-


[oracle@rac201db ~]$ sqlplus "/ as sysdba"

SQL*Plus: Release 19.0.0.0.0 - Production on Thu Feb 23 12:13:39 2023
Version 19.17.0.0.0

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


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

SQL> col OPNAME for a30
select OPNAME,SOFAR/TOTALWORK*100 PCT, trunc(TIME_REMAINING/60) MIN_RESTANTES,
trunc(ELAPSED_SECONDS/60) MIN_ATEAGORA
from v$session_longops where TOTALWORK>0 and OPNAME like '%RMAN%';SQL>   2    3

OPNAME                                PCT         MIN_RESTANTES MIN_ATEAGORA
------------------------------        ---------- ------------- ------------
RMAN: incremental datafile restore  5,24103554            41            2



SQL> col OPNAME for a30
select OPNAME,SOFAR/TOTALWORK*100 PCT, trunc(TIME_REMAINING/60) MIN_RESTANTES,
trunc(ELAPSED_SECONDS/60) MIN_ATEAGORA
from v$session_longops where TOTALWORK>0 and OPNAME like '%RMAN%';SQL>   2    3

OPNAME                                PCT        MIN_RESTANTES  MIN_ATEAGORA
------------------------------       ---------- ------------- ------------
RMAN: incremental datafile restore  8,85274275            27            2



SQL>
SQL>
SQL> set lines 200
set pagesize 999
SQL> cle bre
SQL> col sid form 999999
breaks cleared
SQL> SQL> col start_time head "Start|Time" form a12 trunc
col opname head "OSQL> peration" form a12 trunc
SQL> col target head "Object" form a20
SQL> col module head "Module" form a25
SQL> col totalwork head "Total|Work" form 9999999999 trunc
SQL> col Sofar head "Sofar" form 9999999999 trunc
SQL> col elamin head "Elapsed|Time|(Mins)" form 99999999 trunc
SQL> col tre head "Time|Remain|(Sec)" form 999999999 trunc
SQL>
SQL> select l.sid,l.serial#,module,s.sql_id,to_char(start_time,'dd-mon:hh24:mi') start_time,
  2           opname,target,totalwork,sofar,(elapsed_Seconds/60) elamin,
         time_remaining tre
from gv$session_longops l, gv$session s
where
  3  s.sid=l.sid
and s.serial#=l.serial#
  4    5    6    7    8  and totalwork <> SOFAR
order by l.sid,tre, start_time,sid
/  9   10

                                                                                                                                    Elapsed       Time
                                                           Start                                                Total                  Time     Remain
    SID    SERIAL# Module                    SQL_ID        Time         Operation    Object                      Work       Sofar    (Mins)      (Sec)
------- ---------- ------------------------- ------------- ------------ ------------ -------------------- ----------- ----------- --------- ----------
   1013      34092 restore incr datafile                   23-feb:12:12 RMAN: increm 2655                    20857920     2373628         3       1628

SQL>
SQL>
SQL> select SID, START_TIME,TOTALWORK, sofar, (sofar/totalwork) * 100 done,
sysdate + TIME_REMAINING/3600/24 end_at
from v$session_longops
where totalwork > sofar
AND opname NOT LIKE '%aggregate%'
AND opname like 'RMAN%'
/  2    3    4    5    6    7

        Start              Total
    SID Time                Work       Sofar       DONE END_AT
------- ------------ ----------- ----------- ---------- --------
   1013 23.02.23        20857920     2643186 12,6723374 23.02.23

SQL>
SQL>
SQL> /

        Start              Total
    SID Time                Work       Sofar       DONE END_AT
------- ------------ ----------- ----------- ---------- --------
   1013 23.02.23        20857920     3479509 16,6819558 23.02.23

SQL>
SQL>
SQL> /

        Start              Total
    SID Time                Work       Sofar       DONE END_AT
------- ------------ ----------- ----------- ---------- --------
   1013 23.02.23        20857920     5291340 25,3684931 23.02.23

SQL>
SQL>
SQL> /

        Start              Total
    SID Time                Work       Sofar       DONE END_AT
------- ------------ ----------- ----------- ---------- --------
   1013 23.02.23        20857920    14188507 68,0245537 23.02.23

SQL>
SQL>
SQL> /

no rows selected

SQL>
SQL>
SQL>
SQL>
SQL> SELECT ARCH.THREAD# "Thread",
       ARCH.SEQUENCE# "Last Sequence Received",
       APPL.SEQUENCE# "Last Sequence Applied",
       (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
FROM
  2    3    4    5    6  (SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
(SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
WHERE ARCH.THREAD# = APPL.TH  7  READ#;   8

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                   1770                  1770          0
         1                   1770                  1770          0
         2                   1742                  1741          1

SQL>
SQL>
SQL> col group# for a15
set lines 200 pages 200
SELECT process, status, group#, thread#, sequence# FROM v$managed_standby order by process, group#, thread#, sequence#; SQL> SQL>

PROCESS                     STATUS                               GROUP#             THREAD#  SEQUENCE#
--------------------------- ------------------------------------ --------------- ---------- ----------
ARCH                        CLOSING                              14                       1       1770
ARCH                        CLOSING                              20                       2       1741
ARCH                        CLOSING                              21                       2       1742
ARCH                        CONNECTED                            N/A                      0          0
DGRD                        ALLOCATED                            N/A                      0          0
DGRD                        ALLOCATED                            N/A                      0          0
RFS                         IDLE                                 3                        2       1743
RFS                         IDLE                                 9                        1       1771
RFS                         IDLE                                 N/A                      1          0
RFS                         IDLE                                 N/A                      2          0

10 rows selected.

SQL>
SQL>
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;

Database altered.

SQL> SELECT process, status, group#, thread#, sequence# FROM v$managed_standby order by process, group#, thread#, sequence#;

PROCESS                     STATUS                               GROUP#             THREAD#  SEQUENCE#
--------------------------- ------------------------------------ --------------- ---------- ----------
ARCH                        CLOSING                              14                       1       1770
ARCH                        CLOSING                              20                       2       1741
ARCH                        CLOSING                              21                       2       1742
ARCH                        CONNECTED                            N/A                      0          0
DGRD                        ALLOCATED                            N/A                      0          0
DGRD                        ALLOCATED                            N/A                      0          0
MRP0                        APPLYING_LOG                         N/A                      1       1771
RFS                         IDLE                                 3                        2       1743
RFS                         RECEIVING                            9                        1       1771
RFS                         IDLE                                 N/A                      1          0
RFS                         IDLE                                 N/A                      2          0

11 rows selected.

SQL>
SQL>
SQL> /

PROCESS                     STATUS                               GROUP#             THREAD#  SEQUENCE#
--------------------------- ------------------------------------ --------------- ---------- ----------
ARCH                        CLOSING                              14                       1       1770
ARCH                        CLOSING                              20                       2       1741
ARCH                        CLOSING                              21                       2       1742
ARCH                        CONNECTED                            N/A                      0          0
DGRD                        ALLOCATED                            N/A                      0          0
DGRD                        ALLOCATED                            N/A                      0          0
MRP0                        APPLYING_LOG                         N/A                      2       1743
RFS                         IDLE                                 3                        2       1743
RFS                         IDLE                                 9                        1       1771
RFS                         IDLE                                 N/A                      1          0
RFS                         IDLE                                 N/A                      2          0

11 rows selected.

SQL>
SQL>
SQL> SELECT ARCH.THREAD# "Thread",
       ARCH.SEQUENCE# "Last Sequence Received",
       APPL.SEQUENCE# "Last Sequence Applied",
       (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
  2    3    4    5  FROM
(SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
  6    7  (SELECT THREAD# ,SEQUENCE# FROM V$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
  8  WHERE ARCH.THREAD# = APPL.THREAD#;

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                   1770                  1770          0
         1                   1770                  1770          0
         2                   1742                  1742          0

SQL>
SQL>
SQL> /

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                   1773                  1773          0
         2                   1745                  1745          0

SQL>
SQL>
SQL> /

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                   1773                  1773          0
         2                   1745                  1745          0

SQL>
SQL>
SQL> col host_name for a15;
set lines 200 pages 200;
col INSTANCE_NAME for a15;
col PROTECTION_MODE for a20;
col STATUS for a8;
col INSTANCE_ROLE for a18;
col DATABASE_STATUS for a15;
col DATABASE_ROLE for a18;
col VERSION for a15;
select INSTANCE_NAME,HOST_NAME,STATUS,DATABASE_STATUS,PROTECTION_MODE,INSTANCE_ROLE,VERSION,database_role from v$database,v$instance;SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL> SQL>

INSTANCE_NAME   HOST_NAME       STATUS   DATABASE_STATUS PROTECTION_MODE      INSTANCE_ROLE      VERSION         DATABASE_ROLE
--------------- --------------- -------- --------------- -------------------- ------------------ --------------- ------------------
ORCLDBDG          rac201db  MOUNTED  ACTIVE          MAXIMUM PERFORMANCE  PRIMARY_INSTANCE   19.0.0.0.0      PHYSICAL STANDBY

SQL>
SQL> SELECT ARCH.THREAD# "Thread",
       ARCH.SEQUENCE# "Last Sequence Received",
       APPL.SEQUENCE# "Last Sequence Applied",
  2    3    4         (ARCH.SEQUENCE# - APPL.SEQUENCE#) "Difference"
FROM
(SELECT THREAD# ,SEQUENCE# FROM V$ARCHIVED_LOG WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$ARCHIVED_LOG GROUP BY THREAD#)) ARCH,
(SELECT THREAD# ,SEQUENCE# FROM V$LO  5  G_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL
  6  WHERE ARCH.THREAD# = APPL.THREAD#;  7    8

    Thread Last Sequence Received Last Sequence Applied Difference
---------- ---------------------- --------------------- ----------
         1                   1775                  1775          0
         2                   1747                  1747          0


No comments:

Post a Comment

How to recovery PDB when PDB database is dropped in Oracle

  How to recovery PDB when PDB database is dropped :) [oracle@rac01 ~]$ sqlplus '/as sysdba' SQL*Plus: Release 21.0.0.0.0 - Product...