Performing Role Transitions
1) Switchover
- Planned role transition
- Used for operating-system or hardware maintenance
- Manually invoked on primary database
2) Failover
- Unplanned role transition
- Used in an emergency
- Minimal or no data loss (depending on the data-protection mode)
- Fast-start failover can be enabled for automatic failover
- Initiated at standby database
Performing Switchover and Failover
Switchover:
You
can use the switchover feature to switch the role of the primary database to
one of the available standby databases. The chosen standby database becomes the
primary data base, and the original primary database then becomes a standby
database. There is no need to re-create any of the databases involved in the
switchover operation. There is no data divergence between the original and new
primary databases after successful completion of the switchover.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
On Standby
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
NOT ALLOWED
On Primary Database
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO STANDBY
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL
STANDBY WITH SESSION SHUTDOWN WAIT;
SQL> SHUTDOWN IMMEDIATE;
SQL> startup mount
ORACLE instance started.
Total System Global Area 452984832 bytes
Fixed Size 1297244 bytes
Variable Size 213910692 bytes
Database Buffers 230686720 bytes
Redo Buffers 7090176 bytes
Database mounted.
SQL> SELECT SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
SQL> select
database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
On Standby Database (Should not be in Recovery)
SQL> SELECT
SWITCHOVER_STATUS FROM V$DATABASE;
SWITCHOVER_STATUS
--------------------
SWITCHOVER PENDING
SQL> alter database recover managed standby
database cancel;
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
shut down and restart the new primary database.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY
Issue the following statement on the new primary database
SQL> alter database
open;
Database altered.
SQL>
SQL> ALTER SYSTEM SWITCH LOGFILE;
Check with archive log list
Or
SQL> select sequence#, first_time, next_time, applied
from v$archived_log order by sequence#;
Failover:
You
invoke a failover operation when a failure occurs on the primary database and
there is no possibility of recovering the primary database in a timely manner.
During a failover operation, the standby database assumes the primary database
role. You invoke the failover operation on the standby database that you want
to fail over to the primary role.
Note: You can enable fast-start
failover to fail over automatically when the primary database becomes
unavailable. When fast-start failover is enabled, the broker determines if a
failover is necessary and initiates the failover to the specified target
standby database automatically, with no need for DBA intervention and with no
loss of data. For details, see the lesson titled
“Enabling Fast-Start Failover.”
Check Gaps first
SQL> select protection_mode from v$database;
PROTECTION_MODE
--------------------
MAXIMUM
PERFORMANCE
SQL>
On Standby
SQL> SELECT thread#, low_sequence#, high_sequence# FROM
v$archive_gap;
no rows selected
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PHYSICAL STANDBY
SQL> alter database recover managed standby database
finish force;
Database altered.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
Database altered.
SQL> select database_role from v$database;
DATABASE_ROLE
----------------
PRIMARY
SQL> select open_mode from v$database;
OPEN_MODE
----------
MOUNTED
SQL> alter database open;
Database altered.
SQL> show parameter unique
NAME TYPE VALUE
------------------------------------ -----------
------------------------------
db_unique_name string stdy
SQL> select standby_became_primary_scn from v$database;
STANDBY_BECAME_PRIMARY_SCN
--------------------------
619042
Perform a Switchover with DG Broker
After
verifying the conditions required for executing a switchover, execute the SWITCHOVER
command to perform the switchover operation. The Data Guard broker performs the
following operations:
1.
Verifies that the primary database and target standby database are in the
correct states
2.
Shuts down any instances as necessary
3.
Switches roles between the primary and standby databases
4.
Updates the broker configuration file with the new role information
5.
Restarts the new standby database
6.
Opens the new primary database in read/write mode and starts redo transport
services
Note: For detailed information about each step, see Oracle
Data Guard Broker.
Connect to DGMGRL on the observer server:
$ dgmgrl
DGMGRL> connect sys/oracle@ORCL
Connected.
DGMGRL>
Check that primary
and standby are healthy. This check must return 'SUCCESS' as the status
for both databases, otherwise it means there is a configuration problem.
DGMGRL> show database ORCL;
Database
Name: orcl
Role: PRIMARY
Enabled: YES
Intended State: TRANSPORT-ON
Instance(s):
orcl
Current status for "orcl":
SUCCESS
DGMGRL> show database STDY;
Database
Name: stdy
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: APPLY-ON
Instance(s):
stdy
Current status for "stdy":
SUCCESS
Execute the switchover
DGMGRL> SWITCHOVER TO STDY;
DGMGRL> show database STDY;
Database
Name: stdy
Role: PRIMARY
Enabled: YES
Intended
State: ONLINE
Instance(s):
stdy
Current status for "stdy":
SUCCESS
DGMGRL>
DGMGRL> show database ORCL;
Database
Name: orcl
Role: PHYSICAL STANDBY
Enabled: YES
Intended
State: ONLINE
Instance(s):
orcl
Current status for "orcl":
SUCCESS
DGMGRL>
DGMGRL> SHOW CONFIGURATION VERBOSE;
Configuration
Name: orcl
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: ENABLED
Databases:
orcl - Physical standby database
- Fast-Start Failover target
stdy - Primary database
Fast-Start Failover
Threshold: 30 seconds
Observer: punjab-cc977a23
Shutdown Primary: TRUE
Current status for "orcl":
SUCCESS
DGMGRL>
Thanks (Commands plz)
No comments:
Post a Comment