Failover: changes a standby database to be the primary database. Failover is performed where the standby database changes its role to primary database, the previous primary database no longer becomes part of Data Guard configuration and a new standby database is required to be configured.
Switchover: switches roles between a primary and standby database. Switchover is mostly performed when the primary database is going to be unavailable for maintenance issues etc.
Q1. Create a table on the primary database, perform a switchover using SQL*Plus, create another table on the new primary database, switch database back and check both tables. (20min)
1. Create a table on the primary database, and convert to the standby database.
/* on node1 */
CREATE TABLE RYU (id number, name varchar2(20) not null);
INSERT INTO RYU VALUES (1,'RYU');
INSERT INTO RYU VALUES (2,'KIM');
COMMIT;
ALTER SYSTEM SWITCH LOGFILE;
2. switchover database
/* on node1 */
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY;
alter database open read only;
SELECT name, switchver_status FROM v$database;
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
/* on node2 */
ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN;
ALTER DATABASE OPEN;
select switchover_status FROM v$database;
3. Create a table on the new primary database, and convert to the new standby database.
/* on node2 */
CREATE TABLE RYU2 (id number, name varchar2(20));
INSERT INTO RYU2 VALUES (3,'YAMAMOTO');
INSERT INTO RYU2 VALUES (4,'SUZUKI');
COMMIT;
ALTER SYSTEM SWITCH LOGFILE;
/* on node1 */
SELECT * FROM RYU2;
Q2. Create a table on the primary database, perform a switchover using DGMGRL, create another table on the new primary database, switch database back and check both tables. (20min)
/* DGMGRL */
show configuration
switchover to oradb_s2;
Q3. Perform failover using SQL*Plus (5min)
alter database recover managed standby database cancel;
alter database recover managed stnadby database finish;
SELECT switchover_status FROM v$database;
Q4. Perform failover using DGMGRL (5min)
/* DGMGRL */
show configuration
failover to oradb;