Вы находитесь на странице: 1из 40

Performing Switchover and Failover

Copyright 2006, Oracle. All rights reserved.


Objectives

After completing this lesson, you should be able to do the


following:
Explain the database roles
Perform a switchover
Perform a failover
Use Flashback Database after a failover

9-2 Copyright 2006, Oracle. All rights reserved.


Types of Roles in an
Oracle Data Guard Configuration

There are two types of roles in an Oracle Data Guard


configuration:
User role: identifies the group and determines the
privileges assigned to a user.
Database role: identifies what role (primary or standby)
the database plays in a Data Guard configuration.

SQL> SELECT database_role FROM v$database;


DATABASE_ROLE
----------------
LOGICAL STANDBY

9-3 Copyright 2006, Oracle. All rights reserved.


Role Management Services

A database operates in one of two mutually exclusive


roles in a Data Guard configuration:
Primary role: The database is operating in the primary
role, and redo transport services are shipping redo to the
standby databases.
Standby role: The database is operating in the standby
role, and log apply services are applying the archived
redo logs to the standby database.
With role management services, you can change these
roles dynamically.

9-4 Copyright 2006, Oracle. All rights reserved.


Role Transitions: Switchover and Failover

Not automatically invoked


Switchover
Planned role reversal
Used for OS or hardware maintenance
Failover
Unplanned role reversal
Used in an emergency
Minimal or no data loss depending on the
data-protection mode
Fast-start failover can be enabled for automatic failover

9-5 Copyright 2006, Oracle. All rights reserved.


Choosing the Best Role Transition Operation

Are you performing a planned role


Switch over to
transition so that you can perform Yes
best available
hardware or software maintenance
standby
on the system that currently hosts
database.
the primary database?

No
Can you run crash recovery to Repair
repair the primary database in
Yes
primary
a timely manner? database.

No
Fail over to best available
standby database.

9-7 Copyright 2006, Oracle. All rights reserved.


Switchover

Transitions the roles of the primary and standby


databases
No resetting of the online redo logs of the new primary
database
No data loss

9-8 Copyright 2006, Oracle. All rights reserved.


Switchover: Before

Read/write Primary
transactions database

Application

San Francisco Oracle Net


Boston

Standby Read-only
database reports

Application

9-9 Copyright 2006, Oracle. All rights reserved.


Switchover: After

Read-only Standby
reports database

Application

San Francisco Oracle Net


Boston

Primary Read/write
database transactions

Application

9 - 10 Copyright 2006, Oracle. All rights reserved.


Standby Redo Logs and Switchovers

Standby redo logs should be configured on the primary


database to ease switchovers.
Standby
Online redo redo
logs Redo logs
shipment

Primary Standby
database database
RFS

Standby
redo
logs

9 - 11 Copyright 2006, Oracle. All rights reserved.


Preparing for a Switchover

Verify the following in preparation for the switchover


operation: network connectivity between the primary and
standby locations.

9 - 12 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover by Using
Enterprise Manager

Select the database and


click Switchover.

9 - 13 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover by Using
Enterprise Manager

Click Yes to confirm.

9 - 14 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover by Using
Enterprise Manager

9 - 15 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover
to a Physical Standby by Using SQL

Perform these steps only if you are not using the Data
Guard broker.
On the original primary database:
1. Verify that it is possible to perform a switchover
operation.
2. Initiate the switchover operation on the primary
database:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO
2 PHYSICAL STANDBY;
3. Shut down and restart the instance.

9 - 16 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover
to a Physical Standby by Using SQL

On the original physical standby database:


1. Verify the switchover status in the V$DATABASE view.
2. Switch the physical standby database role to the
primary role.
3. If the standby database was opened read-only, shut
down and restart the new primary database. If it was
not opened read-only, open the database.
4. Begin archiving logs to the physical standby database.

9 - 17 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover
to a Logical Standby by Using SQL

On the original primary database:


1. Verify that it is possible to perform a switchover.
2. Prepare the primary database for the switchover:

SQL> ALTER DATABASE PREPARE TO SWITCHOVER


2 TO LOGICAL STANDBY;

9 - 18 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover
to a Logical Standby by Using SQL

On the original logical standby database:


3. Prepare the logical standby database for switchover:

SQL> ALTER DATABASE PREPARE TO SWITCHOVER


2 TO PRIMARY;

9 - 19 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover
to a Logical Standby by Using SQL

On the original primary database:


4. Verify the switchover status in V$DATABASE.
5. Switch the primary database to the logical standby
database role:
SQL> ALTER DATABASE COMMIT TO SWITCHOVER
2 TO LOGICAL STANDBY;

9 - 20 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover
to a Logical Standby by Using SQL

On the new primary database (original logical standby


database):
6. Verify the switchover status in V$DATABASE.
7. Switch the logical standby database to the primary
database role.
SQL> ALTER DATABASE COMMIT TO SWITCHOVER
2 TO PRIMARY;
8. Ensure that all standby databases begin receiving redo
data.
SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;

9 - 21 Copyright 2006, Oracle. All rights reserved.


Performing a Switchover
to a Logical Standby by Using SQL

On the new logical standby database:


9. Start SQL Apply.

SQL> ALTER DATABASE


2 START LOGICAL STANDBY APPLY;

9 - 22 Copyright 2006, Oracle. All rights reserved.


Considerations When Performing a Switchover to
a Logical Standby Database

Switchover operation does not cause a shutdown of


the primary.
There is no need to terminate user sessions, but
termination is recommended.
Logical standby database may not have all data.

9 - 23 Copyright 2006, Oracle. All rights reserved.


Situations That Prevent a Switchover

You cannot perform a switchover in the following


situations:
Archived redo log files are unavailable.
Point-in-time recovery is required.
Production database is not open and cannot be
opened.

9 - 24 Copyright 2006, Oracle. All rights reserved.


Failover
Local
Archiving

Primary Online Redo Archived redo


database Logs logs

San Francisco
Application
Boston
Read/write Local
transactions archiving

Standby Online redo Archived redo


database becomes logs logs
primary database.

9 - 25 Copyright 2006, Oracle. All rights reserved.


Failover Considerations

Old primary database is no longer part of the


configuration.
Data loss is possible.
Failover should be used only in an emergency.
Special-case failover: activation of a standby

9 - 26 Copyright 2006, Oracle. All rights reserved.


Performing a Failover by Using
Enterprise Manager

Select the database and


click Failover.

9 - 27 Copyright 2006, Oracle. All rights reserved.


Performing a Failover by Using
Enterprise Manager

9 - 28 Copyright 2006, Oracle. All rights reserved.


Performing a Failover by Using
Enterprise Manager

Select the failover type and


click Yes.

9 - 29 Copyright 2006, Oracle. All rights reserved.


Performing a Failover by Using
Enterprise Manager

9 - 30 Copyright 2006, Oracle. All rights reserved.


Performing a Failover
to a Physical Standby Database

The physical standby


database needs to be
reinstated.

9 - 31 Copyright 2006, Oracle. All rights reserved.


Performing a Failover
to a Logical Standby Database

The logical standby database


is now the primary database.
The physical standby
database is disabled.

9 - 32 Copyright 2006, Oracle. All rights reserved.


Performing a Failover to a
Physical Standby Database by Using SQL

1. Identify and resolve any gaps in the archived redo log


files.
2. Repeat step 1 until all gaps are resolved.
3. Copy any other missing archived redo log files.
4. Initiate the failover operation on the target standby
database.
5. Convert the physical standby database to the primary
role.
6. Complete the transition of the standby database to the
primary database role.
7. (Optional) Back up the new primary database.
8. (Optional) Restore the failed primary database.

9 - 33 Copyright 2006, Oracle. All rights reserved.


Performing a Failover to a
Logical Standby Database by Using SQL

1. Copy missing redo logs to the logical standby


database.
2. Register the missing redo logs:
SQL> ALTER DATABASE REGISTER LOGICAL
2 LOGFILE 'filespec';

3. If it exists, register the partially filled archive log file.


4. Ensure that all redo log files have been applied to the
new primary database.
SQL> SELECT APPLIED_SCN, LATEST_SCN
2 FROM V$LOGSTDBY_PROGRESS;

9 - 36 Copyright 2006, Oracle. All rights reserved.


Performing a Failover to a
Logical Standby Database by Using SQL

5. Activate the new primary database:


SQL> ALTER DATABASE ACTIVATE
2 LOGICAL STANDBY DATABASE
3 FINISH APPLY;
6. Enable archiving of redo logs.
7. Begin SQL Apply operations on all logical standby
databases:
SQL> ALTER DATABASE START LOGICAL STANDBY
2 APPLY NEW PRIMARY dblink;

9 - 37 Copyright 2006, Oracle. All rights reserved.


Activating a Standby Database

When you are unable to fail over, you can activate a


standby database by issuing one of the following
commands (depending on the role of the database):

SQL> ALTER DATABASE ACTIVATE


2 PHYSICAL STANDBY DATABASE;

SQL> ALTER DATABASE ACTIVATE


2 LOGICAL STANDBY DATABASE;

9 - 38 Copyright 2006, Oracle. All rights reserved.


Restoring Databases After a Role Transition

Additional steps may be needed to restore your disaster-


recovery solution after a role transition:
Databases may be disabled, but are not removed from
the broker configuration.
Reenable broker management of the databases:
Reinstate databases using the REINSTATE DATABASE
command or through Enterprise Manager.
Re-create databases from a copy of the primary database
and reenable the database.

9 - 39 Copyright 2006, Oracle. All rights reserved.


Flashback Through Standby Database
Role Transitions

Use Flashback Database to flash back a database to a


point in time before a switchover or failover.
Primary and standby databases retain their current
roles when you flash back through physical standby
switchovers or failovers.
Database roles will be flashed back when you flash
back through logical standby switchovers or failovers.
Flashback database can be used to undo a physical
database activation.

9 - 40 Copyright 2006, Oracle. All rights reserved.


Using Flashback Database After Failover

Primary Standby
database database

Redo

Flashback Failover

Redo
New standby database New primary database

9 - 41 Copyright 2006, Oracle. All rights reserved.


Summary

In this lesson, you should have learned how to:


Use the Data Guard GUI to perform switchover and
failover operations
Use SQL commands to perform switchover and failover
operations
Use Flashback Database after a failover

9 - 44 Copyright 2006, Oracle. All rights reserved.


Practice 9: Overview

This practice covers the following topics:


Performing a switchover
Performing a failover

9 - 45 Copyright 2006, Oracle. All rights reserved.

Вам также может понравиться