Saturday, February 8, 2025

Oracle Data Guard Primary and Standby Shutdown & Startup Process

=====================Shutdown Process (Primary and Standby)======================


-- Check the current role of databases (Primary and Standby )

SQL> SELECT DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;

--Shutdown the Standby Database First

sqlplus / as sysdba


--Checking log services: 
SQL> SELECT DEST_ID, STATUS, DESTINATION, ERROR FROM V$ARCHIVE_DEST WHERE TARGET='STANDBY';

--Stop log apply services: 

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

--Shutdown the standby database

SQL> SHUTDOWN IMMEDIATE;



--Shutdown the Primary Database

sqlplus / as sysdba
--Shutdown the primary database

SQL> SHUTDOWN IMMEDIATE;

======================Startup Process (Primary and Standby)=======================

--Start the Primary Database First

--Startup the primary database

SQL> STARTUP;

--Verify the database role

SQL> SELECT DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;

DATABASE_ROLE    OPEN_MODE
---------------- --------------------
PRIMARY          READ WRITE


--Checking log shipping 
SELECT DEST_ID, STATUS, DESTINATION, ERROR FROM V$ARCHIVE_DEST WHERE TARGET='STANDBY';

  • Ensure STATUS is VALID and there are no errors.
  • If you see errors, check the DESTINATION path and fix any issues.

  • SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=ENABLE;

    --Start the Standby Database

    sqlplus / as sysdba
    --Startup the standby database in mount mode

    SQL> STARTUP MOUNT;

    --Start log apply services

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

    Database altered.

    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

    Database altered.

    SQL> alter database open read only;

    Database altered.

    SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;

    Database altered.

    -- Verify log apply status:
    SQL> SELECT PROCESS, STATUS FROM V$MANAGED_STANDBY;

    --Ensure the database is in standby mode:
    SQL> SELECT DATABASE_ROLE, OPEN_MODE FROM V$DATABASE;

    DATABASE_ROLE    OPEN_MODE
    ---------------- --------------------
    PHYSICAL STANDBY READ ONLY WITH APPLY

    Database altered.

    No comments:

    Post a Comment

     https://www.linkedin.com/pulse/building-real-time-database-monitoring-dashboard-oracle-khaleeq-tpwxf/