Choosing a Target Standby Database for a Role Transition

Nel documento Oracle® Data Guard Concepts and Administration 10g (pagine 109-113)

Creating a Logical Standby Database

Step 5 Trace the progression of transmitted redo on the standby site

7.1 Introduction to Role Transitions

7.1.2 Choosing a Target Standby Database for a Role Transition

For a Data Guard configuration with multiple standby databases, there are a number of factors to consider when choosing the target standby database for a role transition.

These include the following:

Locality of the standby database.

The capability of the standby database (hardware specifications—such as the number of CPUs, I/O bandwidth available, and so on).

The time it will take to perform the role transition. This is affected by how far behind the standby database is in terms of application of redo data, and how much flexibility you have in terms of trading off application availability with data loss.

Data Guard provides the V$DATAGUARD_STATS view that can be used to estimate the viability of each standby database in terms of the currency of the data in the standby database, and the time it will take to perform a role transition if all available redo data is applied to the standby database. For example:

SQL> COLUMN NAME FORMAT A18 SQL> COLUMN VALUE FORMAT A16

SQL> COLUMN TIME_COMPUTED FORMAT A24 SQL> SELECT * FROM V$DATAGUARD_STATS;

NAME VALUE TIME_COMPUTED

--- --- ---apply finish time +00 00:00:02.4 15-MAY-2005 10:32:49 second(1)

interval

apply lag +00 0:00:04 15-MAY-2005 10:32:49 second(0)

interval

transport lag +00 00:00:00 15-MAY-2005 10:32:49 second(0)

interval

This shows that for this standby database, there is no transport lag, that log apply services have not applied the redo generated in the last 4 seconds (apply lag), and that it will take log apply services 2.4 seconds to finish applying the unapplied redo (apply finish time). The time at which each of the statistics is computed is shown in the TIME_COMPUTED column.

If the configuration contains both physical and logical standby databases, consider choosing a physical standby database to be the target standby database. A switchover or failover to a physical standby database is preferable because all databases in the

Note: Even though only one RAC instance on the standby database is open during the switchover, all other standby database instances will automatically undergo a transition to their new role correctly when they are opened.

Introduction to Role Transitions

database. You will then need to re-create the physical standby databases from a backup of the new primary database before you can reenable them.

7.1.3 Switchovers

A switchover is typically used to reduce primary database downtime during planned outages, such as operating system or hardware upgrades, or rolling upgrades of the Oracle database software and patch sets (described in Chapter 11, "Using SQL Apply to Upgrade the Oracle Database").

A switchover takes place in two phases. In the first phase, the existing primary database undergoes a transition to a standby role. In the second phase, a standby database undergoes a transition to the primary role.

Figure 7–1 shows a two-site Data Guard configuration before the roles of the databases are switched. The primary database is in San Francisco, and the standby database is in Boston.

Figure 7–1 Data Guard Configuration Before Switchover

Figure 7–2 shows the Data Guard environment after the original primary database was switched over to a standby database, but before the original standby database has become the new primary database. At this stage, the Data Guard configuration temporarily has two standby databases.

Figure 7–2 Standby Databases Before Switchover to the New Primary Database San Francisco

Boston Application

Application 0001

0002 Online Redo

Log Files Local Archiving Primary Database

Read/Write Transactions

Read-Only Access Oracle Net

Standby Database

Archived Redo Log Files

Archived Redo Log Files

Boston

Application Application

Standby Database Archived Redo Log Files Standby Database Archived Redo

Log Files

San Francisco

Introduction to Role Transitions

Figure 7–3 shows the Data Guard environment after a switchover took place. The original standby database became the new primary database. The primary database is now in Boston, and the standby database is now in San Francisco.

Figure 7–3 Data Guard Environment After Switchover

Preparing for a Switchover

Ensure the prerequisites listed in Section 7.1.1 are satisfied. In addition, the following prerequisites must be met for a switchover:

For switchovers involving a physical standby database, verify the primary database instance is open and the standby database instance is mounted.

The standby database that you plan to change to the primary role must be mounted before you begin the switchover. Ideally, the physical standby database will also be actively applying redo when the database roles are switched. If the physical standby database is open for read-only access, the switchover still will take place, but will require additional time. See Section 6.3, "Applying Redo Data to Physical Standby Databases" on page 6-4 for more information about Redo Apply.

For switchovers involving a logical standby database, verify both the primary and standby database instances are open and that SQL Apply is active. See Section 6.4,

"Applying Redo Data to Logical Standby Databases" on page 6-5 for more information about SQL Apply.

For switchovers involving a primary database in a Real Applications Cluster, all but one instance must be shut down. Once the switchover is performed

successfully, you can bring all other instances back online.

When a database transitions from one role to another, the DB_ROLE_CHANGE system event fires. You can write a trigger that's associated with this system event to manage tasks after a switchover occurs. The event fires when the database opens for the first time after the switchover regardless of its new role (that is, regardless of whether the switchover caused it to open for the first time as a primary database, as a logical standby, or as a physical standby in read-only mode). You can query the DATABASE_

ROLE column of the V$DATABASE view to determine a database’s current role. See the table of system manager events in Oracle Database Application Developer's Guide -

Application

Introduction to Role Transitions

7.1.4 Failovers

A failover is typically used only when the primary database becomes unavailable, and there is no possibility of restoring it to service within a reasonable period of time. The specific actions performed during a failover vary based on whether a logical or a physical standby database is involved in the failover, the state of the Data Guard configuration at the time of the failover, and on the specific SQL statements used to initiate the failover.

Figure 7–4 shows the result of a failover from a primary database in San Francisco to a physical standby database in Boston.

Figure 7–4 Failover to a Standby Database

Preparing for a Failover

If possible, before performing a failover, you should transfer as much of the available and unapplied primary database redo data as possible to the standby database.

Ensure the prerequisites listed in Section 7.1.1, "Preparing for a Role Transition (Failover or Switchover)" on page 7-2 are satisfied. In addition, the following prerequisites must be met for a failover:

If a standby database currently running in maximum protection mode will be involved in the failover, first place it in maximum performance mode by issuing the following statement on the standby database:

SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;

Then, if appropriate standby databases are available, you can reset the desired protection mode on the new primary database after the failover completes.

This is required because you cannot fail over to a standby database that is in maximum protection mode. In addition, if a primary database in maximum protection mode is still actively communicating with the standby database, issuing the ALTER DATABASE statement to change the standby database from maximum protection mode to maximum performance mode will not succeed. Because a failover removes the original primary database from the Data Guard

configuration, these features serve to protect a primary database operating in maximum protection mode from the effects of an unintended failover.

San Francisco

Role Transitions Involving Physical Standby Databases

When a database transitions from one role to another, the DB_ROLE_CHANGE system event fires. You can write a trigger that's associated with this system event to manage tasks after a failover occurs. The event fires when the database opens for the first time after the failover regardless of its new role (in the case of a failover to a physical standby database, the system event will fire when the database is opened for the first time after a failover operation). You can query the DATABASE_ROLE column of the V$DATABASE view to determine a database’s current role. See the table of system manager events in Oracle Database Application Developer's Guide - Fundamentals for more details.

To perform a failover involving a physical standby database, see Section 7.2.2,

"Failovers Involving a Physical Standby Database" on page 7-9. To perform a failover involving a logical standby database, see Section 7.3.2, "Failovers Involving a Logical Standby Database" on page 7-16. To perform a failover using the Data Guard broker, see the chapter about "Switchover and Failover Operations" in Oracle Data Guard Broker.

Nel documento Oracle® Data Guard Concepts and Administration 10g (pagine 109-113)