Wednesday, January 14, 2026

perform Manual Switchover and Failover on Physical Standby

1.Perform Manual Switchover on Physical Standby

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



Connect to test database via client and keep querying below


sqlplus sys/sys@test as sysdba

 

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

 

NAME      OPEN_MODE      DB_UNIQUE_NAME         DATABASE_ROLE

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

test    READ WRITE     test                 PRIMARY

Check primary and standby for any gaps


On primary:

===========

select STATUS, GAP_STATUS from V$ARCHIVE_DEST_STATUS where DEST_ID = 2;

 

On standby:

===========

select NAME, VALUE, DATUM_TIME from V$DATAGUARD_STATS;

We will first convert primary to standby and later standby to primary


On primary:

===========

select SWITCHOVER_STATUS from V$DATABASE;

You must see TO STANDBY or SESSIONS ACTIVE


SQL>alter database commit to switchover to physical standby with session shutdown;

 

SQL>startup mount;


At this stage, there is no primary to accept queries from client. Run below query on client putty terminal. The query will hang and wait until standby is converted to primary.


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


Convert standby to primary: Our primary is already converted to standby. Now it’s time to convert original standby into primary


select SWITCHOVER_STATUS from V$DATABASE;

 

SQL>alter database commit to switchover to primary with session shutdown;

 

SQL> alter database open;


At this stage, the client query would execute successfully!



On new standby – Initially your primary database: Start MRP


SQL>alter database recover managed standby database disconnect;


Revert back: Once again follow the above process from top and re-execute steps in proper databases to revert back to original setup.





2. Performing Manual Failover on Physical Standby

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



Failover is when your primary database is completely lost. When there is a failover, standby is converted into primary but primary is not converted into standby as it is lost. If you do not have Flashback enabled on primary, you must re-create primary from scratch (Using RMAN duplicate method). In this example, we have already enabled flashback on both primary and standby.

 

Our current physical standby server overview

Database SID

Database Role

Test

Primary Database

test_s

Physical Standby

Crash Primary database



Let’s crash primary (test): In order to simulate failure, we will shut down the primary server test. As root user, shutdown the server without shutting down DB.



Execute query on client: At this stage, there is no primary to accept queries from client. Run below query on client putty terminal. The query will hang and wait until standby is converted to primary


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



3. Perform Failover to Standby

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



On standby:     switch physical standby to primary

===========

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;

then finish the database recovery and is no more required

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;

at this stage database is ready to be open and converted to primary so if you don't finish it it won't be able to be converted to primary. here how we check it

SQL> select SWITCHOVER_STATUS from V$DATABASE;

You must see TO PRIMARY or SESSIONS ACTIVE. Switch standby to primary


SQL> alter database commit to switchover to primary with session shutdown;

SQL> alter database open;


Check client query: Check the query you executed in step 2 on client, it must get executed





 

Oracle 12c Installation on Oracle Linux

 

Install Oracle 12c on Oracle Linux with ease using this guide.

In this article, we will be looking at Oracle 12cR2 installation on Oracle Linux 7.7 version. The steps are exactly same for OEL 6 and all other versions of OEL 7.x

Oracle 12c Prerequisites


Use the YUM repository to perform all the pre-install steps. Make sure your VM is able to ping google.com before executing below command

yum install -y oracle-database-server-12cR2-preinstall

Set password for the oracle user

passwd oracle

Create directories which will hold Oracle software installation

mkdir -p /u01/app/oracle/product/12.2.0.1
chown -R oracle:oinstall /u01
chmod -R 775 /u01

Setup Oracle user bash_profile

su - oracle
vi .bash_profile

Delete all and paste below. Make sure to change environment variables according to your environment

# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs
export ORACLE_HOME=/u01/app/oracle/product/12.2.0.1
export ORACLE_BASE=/u01/app/oracle
export ORACLE_SID=prod

export NLS_LANG=american_america.al32utf8
export NLS_DATE_FORMAT="yyyy-mm-dd:hh24:mi:ss"

PATH=$PATH:$HOME/.local/bin:$ORACLE_HOME/bin

export PATH

Export the bash profile

. .bash_profile

Download Oracle 12c and copy the 12c software file to /tmp location and unzip into ORACLE_HOME location

cd $ORACLE_HOME

unzip -qo /tmp/linuxx64_12201_database.zip

At this stage, you have two options to install Oracle software: silent mode and graphical mode. We will look at both methods below, choose the one that suits your environment.


Oracle 12c Silent Install


Start the run installer in silent mode to begin the installation

cd $ORACLE_HOME/database

./runInstaller -ignoreSysPrereqs -showProgress -silent       \
oracle.install.option=INSTALL_DB_SWONLY                      \
ORACLE_HOSTNAME=${HOSTNAME}                                  \
UNIX_GROUP_NAME=oinstall                                     \
INVENTORY_LOCATION=/u01/app/oraInventory                     \
SELECTED_LANGUAGES=en,en_GB                                  \
ORACLE_HOME=${ORACLE_HOME}                                   \
ORACLE_BASE=${ORACLE_BASE}                                   \
oracle.install.db.InstallEdition=EE                          \
oracle.install.db.OSDBA_GROUP=dba                            \
oracle.install.db.OSOPER_GROUP=dba                           \
oracle.install.db.OSBACKUPDBA_GROUP=dba                      \
oracle.install.db.OSDGDBA_GROUP=dba                          \
oracle.install.db.OSKMDBA_GROUP=dba                          \
oracle.install.db.OSRACDBA_GROUP=dba                         \
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false                   \
DECLINE_SECURITY_UPDATES=true                                \
oracle.installer.autoupdates.option=SKIP_UPDATES

Once installation is completed, run the root scripts and you can move to DBCA create database.

Logical Standby in Oracle Data Guard Overview

  In Oracle Data Guard , a Logical Standby Database is a standby database that: Receives redo data from the Primary database Convert...