Saturday, May 8, 2021

Setup Data Guard Broker Configuration in Oracle Database

How to setup Data Guard Broker Configuration

=================================================


Primary database : india

Standby database : india_stby


Add static entry for the DGMGRL in the listener.ora on both the primary and standby servers

Standby listener.ora

================================


oracle@ip-10-0-1-37 admin]$ cat listener.ora

# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/dbhome_1/network/admin/listener.ora

# Generated by Oracle configuration tools.


SID_LIST_LISTENER =

      (SID_LIST =

        (SID_DESC =

          (GLOBAL_DBNAME = india_stby)

          (SID_NAME = india_stby)

          (ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1)

       )

        (SID_DESC =

          (GLOBAL_DBNAME = india_dgmgrl)

          (SID_NAME = india_stby)

          (ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1)

               )

        (SID_DESC =

          (GLOBAL_DBNAME = india_stby_dgmgrl)

          (SID_NAME = india_stby)

          (ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1)

               )

          )

[oracle@ip-10-0-1-37 admin]$


Primary  listener.ora

==============================


SID_LIST_LISTENER =

      (SID_LIST =

        (SID_DESC =

          (GLOBAL_DBNAME = india)

          (SID_NAME = india)

          (ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1)

       )

        (SID_DESC =

          (GLOBAL_DBNAME = india_dgmgrl)

          (SID_NAME = india_stby)

          (ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1)

               )

        (SID_DESC =

          (GLOBAL_DBNAME = india_stby_dgmgrl)

          (SID_NAME = india_stby)

          (ORACLE_HOME = /u01/app/oracle/product/12.2.0/dbhome_1)

               )

          )

 

ALTER SYSTEM SET dg_broker_start=true scope=both;



SQL>

SQL> ALTER SYSTEM SET dg_broker_start=true scope=both;


System altered.


SQL>

SQL>

SQL> show parameter broker


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

connection_brokers                   string      ((TYPE=DEDICATED)(BROKERS=1)),

                                                  ((TYPE=EMON)(BROKERS=1))

dg_broker_config_file1               string      /u01/app/oracle/product/12.2.0

                                                 /dbhome_1/dbs/dr1india_stby.da

                                                 t

dg_broker_config_file2               string      /u01/app/oracle/product/12.2.0

                                                 /dbhome_1/dbs/dr2india_stby.da

                                                 t

dg_broker_start                      boolean     TRUE

use_dedicated_broker                 boolean     FALSE

SQL>

SQL>

SQL>

SQL>


on stanndby 

==============


SQL> /


    Thread Last Sequence Received Last Sequence Applied Difference

---------- ---------------------- --------------------- ----------

         1                     29                    29          0


SQL>

SQL>

SQL> ALTER SYSTEM SET dg_broker_start=true scope=both;


System altered.

SQL>

SQL>

SQL> show parameter broker

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

connection_brokers                   string      ((TYPE=DEDICATED)(BROKERS=1)),

                                                  ((TYPE=EMON)(BROKERS=1))

dg_broker_config_file1               string      /u01/app/oracle/product/12.2.0

                                                 /dbhome_1/dbs/dr1india_stby.da

                                                 t

dg_broker_config_file2               string      /u01/app/oracle/product/12.2.0

                                                 /dbhome_1/dbs/dr2india_stby.da

                                                 t

dg_broker_start                      boolean     TRUE

use_dedicated_broker                 boolean     FALSE

SQL>

SQL>

SQL>

SQL>


DGMGRL>

DGMGRL>

DGMGRL> create configuration 'india' as primary database is 'india' connect identifier is india;

Configuration "india" created with primary database "india"

DGMGRL>


DGMGRL>

DGMGRL> show configuration;


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india - Primary database


Fast-Start Failover: DISABLED


Configuration Status:

DISABLED


DGMGRL>

DGMGRL>

DGMGRL> add database 'india_stby' as connect identifier is india_stby maintained as physical;

Error: ORA-16698: member has a LOG_ARCHIVE_DEST_n parameter with SERVICE attribute set

Failed.

DGMGRL>

DGMGRL> add database 'india_stby' as connect identifier is india_stby maintained as physical;

Database "india_stby" added

DGMGRL>

DGMGRL>

DGMGRL> show configuration


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india      - Primary database

    india_stby - Physical standby database


Fast-Start Failover: DISABLED


Configuration Status:

DISABLED


DGMGRL>

DGMGRL>

DGMGRL> enable configuration;

Enabled.

DGMGRL>

DGMGRL>

DGMGRL> show configuration


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india      - Primary database

    india_stby - Physical standby database


Fast-Start Failover: DISABLED


Configuration Status:

SUCCESS   (status updated 51 seconds ago)


DGMGRL>



DGMGRL> show database india InconsistentProperties

INCONSISTENT PROPERTIES

   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE


DGMGRL>


DGMGRL>

DGMGRL> show database india_stby InconsistentProperties

INCONSISTENT PROPERTIES

   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE


DGMGRL>



DGMGRL>

DGMGRL> show database india


Database - india


  Role:               PRIMARY

  Intended State:     TRANSPORT-ON

  Instance(s):

    india


Database Status:

SUCCESS


DGMGRL> show database india_stby


Database - india_stby


  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 1 second ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 1.00 KByte/s

  Real Time Query:    ON

  Instance(s):

    india_stby


Database Status:

SUCCESS


DGMGRL>






DGMGRL>

DGMGRL> show database india_stby statusreport

STATUS REPORT

       INSTANCE_NAME   SEVERITY ERROR_TEXT


DGMGRL>


DGMGRL>

DGMGRL> show database india statusreport

STATUS REPORT

       INSTANCE_NAME   SEVERITY ERROR_TEXT


DGMGRL>


ORA-16698: member has a LOG_ARCHIVE_DEST_n parameter with SERVICE attribute set

ORA-16698: member has a LOG_ARCHIVE_DEST_n parameter with SERVICE attribute set

==================================================================

DGMGRL>

DGMGRL> create configuration 'india' as primary database is 'india' connect identifier is india;

Configuration "india" created with primary database "india"

DGMGRL>

DGMGRL> show configuration;


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india - Primary database


Fast-Start Failover: DISABLED


Configuration Status:

DISABLED



DGMGRL>

DGMGRL> add database 'india_stby' as connect identifier is india_stby maintained as physical;

Error: ORA-16698: member has a LOG_ARCHIVE_DEST_n parameter with SERVICE attribute set


Failed.

DGMGRL>





Steps to resolve issue in 12c

========================================


DGMGRL> disable configuration;

DGMGRL> remove configuration;


Disable log_archive_dest_2 on both Primary/standby

=====================================================


alter system set log_archive_dest_2='' scope=both;


SQL> show parameter log_archive_dest_2


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_dest_2                   string      service=india_stby async valid

                                                 _for=(online_logfiles,primary_

                                                 role) db_unique_name=india_stb

                                                 y



SQL> alter system set log_archive_dest_2='' scope=both;


System altered.


SQL> show parameter log_archive_dest_2


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_dest_2                   string

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>



SQL> show parameter log_archive_dest_2


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_dest_2                   string      service=india_stby_stby async

                                                 valid_for=(online_logfiles,pri

                                                 mary_role) db_unique_name=indi

                                                 a_stby

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


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_dest_27                  string

log_archive_dest_28                  string

log_archive_dest_29                  string

SQL>

SQL> alter system set log_archive_dest_2='' scope=both;


System altered.


SQL>  show parameter log_archive_dest_2


NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

log_archive_dest_2                   string

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>



Disable/Enable Data Guard broker on both Primary/standby




SQL> alter system set dg_broker_start=false scope=both;


System altered.


SQL> alter system set dg_broker_start=true scope=both;


System altered.


SQL>

SQL>



[oracle@ip-10-0-1-12 ~]$ dgmgrl sys/sys@india

DGMGRL for Linux: Release 12.2.0.1.0 - Production on Sat May 8 12:45:37 2021


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


Welcome to DGMGRL, type "help" for information.

Connected to "india"

Connected as SYSDBA.

DGMGRL>

DGMGRL>

DGMGRL>


DGMGRL>  create configuration 'india' as primary database is 'india' connect identifier is india;

Configuration "india" created with primary database "india"

DGMGRL>

DGMGRL> show configuration


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india - Primary database


Fast-Start Failover: DISABLED


Configuration Status:

DISABLED


DGMGRL>




DGMGRL>

DGMGRL>  create configuration 'india' as primary database is 'india' connect identifier is india;

Configuration "india" created with primary database "india"

DGMGRL>

DGMGRL> show configuration


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india - Primary database


Fast-Start Failover: DISABLED


Configuration Status:

DISABLED


DGMGRL> add database 'india_stby' as connect identifier is india_stby maintained as physical;

Database "india_stby" added

DGMGRL>

DGMGRL>

DGMGRL> show configuration


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india      - Primary database

    india_stby - Physical standby database


Fast-Start Failover: DISABLED


Configuration Status:

DISABLED


DGMGRL>




Enbale LOG_ARCHIVE_DEST_2 and check log shipping is working fine 

============================================================================


Primary

*************


ALTER SYSTEM SET log_archive_dest_2='service=india_stby async valid_for=(online_logfiles,primary_role) db_unique_name=india_stby' SCOPE=BOTH;


Standby

************


ALTER SYSTEM SET log_archive_dest_2='service=india async valid_for=(online_logfiles,primary_role) db_unique_name=india' SCOPE=BOTH;





DGMGRL>

DGMGRL> show configuration


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india      - Primary database

    india_stby - Physical standby database


Fast-Start Failover: DISABLED


Configuration Status:

DISABLED


DGMGRL>

DGMGRL> enable configuration;

Enabled.

DGMGRL>


DGMGRL>

DGMGRL> show configuration


Configuration - india


  Protection Mode: MaxPerformance

  Members:

  india      - Primary database

    india_stby - Physical standby database


Fast-Start Failover: DISABLED


Configuration Status:

SUCCESS   (status updated 51 seconds ago)


DGMGRL>



DGMGRL> show database india InconsistentProperties

INCONSISTENT PROPERTIES

   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE


DGMGRL>


DGMGRL>

DGMGRL> show database india_stby InconsistentProperties

INCONSISTENT PROPERTIES

   INSTANCE_NAME        PROPERTY_NAME         MEMORY_VALUE         SPFILE_VALUE         BROKER_VALUE


DGMGRL>



DGMGRL>

DGMGRL> show database india


Database - india


  Role:               PRIMARY

  Intended State:     TRANSPORT-ON

  Instance(s):

    india


Database Status:

SUCCESS


DGMGRL> show database india_stby


Database - india_stby


  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 1 second ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 1.00 KByte/s

  Real Time Query:    ON

  Instance(s):

    india_stby


Database Status:

SUCCESS


DGMGRL>




DGMGRL> show database verbose india


Database - india


  Role:               PRIMARY

  Intended State:     TRANSPORT-ON

  Instance(s):

    india


  Properties:

    DGConnectIdentifier             = 'india'

    ObserverConnectIdentifier       = ''

    LogXptMode                      = 'ASYNC'

    RedoRoutes                      = ''

    DelayMins                       = '0'

    Binding                         = 'optional'

    MaxFailure                      = '0'

    MaxConnections                  = '1'

    ReopenSecs                      = '300'

    NetTimeout                      = '30'

    RedoCompression                 = 'DISABLE'

    LogShipping                     = 'ON'

    PreferredApplyInstance          = ''

    ApplyInstanceTimeout            = '0'

    ApplyLagThreshold               = '30'

    TransportLagThreshold           = '30'

    TransportDisconnectedThreshold  = '30'

    ApplyParallel                   = 'AUTO'

    ApplyInstances                  = '0'

    StandbyFileManagement           = 'AUTO'

    ArchiveLagTarget                = '0'

    LogArchiveMaxProcesses          = '4'

    LogArchiveMinSucceedDest        = '1'

    DataGuardSyncLatency            = '0'

    DbFileNameConvert               = '/u01/app/oracle/oradata/india, /u01/app/oracle/oradata/india_stby'

    LogFileNameConvert              = '/u01/app/oracle/oradata/india, /u01/app/oracle/oradata/india_stby'

    FastStartFailoverTarget         = ''

    InconsistentProperties          = '(monitor)'

    InconsistentLogXptProps         = '(monitor)'

    SendQEntries                    = '(monitor)'

    LogXptStatus                    = '(monitor)'

    RecvQEntries                    = '(monitor)'

    PreferredObserverHosts          = ''

    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXXXXXX)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=india_DGMGRL)(INSTANCE_NAME=india)(SERVER=DEDICATED)))'

    StandbyArchiveLocation          = '/u01/app/oracle/product/12.2.0/dbhome_1/dbs/arch'

    AlternateLocation               = ''

    LogArchiveTrace                 = '0'

    LogArchiveFormat                = '%t_%s_%r.dbf'

    TopWaitEvents                   = '(monitor)'


  Log file locations:

    Alert log               : /u01/app/oracle/diag/rdbms/india/india/trace/alert_india.log

    Data Guard Broker log   : /u01/app/oracle/diag/rdbms/india/india/trace/drcindia.log


Database Status:

SUCCESS


DGMGRL>




DGMGRL> show database verbose india_stby


Database - india_stby


  Role:               PHYSICAL STANDBY

  Intended State:     APPLY-ON

  Transport Lag:      0 seconds (computed 1 second ago)

  Apply Lag:          0 seconds (computed 1 second ago)

  Average Apply Rate: 1.00 KByte/s

  Active Apply Rate:  64.00 KByte/s

  Maximum Apply Rate: 64.00 KByte/s

  Real Time Query:    ON

  Instance(s):

    india_stby


  Properties:

    DGConnectIdentifier             = 'india_stby'

    ObserverConnectIdentifier       = ''

    LogXptMode                      = 'ASYNC'

    RedoRoutes                      = ''

    DelayMins                       = '0'

    Binding                         = 'optional'

    MaxFailure                      = '0'

    MaxConnections                  = '1'

    ReopenSecs                      = '300'

    NetTimeout                      = '30'

    RedoCompression                 = 'DISABLE'

    LogShipping                     = 'ON'

    PreferredApplyInstance          = ''

    ApplyInstanceTimeout            = '0'

    ApplyLagThreshold               = '30'

    TransportLagThreshold           = '30'

    TransportDisconnectedThreshold  = '30'

    ApplyParallel                   = 'AUTO'

    ApplyInstances                  = '0'

    StandbyFileManagement           = 'AUTO'

    ArchiveLagTarget                = '0'

    LogArchiveMaxProcesses          = '5'

    LogArchiveMinSucceedDest        = '1'

    DataGuardSyncLatency            = '0'

    DbFileNameConvert               = '/u01/app/oracle/oradata/india, /u01/app/oracle/oradata/india_stby'

    LogFileNameConvert              = '/u01/app/oracle/oradata/india, /u01/app/oracle/oradata/india_stby'

    FastStartFailoverTarget         = ''

    InconsistentProperties          = '(monitor)'

    InconsistentLogXptProps         = '(monitor)'

    SendQEntries                    = '(monitor)'

    LogXptStatus                    = '(monitor)'

    RecvQEntries                    = '(monitor)'

    PreferredObserverHosts          = ''

    StaticConnectIdentifier         = '(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=XXXXX)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=india_stby_DGMGRL)(INSTANCE_NAME=india_stby)(SERVER=DEDICATED)))'

    StandbyArchiveLocation          = 'USE_DB_RECOVERY_FILE_DEST'

    AlternateLocation               = ''

    LogArchiveTrace                 = '0'

    LogArchiveFormat                = '%t_%s_%r.dbf'

    TopWaitEvents                   = '(monitor)'


  Log file locations:

    Alert log               : /u01/app/oracle/diag/rdbms/india_stby/india_stby/trace/alert_india_stby.log

    Data Guard Broker log   : /u01/app/oracle/diag/rdbms/india_stby/india_stby/trace/drcindia_stby.log


Database Status:

SUCCESS


DGMGRL>



Convert Physical Standby To Snapshot Standby Database

 

Convert Physical Standby To Snapshot Standby Database 

===================================================================

High Level Steps to converting physical standby database to snapshot standby database  

===================================================================

  • No gap 
  • enable flashback standby side
  • shutdown and start in mount standby database 
  • convert to snapshot standby


Steps to  converting back a snapshot standby database to physical standby database

=====================================================================

  • Shut down the snapshot standby database and open it in Mount mode.
  • Convert the snapshot standby database to physical standby database
  • Bounce the physical standby database and start the Managed Recovery Process (MRP) on it.

 


Primary database Details

====================================

SQL>

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u01/app/oracle/product/12.2.0/dbhome_1/dbs/arch

Oldest online log sequence     17

Next log sequence to archive   19

Current log sequence           19

SQL>

SQL>

SQL> select status,instance_name,database_role,open_mode from v$database,v$Instance;


STATUS       INSTANCE_NAME    DATABASE_ROLE    OPEN_MODE

------------ ---------------- ---------------- --------------------

OPEN         india            PRIMARY          READ WRITE

SQL>

SQL> select thread#,max(sequence#) from v$archived_log group by thread#;

   THREAD# MAX(SEQUENCE#)

---------- --------------

         1             18

SQL>


Standby database Details:

=================================

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

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE

--------- ------------------------------ ---------------- --------------------

INDIA     india_stby                     PHYSICAL STANDBY READ ONLY WITH APPLY


check gap status ( make sure no gap )

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$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL  WHERE  ARCH.THREAD# = APPL.THREAD#  ORDER BY 1;


    Thread Last Sequence Received Last Sequence Applied Difference

---------- ---------------------- --------------------- ----------

         1                     18                    18          0

SQL>

SQL>

SQL> select thread#,max(sequence#) from v$archived_log where applied='YES' group by thread#;

   THREAD# MAX(SEQUENCE#)

---------- --------------

         1             18

SQL>

SQL> select flashback_on from v$database;

FLASHBACK_ON

------------------

NO

SQL>

SQL> show parameter db_recovery_file_dest;

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string

db_recovery_file_dest_size           big integer 0

SQL>

SQL>

SQL> alter database flashback on;

alter database flashback on

*

ERROR at line 1:

ORA-38706: Cannot turn on FLASHBACK DATABASE logging.

ORA-38709: Recovery Area is not enabled.


SQL> alter system set db_recovery_file_dest_size=2;

System altered.


SQL> show parameter db_recovery_file_dest;

NAME                                 TYPE        VALUE

------------------------------------ ----------- ------------------------------

db_recovery_file_dest                string

db_recovery_file_dest_size           big integer 2

SQL>

SQL> select name from V$RECOVERY_FILE_DEST;

NAME

---------------------------------------------------------------------

SQL> show parameter reco

NAME                                 TYPE        VALUE

------------------------------------ ----------- --------------------

control_file_record_keep_time        integer     7

db_recovery_file_dest                string

db_recovery_file_dest_size           big integer 2

db_unrecoverable_scn_tracking        boolean     TRUE

recovery_parallelism                 integer     0

remote_recovery_file_dest            string

SQL>

SQL>

SQL> alter system set db_recovery_file_dest='/u01/app/oracle/fra' scope=both;


System altered.


SQL> select name from V$RECOVERY_FILE_DEST;


NAME

-----------------------------------------------------------

/u01/app/oracle/fra


SQL> alter database flashback on;

alter database flashback on

*

ERROR at line 1:

ORA-01153: an incompatible media recovery is active

SQL>


Cancel recovery process

==============================

SQL>

SQL> alter database recover managed standby database cancel;

Database altered.

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

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE

--------- ------------------------------ ---------------- --------------------

INDIA     india_stby                     PHYSICAL STANDBY READ ONLY

SQL>

shutdown standby database and startup mount 

===============================================

SQL>

SQL> shut immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

SQL>

SQL> startup mount

ORACLE instance started.


Total System Global Area 1048576000 bytes

Fixed Size                  8628640 bytes

Variable Size             369100384 bytes

Database Buffers          662700032 bytes

Redo Buffers                8146944 bytes

Database mounted.

SQL>

SQL> select flashback_on from v$database;

FLASHBACK_ON

------------------

NO

SQL> alter database flashback on ;

alter database flashback on

*

ERROR at line 1:

ORA-38706: Cannot turn on FLASHBACK DATABASE logging.

ORA-38708: not enough space for first flashback database log file

SQL>


* we have to increase recovery size 


SQL> alter system set db_recovery_file_dest_size=3g;

System altered.

SQL> alter database flashback on ;

Database altered.

SQL> select flashback_on from v$database;

FLASHBACK_ON

------------------

YES


Now convert it to snapshot standby

=========================================

SQL> select status from v$instance;

STATUS

------------

MOUNTED

SQL> alter database convert to snapshot standby ;

Database altered.

SQL>

SQL> alter database open;

Database altered.

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

NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE

--------- ------------------------------ ---------------- --------------------

INDIA     india_stby                     SNAPSHOT STANDBY READ WRITE


SQL>

SQL> select NAME,GUARANTEE_FLASHBACK_DATABASE from v$restore_point;

NAME                                                                                                                             GUA

-------------------------------------------------------------------------------------------------------------------------------- ---

SNAPSHOT_STANDBY_REQUIRED_05/08/2021 11:17:56                                                                                    YES


SQL>

for Testing create table in this snapshot standby

===================================================

SQL> create table hr.test_snap (id number(5),name varchar2(50));

Table created.

SQL>

SQL> insert into hr.test_snap values (1,'ANURAG');

1 row created.

SQL> commit;

Commit complete.

SQL> select * from hr.test_snap;

        ID NAME

---------- --------------------------------------------------

         1 ANURAG


SQL>

SQL>

SQL>

SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     1

Next log sequence to archive   1

Current log sequence           1

SQL>

SQL>



SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     1

Next log sequence to archive   1

Current log sequence           1

SQL>

SQL>

SQL> alter system switch logfile;


System altered.


SQL> /


System altered.


SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            USE_DB_RECOVERY_FILE_DEST

Oldest online log sequence     1

Next log sequence to archive   3

Current log sequence           3

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


NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE

--------- ------------------------------ ---------------- --------------------

INDIA     india_stby                     SNAPSHOT STANDBY READ WRITE



on primary 

=================


SQL> archive log list

Database log mode              Archive Mode

Automatic archival             Enabled

Archive destination            /u01/app/oracle/product/12.2.0/dbhome_1/dbs/arch

Oldest online log sequence     18

Next log sequence to archive   20

Current log sequence           20

SQL>

SQL> alter system switch logfile;


System altered.


SQL> /


System altered.


SQL>  select thread#,max(sequence#) from v$archived_log group by thread#;


   THREAD# MAX(SEQUENCE#)

---------- --------------

         1             21

SQL>

SQL>  select status,instance_name,database_role,open_mode from v$database,v$Instance;

STATUS       INSTANCE_NAME    DATABASE_ROLE    OPEN_MODE

------------ ---------------- ---------------- --------------------

OPEN         india            PRIMARY          READ WRITE


SQL>


Convert it again to physical standby again.

===================================================


Shut down the snapshot standby database and open it in Mount mode.

==================================================================


SQL> shut immediate;

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

SQL> startup mount

ORACLE instance started.


Total System Global Area 1048576000 bytes

Fixed Size                  8628640 bytes

Variable Size             369100384 bytes

Database Buffers          662700032 bytes

Redo Buffers                8146944 bytes

Database mounted.

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


NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE

--------- ------------------------------ ---------------- --------------------

INDIA     india_stby                     SNAPSHOT STANDBY MOUNTED


SQL>


Convert the snapshot standby database to physical standby database.

===================================================================

SQL>

SQL>

SQL> alter database convert to physical standby;

Database altered.


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


NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE

--------- ------------------------------ ---------------- --------------------

INDIA     india_stby                     PHYSICAL STANDBY MOUNTED


Bounce the standby database 

===========================

SQL> alter database open;

Database altered.


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


NAME      DB_UNIQUE_NAME                 DATABASE_ROLE    OPEN_MODE

--------- ------------------------------ ---------------- --------------------

INDIA     india_stby                     PHYSICAL STANDBY READ ONLY


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


Database altered.


SQL>



SQL> select process,status,sequence# from v$managed_standby;


PROCESS   STATUS        SEQUENCE#

--------- ------------ ----------

ARCH      CONNECTED             0

DGRD      ALLOCATED             0

DGRD      ALLOCATED             0

ARCH      CONNECTED             0

ARCH      CLOSING              24

ARCH      CONNECTED             0

ARCH      CONNECTED             0

RFS       IDLE                 25

RFS       IDLE                  0

MRP0      APPLYING_LOG         25


10 rows selected.




on primary

============


SQL> select thread#,max(sequence#) from v$archived_log group by thread#;


   THREAD# MAX(SEQUENCE#)

---------- --------------

         1             27


SQL>



on standby 

===============



PROCESS   STATUS        SEQUENCE#

--------- ------------ ----------

ARCH      CLOSING              26

DGRD      ALLOCATED             0

DGRD      ALLOCATED             0

ARCH      CONNECTED             0

ARCH      CLOSING              27

ARCH      CLOSING              25

ARCH      CONNECTED             0

RFS       IDLE                 28

RFS       IDLE                  0

MRP0      APPLYING_LOG         28


10 rows selected.


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$LOG_HISTORY WHERE (THREAD#,FIRST_TIME ) IN (SELECT THREAD#,MAX(FIRST_TIME) FROM V$LOG_HISTORY GROUP BY THREAD#)) APPL  WHERE  ARCH.THREAD# = APPL.THREAD#  ORDER BY 1;


    Thread Last Sequence Received Last Sequence Applied Difference

---------- ---------------------- --------------------- ----------

         1                     27                    27          0


SQL>




Table does not exists which we created during database was snapshot standby 

=================================================================================



SQL>

SQL>

SQL> select * from hr.test_snap;

select * from hr.test_snap

                 *

ERROR at line 1:

ORA-00942: table or view does not exist

SQL>