0% found this document useful (0 votes)
15 views3 pages

Switchover

The document outlines the steps for performing a switchover between a primary and standby database in Oracle. It includes SQL commands to check the state of the databases, verify archived logs, and execute the switchover process. The final steps confirm the successful transition of the database roles and open modes.

Uploaded by

tpyzvc6g2d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views3 pages

Switchover

The document outlines the steps for performing a switchover between a primary and standby database in Oracle. It includes SQL commands to check the state of the databases, verify archived logs, and execute the switchover process. The final steps confirm the successful transition of the database roles and open modes.

Uploaded by

tpyzvc6g2d
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

Primary database:-

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

===================================================================
Standby database:-

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

NAME OPEN_MODE DATABASE_ROLE


--------- -------------------- ----------------
DBWR MOUNTED PHYSICAL STANDBY
=====================================================================
Precheck for Switchover:- (PRIMARY SIDE)

Before performing switchover, kindly verify the state of data guard on both the
instances by following SQL queries:

Step 2:-

SQL> ALTER SESSION SET nls_date_format='DD-MON-YYYY HH24:MI:SS';

Session altered.
SQL> SELECT sequence#, first_time, next_time, applied FROM v$archived_log ORDER BY
sequence#;

SEQUENCE# FIRST_TIME NEXT_TIME APPLIED


---------- -------------------- -------------------- ---------
3 13-MAR-2019 18:59:20 13-MAR-2019 23:55:09 NO
4 13-MAR-2019 23:55:09 14-MAR-2019 20:04:18 NO
5 14-MAR-2019 20:04:18 14-MAR-2019 20:43:17 NO
6 14-MAR-2019 20:43:17 15-MAR-2019 01:35:09 NO
7 15-MAR-2019 01:35:09 15-MAR-2019 22:57:54 NO
8 15-MAR-2019 22:57:54 16-MAR-2019 00:11:18 NO
8 15-MAR-2019 22:57:54 16-MAR-2019 00:11:18 YES
9 16-MAR-2019 00:11:18 16-MAR-2019 00:47:08 NO
9 16-MAR-2019 00:11:18 16-MAR-2019 00:47:08 YES
10 16-MAR-2019 00:47:08 16-MAR-2019 01:54:56 NO
10 16-MAR-2019 00:47:08 16-MAR-2019 01:54:56 YES

11 rows selected.
Step 3:-

SQL> select switchover_status from v$database;

SWITCHOVER_STATUS
--------------------
TO STANDBY
Not Allowed:-Either this is a standby database and the primary database has not
been switched first, or this is a primary database and there are no standby
databases
Session Active:- Indicates that there are active SQL sessions attached to the
primary or standby database that need to be disconnected before the switchover
operation is permitted
Switchover Pending:- This is a standby database and the primary database switchover
request has been received but not processed.
Switchover Latent:- The switchover was in pending mode, but did not complete and
went back to the primary database
To Primary:- This is a standby database, with no active sessions, that is allowed
to switch over to a primary database
To Standby:- This is a primary database, with no active sessions, that is allowed
to switch over to a standby database
Recovery Needed:- This is a standby database that has not received the switchover
request

On Primary database:-

Step 4:

SQL> alter database commit to switchover to standby;

Database altered.
Step 5:-

shutdown immediate

startup nomount

alter database mount standby database

[oracle@ram dbs]$ sqlplus / as sysdba

SQL*Plus: Release 19.0.0.0.0 - Production on Sat Mar 16 02:20:17 2019


Version 19.2.0.0.0

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

Connected to an idle instance.

SQL> startup nomount


ORACLE instance started.

Total System Global Area 2415917872 bytes


Fixed Size 8899376 bytes
Variable Size 654311424 bytes
Database Buffers 1744830464 bytes
Redo Buffers 7876608 bytes
SQL> alter database mount standby database;

Database altered.
SQL> alter database recover managed standby database disconnect from session;

Database altered.
=============
-------------
STEP 6:-
-------------
=============
SQL> select name,open_mode,database_role from v$database;

NAME OPEN_MODE DATABASE_ROLE


--------- -------------------- ----------------
DBWR READ WRITE PRIMARY

=========
-----------------------------------------------------------------------------------
-------------------------------------------
Step 7:-
-----------------------------------------------------------------------------------
--------------------------------------------
=========
alter database commit to switchover to primary;

SQL> alter database commit to switchover to primary;

Database altered.
=====================================================
Step 8:-

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

NAME OPEN_MODE DATABASE_ROLE


--------- -------------------- ----------------
DBWR MOUNTED PRIMARY

archivelog_size_hourly.sql

You might also like