By Mouhamadou Diaw

In this blog we will talk about how to do a switchover and how to do a failover. We suppose that dbvisit is already installed and that a standby database is already configured. Our instance is named DBPRIMA.

Switchover
SWITCHOVER is the fact to change database role. The primary becomes the standby and the standby becomes the primary. This can be useful for many reasons.
Before performing a switchover, we have first to send archived logs if any not already sent on the primary server. For this we use the magic command dbvctl

[oracle@dbvisit2 DBPRIMA]$ /u01/app/dbvisit/standby/dbvctl -d DBPRIMA
=============================================================
Dbvisit Standby Database Technology (8.0.04.18184) (pid 9201)
dbvctl started on dbvisit2: Tue Nov 29 14:46:15 2016
=============================================================
>>> Applying Log file(s) from dbvisit1 to DBPRIMA on dbvisit2:
thread 1 sequence 30 (1_30_926978008.arc)
=============================================================
dbvctl ended on dbvisit2: Tue Nov 29 14:46:17 2016
=============================================================
[oracle@dbvisit2 DBPRIMA]$

After let’s apply all archived logs on the standby

[oracle@dbvisit2 DBPRIMA]$ /u01/app/dbvisit/standby/dbvctl -d DBPRIMA
=============================================================
Dbvisit Standby Database Technology (8.0.04.18184) (pid 9201)
dbvctl started on dbvisit2: Tue Nov 29 14:46:15 2016
=============================================================
>>> Applying Log file(s) from dbvisit1 to DBPRIMA on dbvisit2:
thread 1 sequence 30 (1_30_926978008.arc)
=============================================================
dbvctl ended on dbvisit2: Tue Nov 29 14:46:17 2016
=============================================================
[oracle@dbvisit2 DBPRIMA]$

Note that the commands above can be scheduled on both servers using crontab for example on linux system
On the Primary Server:

00,10,20,30,40,50 * * * * cd /u01/app/dbvisit/standby; ./dbvctl -d DBPRIMA >>/dev/null 2>&1

On the Standby Server:

00,10,20,30,40,50 * * * * cd /u01/app/dbvisit/standby; ./dbvctl -d DBPRIMA >>/dev/null 2>&1

After sending and applying archived logs, we can check the status of the synchronization

[oracle@dbvisit1 ~]$ /u01/app/dbvisit/standby/dbvctl -d DBPRIMA -i
=============================================================
Dbvisit Standby Database Technology (8.0.04.18184) (pid 4420)
dbvctl started on dbvisit1: Tue Nov 29 14:26:11 2016
=============================================================
Dbvisit Standby log gap report for DBPRIMA thread 1 at 201611291426:
-------------------------------------------------------------
Destination database on dbvisit2 is at sequence: 29.
Source database on dbvisit1 is at log sequence: 30.
Source database on dbvisit1 is at archived log sequence: 29.
Dbvisit Standby last transfer log sequence: 29.
Dbvisit Standby last transfer at: 2016-11-29 14:24:16.
Archive log gap for DBPRIMA: 0.
Transfer log gap for DBPRIMA: 0.
Standby database time lag (DAYS-HH:MI:SS): +0:01:37.
=============================================================
dbvctl ended on dbvisit1: Tue Nov 29 14:26:12 2016
=============================================================
[oracle@dbvisit1 ~]$

If all is ok, we can now we can go for the SWITCHOVER. We can do it either by the graphical console or by command line. We are using the command line method. The command should be run only on the primary server.

[oracle@dbvisit1 ~]$ /u01/app/dbvisit/standby/dbvctl -d DBPRIMA -o switchover
=============================================================
Dbvisit Standby Database Technology (8.0.04.18184) (pid 5081)
dbvctl started on dbvisit1: Tue Nov 29 14:47:32 2016
=============================================================
>>> Starting Switchover between dbvisit1 and dbvisit2
Running pre-checks ... done
Pre processing ... done
Processing primary ... done
Processing standby ... done
Converting standby ... done
Converting primary ... done
Completing ... done
Synchronizing ... done
Post processing ... done
>>> Graceful switchover completed.
Primary Database Server: dbvisit2
Standby Database Server: dbvisit1
>>> Dbvisit Standby can be run as per normal:
dbvctl -d DBPRIMA
PID:5081
TRACE:5081_dbvctl_switchover_DBPRIMA_201611291447.trc
=============================================================
dbvctl ended on dbvisit1: Tue Nov 29 14:50:23 2016
=============================================================
[oracle@dbvisit1 ~]$

Failover
The FAILOVER process happens when the primary database is no longer working. In this case the standby should be activated and will become the primary one. This FAILOVER process is NOT reversible unlike SWITCHOVER process.
A good practice before activating the standby database is to run a quick test to ensure that the standby database is in a consistent state (datafile headers and controlfile is in sync) and ready to be activated. This can be done by opening the standby database read-only.

[oracle@dbvisit2 ~]$ /u01/app/dbvisit/standby/dbvctl -d DBPRIMA -o read
=============================================================
Dbvisit Standby Database Technology (8.0.04.18184) (pid 2542)
dbvctl started on dbvisit2: Wed Nov 30 09:40:50 2016
=============================================================
Open Standby Database DBPRIMA in READ ONLY mode...
Standby Database DBPRIMA opened in READ ONLY mode.
Log files cannot be applied to Database while in READ ONLY mode.
Database tempfile(s) may need to be added to this database.
=============================================================
dbvctl ended on dbvisit2: Wed Nov 30 09:40:55 2016
=============================================================
[oracle@dbvisit2 ~]$

As we don’t get any error and that we know we can open the standby read-only, let’s start it back into recovery mode (mount state).

[oracle@dbvisit2 ~]$ /u01/app/dbvisit/standby/dbvctl -d DBPRIMA -o restart
=============================================================
Dbvisit Standby Database Technology (8.0.04.18184) (pid 2667)
dbvctl started on dbvisit2: Wed Nov 30 09:45:45 2016
=============================================================
Stopping instance DBPRIMA...
Standby Instance DBPRIMA shutdown successfully on dbvisit2.
Starting instance DBPRIMA...
Standby Instance DBPRIMA started
=============================================================
dbvctl ended on dbvisit2: Wed Nov 30 09:45:57 2016
=============================================================
[oracle@dbvisit2 ~]$

And proceed with the FAILOVER. Dbvisit will ask to confirm. We can use the –force option to avoid this.

[oracle@dbvisit2 ~]$ /u01/app/dbvisit/standby/dbvctl -d DBPRIMA -o activate
=============================================================
Dbvisit Standby Database Technology (8.0.04.18184) (pid 2796)
dbvctl started on dbvisit2: Wed Nov 30 09:47:12 2016
=============================================================
Activating means this database will become a Primary Database.
It will no longer be a Standby Database for DBPRIMA on dbvisit1.
Activation cannot be reversed.
=>Activate Standby Database on dbvisit2? [No]: yes
Are you sure? [No]: yes
>>> Activating now...
File /u01/app/dbvisit/standby/conf/dbv_DBPRIMA.env copied to
/u01/app/dbvisit/standby/conf/dbv_DBPRIMA.env.201611300947.
>>> Activation complete. Please ensure a backup of this Database is made
>>> Old archives from before the activation should be removed to avoid mix-up between new
and old archive logs
>>> If the Dbvisit Standby process is to be reversed, then database on dbvisit1 will need
to be rebuilt as a Standby Database
=============================================================
dbvctl ended on dbvisit2: Wed Nov 30 09:48:07 2016
=============================================================
[oracle@dbvisit2 ~]$

In this article we have seen how easy it is to do a switchover or failover with Dbvisit 8 .