Beruflich Dokumente
Kultur Dokumente
D67578
May 2010
Edition 3.0
D52161GC30
Student Guide
Administration
Oracle Database 11g: Data Guard
Donna K. Keesling This document contains proprietary inf ormation and is protected by copy right and
other intellectual property law s. You may copy and print this document solely for your
own use in an Oracle training course. The document may not be modif ied or altered in
Technical Contributors any w ay. Except where your use constitutes "fair use" under copyright law , you may
and Reviewers not use, share, download, upload, copy , print, display , perf orm, reproduce, publish,
license, post, transmit, or distribute this document in whole or in part without the
Todd Bao express authorization of Oracle.
Harald van Breederode The inf ormation contained in this document is subject to change without notice. If y ou
Michael Cebulla f ind any problems in the document, please report them in writing to: Oracle Univ ersity ,
500 Oracle Parkway , Redwood Shores, Calif ornia 94065 USA. This document is not
Joel Goodman w arranted to be error-free.
Uwe Hesse
Restricted Rights Notice
Pete Jones
If this documentation is deliv ered to the United States Gov ernment or any one using
Nitin Karkhanis
the documentation on behalf of the United States Gov ernment, the f ollowing notice is
Frank Kobylanski applicable:
Sadhana Kyathappala U.S. GOVERNMENT RIGHTS
Stephen Moriarty The U.S. Gov ernment’s rights to use, modif y , reproduce, release, perf orm, display , or
disclose these training materials are restricted by the terms of the applicable Oracle
Javier Saiz license agreement and/or the applicable U.S. Gov ernment contract.
Madhavi Siddireddy
Trademark Notice
Jim Spiller
Oracle and Jav a are registered trademarks of Oracle and/or its af f iliates. Other names
Milgred Tumolo
may be trademarks of their respectiv e owners.
Branislav Valny
Jean-Francois Verrier
Pam Welford
Editors
Aju Kumar
Amitha Narayan
Nita Pavitran
Graphic Designer
Satish Bettegowda
Publishers
Syed Imtiaz Ali
Sumesh Koshy
Veena Narasimhan
unarski inzenjering d.o.o use only
Contents
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Preface
iii
Specifying Role-Based Destinations 2-15
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
iv
Data Guard Overview Page 3-15
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
v
Step 3: Select the Standby Database Location Oracle Home 5-12
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Step 4: Specify the Standby Database File Locations (Staging Method) 5-13
Step 4: Specify the Standby Database File Locations 5-14
Step 5: Specify Standby Database Configuration Parameters 5-15
Step 6: Review the Configuration Information 5-16
Standby Database Creation: Processing 5-17
Standby Database Creation: Progress 5-19
Verifying a Data Guard Configuration 5-20
Reviewing Results of the Verify Operation 5-21
Performing Routine Maintenance 5-22
vi
Step 7: Verify That the Logical Standby Database Is Performing
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Properly 6-25
Step 7: Verify That the Logical Standby Database Is Performing Properly 6-26
Creating a Logical Standby Database by Using Enterprise Manager 6-27
Using the Add Standby Database Wizard 6-28
Securing Your Logical Standby Database 6-31
Automatic Deletion of Redo Log Files by SQL Apply 6-32
Managing Remote Archived Log File Retention 6-33
Managing SQL Apply Filtering 6-34
Viewing SQL Apply Filtering Settings 6-36
vii
Configuring Zero Lag Between the Primary and Standby Databases 8-13
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
viii
Considerations When Performing a Switchover to a Logical Standby
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Database 10-13
Situations That Prevent a Switchover 10-14
Failover 10-15
Types of Failovers 10-16
Failover Considerations 10-17
Performing a Manual Failover by Using DGMGRL 10-18
Reenabling Disabled Databases by Using DGMGRL 10-19
Performing a Failover by Using Enterprise Manager 10-20
Performing a Failover to a Physical Standby Database 10-23
ix
Setting the Lag-Time Limit 12-12
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
x
Connecting Clients to the Correct Database 13-13
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
xi
Excluding the Standby Database 14-27
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Quiz 14-28
Summary 14-30
Practice 14: Overview 14-31
xii
Configuration 16-15
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
xiii
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
xiv
Oracle University and Digit racunarski inzenjering d.o.o use only
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Preface
Before you begin this course, you should be able to perform basic Oracle Database
11g administration.
How This Course Is Organized
Oracle Database 11g: Data Guard Administration is an instructor- led course
featuring lectures and hands-on exercises. Online demonstrations and written
practice sessions reinforce the concepts and skills that are introduced.
Preface - 3
Related Publications
Oracle Publications
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Preface - 4
Typographic Conventions
The following two lists explain Oracle University typographical conventions for
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Preface - 5
Typographic Conventions (continued)
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Preface - 6
HESE eKIT MATERIALS ARE FOR YOUR USE IN THIS CLASSROOM ONLY. COPYING eKIT MATERIALS FROM THIS COMPUTER IS STRICTLY PROHIBIT ED
Primary Standby
database Redo transport database
Database Database
copy
the broker. To reenable broker management of these databases, you must reinstate or re-create
the databases.
Note: See the lesson titled ―Performing Switchover and Failover‖ for detailed information.
Oracle
Management
Server
Repository
Agent Agent
Primary
(Overview)
database MRP or Standby
transactions LSP database
LNSn RFS
Redo
buffer
Oracle n et
LGWR (Real-time
Primary
MRP or Standby
database
LSP database
transactions
LNSn RFS
Redo
buffer
Oracle n et
LGWR (Real-time
Primary
MRP or Standby
database
LSP database
transactions
LNSn RFS
Redo
buffer
Oracle n et
LGWR (Real-time
Backup
Reports
Primary
MRP or Standby
database
LSP database
transactions
LNSn RFS
Redo
buffer
Oracle n et
LGWR (Real-time
This protection mode provides the highest possible level of data protection without
compromising the availability of the primary database. As with maximum protection mode, a
transaction does not commit until the redo needed to recover that transaction is written to the
local online redo log and to at least one remote standby redo log. Unlike maximum protection
mode, the primary database does not shut down if a fault prevents it from writing its redo stream
to a remote standby redo log. Instead, the primary database operates in an unsynchronized
mode until the fault is corrected and all the gaps in the redo log files are resolved. When all the
gaps are resolved and the primary database is synchronized with the standby database, the
primary database automatically resumes operating in maximum availability mode.
This mode guarantees that no data loss occurs if the primary database fails, but only if a second
Answer: a, c, d
Answer: c
NOLOGGING mode. Therefore, it is recommended that you enable FORCE LOGGING mode when
the database is in the MOUNT state.
Note: You should enable FORCE LOGGING before performing the backup operation to create the
standby database, and then maintain FORCE LOGGING mode for as long as the Data Guard
configuration exists.
Online Standby
redo Redo redo
logs shipment logs
Primary Standby
database database
Standby Archived
Redo from redo logs redo logs
primary database
MRP/LSP
Standby database
or
Setting LOG_ARCHIVE_CONFIG
Specify the DG_CONFIG attribute of the LOG_ARCHIVE_CONFIG parameter to list the
DB_UNIQUE_NAME of the primary and standby databases in the Data Guard configuration. By
default, the LOG_ARCHIVE_CONFIG parameter enables the database to send and receive
redo. The LOG_ARCHIVE_CONFIG parameter can be used to disable the sending of redo logs
to remote destinations or disable the receipt of remote redo logs. The complete syntax for the
LOG_ARCHIVE_CONFIG parameter is as follows:
LOG_ARCHIVE_CONFIG = {
[ SEND | NOSEND ][ RECEIVE | NORECEIVE ]
[ DG_CONFIG=(remote_db_unique_name1
[, ... remote_db_unique_name9) | NODG_CONFIG ] }
Use the V$DATAGUARD_CONFIG view to see the unique database names defined with the
DB_UNIQUE_NAME and LOG_ARCHIVE_CONFIG initialization parameters; you can thus view
the Data Guard environment from any database in the configuration. The first row of the view
lists the unique database name of the current database that was specified with the
DB_UNIQUE_NAME initialization parameter. Additional rows reflect the unique database
names of the other databases in the configuration that were specified with the DG_CONFIG
keyword of the LOG_ARCHIVE_CONFIG initialization parameter.
Setting LOG_ARCHIVE_DEST_ n
By using the various LOG_ARCHIVE_DEST_n attributes, you define most of the settings for
the Data Guard configuration. The Redo Transport Service is directly controlled by these
settings. There are a number of different attributes that can be set for each
LOG_ARCHIVE_DEST_n parameter. Most have defaults that are adequate for most
configurations. See Oracle Data Guard Concepts and Administration for a complete list and a
description of each.
You should specify a LOG_ARCHIVE_DEST_n parameter (where n is an integer from 1 to 31)
for the local archiving destination and one for the standby location. In previous versions of the
Oracle Database, LOG_ARCHIVE_DEST_10 was set to USE_DB_RECOVERY_FILE_DEST
when the fast recovery area was being used. For Oracle Database 11g Release 2, this will
now have to be manually set. Query the V$ARCHIVE_DEST view to see current settings of the
LOG_ARCHIVE_DEST_n initialization parameter.
All defined LOG_ARCHIVE_DEST_n parameters must contain, at a minimum, either a
LOCATION attribute or a SERVICE attribute.
In addition, you must have a LOG_ARCHIVE_DEST_STATE_n parameter for each defined
destination. LOG_ARCHIVE_DEST_STATE_n defaults to ENABLE.
Primary Standby
database database
log_archive_dest_2 = log_archive_dest_2 =
'service=pc01sby1 async 'service=pc01prmy async
valid_for= valid_for=
(online_logfile, (online_logfile,
primary_role) primary_role)
db_unique_name=pc01sby1' db_unique_name=pc01prmy'
database role.
• STANDBY_ROLE: This destination is used only when the database is in the standby
(logical or physical) role.
• ALL_ROLES: This destination is used when the database is in either the primary or the
standby (logical or physical) role.
Note: Because the keywords are unique, the archival_source and database_role values
can be specified in any order.
For example, VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILE) is functionally equivalent to
VALID_FOR=(ONLINE_LOGFILE,PRIMARY_ROLE).
ONLINE_LOGFILE, ALL_ROLES
DB_FILE_NAME_CONVERT
• DB_FILE_NAME_CONVERT must be defined on standby
databases that have different disk or directory structures
from the primary.
• Multiple pairs of file names can be listed in the
DB_FILE_NAME_CONVERT parameter.
LOG_FILE_NAME_CONVERT
• LOG_FILE_NAME_CONVERT is similar to
DB_FILE_NAME_CONVERT.
• LOG_FILE_NAME_CONVERT must be defined on standby
databases that have different disk or directory structures
from the primary.
LOG_FILE_NAME_CONVERT = ('/oracle1/logs/',
'/ora1/stby_logs/')
STANDBY_FILE_MANAGEMENT
• STANDBY_FILE_MANAGEMENT is used to maintain
consistency when you add or delete a data file on the
primary database.
– MANUAL (default)
— Data files must be manually added to the standby database.
DB_NAME=pc01prmy
DB_UNIQUE_NAME=pc01prmy
LOG_ARCHIVE_CONFIG='DG_CONFIG=(pc01prmy,pc01sby1)'
CONTROL_FILES='/u01/app/oracle/oradata/pc01prmy/control1.ctl',
'/u01/app/oracle/oradata/pc01prmy/control2.ctl'
LOG_ARCHIVE_DEST_2=
Creating an Oracle Net Service Name for Your Physical Standby Database
Use Oracle Net Manager to define a network service name for your physical standby
database.
The slide shows the entry in the tnsnames.ora file that was generated by Oracle Net
Manager.
Note: This entry is used to connect to the standby database when invoking RMAN and
executing the DUPLICATE TARGET DATABASE FOR STANDBY FROM ACTIVE DATABASE
command. It is also used in the LOG_ARCHIVE_DEST_2 parameter for the SERVICE value to
define the redo transport to the standby database.
Standby Database
Use Oracle Net Manager to configure an entry for your standby
database in the listener.ora file:
SID_LIST_LISTENER1 =
(SID_LIST =
(SID_DESC =
Copying Your Primary Database Password File to the Physical Standby Database
Host
You must create a password file for your physical standby database by copying the primary
database password file to the physical standby database host and renaming it.
Initialization Parameters
• Fetch archive log (FAL):
– Provides a client/server mechanism for resolving gaps
detected in the range of archived redo logs that are
generated at the primary database and received at the
standby database
– Is applicable for physical standby databases only
spfile
parameter_value_convert 'pc01prmy','pc01sby1'
set db_unique_name='pc01sby1'
set db_file_name_convert='/pc01prmy/','/pc01sby1/'
set log_file_name_convert='/pc01prmy/','/pc01sby1/'
set control_files=
RFS
Primary MRP
database Standby
ARC0
Archived
redo log Standby
files database
For physical standby databases, the managed recovery process (MRP) applies the redo from
the standby redo log files after the remote file server (RFS) process finishes writing. To start
real-time apply for a physical standby database, issue the following command:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE
USING CURRENT LOGFILE;
Note: Standby redo log files are required for real-time apply. You must have one more standby
redo log group than the number of online log groups on the primary database.
Real-time apply is supported and automatically enabled by the broker.
Primary Standby
• TYPICAL on the primary database: The instance logs buffer cache reads for read/write
tablespaces in the redo log
• FULL on the primary database: The instance logs reads for read-only tablespaces as
well as read/write tablespaces
• TYPICAL or FULL on the standby database or on the primary database during media
recovery: The instance performs lost write detection
• NONE on either the primary database or the standby database (the default): No lost
write detection functionality is enabled
Answer: b
Answer: b
• Client-side:
– Oracle Enterprise Manager Grid Control
– DGMGRL (command-line interface)
• Server-side: Data Guard monitor
– DMON process
pc01prmy pc01sby1
Primary Standby
site site
Standby database
Broker-controlled Standby database
databases Standby database
Standby database
Instances Instances
Comparing Configuration Management With and Without the Data Guard Broker
The table in the slide provides an overview of configuration management with and without the
Data Guard broker (source: Table 1-1, ―Configuration Management With and Without the
Broker,‖ in Oracle Data Guard Broker).
Configuration - DGConfig1
Configuration Status:
SUCCESS
DGMGRL Commands
The following commands are available in DGMGRL (the Data Guard CLI). Many of these
commands have additional arguments that are not described here. See Oracle Data Guard
Broker for detailed information.
• ADD: Adds a standby database to the broker configuration
• CONNECT: Connects a given username to the specified instance
• CREATE: Enables you to create broker configurations
• DISABLE: Enables you to disable broker control of a configuration or database so that
the object is no longer managed by the broker
• EDIT: Used to edit a configuration, database, or instance
• ENABLE: Enables you to enable broker control of a configuration or database
• EXIT/QUIT: Exits DGMGRL
• FAILOVER: Performs a database failover operation in which one of the standby
databases changes to the role of primary database (This is an unplanned transition that
may result in the loss of application data.)
Grid Control
Which tools are used to interface with the Data Guard Broker?
a. DGMGRL
b. SRVCTL
c. Enterprise Manager
d. CRSCTL
Answer: a, c
Answer: b
files and in the SPFILE. For static initialization parameters, the value in the SGA may differ from
what is in the configuration files and in the SPFILE. Typically, the broker reconciles the
differences by updating all parameter and property values the next time the database instance is
stopped and restarted.
Note: When using the broker (with Enterprise Manager or DGMGRL), do not attempt to
manually set the parameters that the broker controls. If you set them manually, either you render
your configuration inoperable or the broker simply takes the next opportunity to reset the
parameter to the recorded setting. If you want to change a parameter value, you must change it
by using one of the broker interfaces.
Configuration - DGConfig1
Configuration Status:
SUCCESS
by Using DGMGRL
Specify database properties to manage redo transport services:
• DGConnectIdentifier
• LogXptMode
• LogShipping
Primary
MRP or Standby
database
LSP database
transactions
LNSn RFS
Redo
buffer
Standby ack (Real-time
Oracle Net
Standby
redo logs
Online
redo ARC0
logs
Primary
MRP or Standby
database
LSP database
transactions
LNSn RFS
Redo
buffer
Standby ack (Real-time
Oracle Net
Standby
redo logs
Online
redo
ARC0
logs
How many Data Guard broker configuration files are created for
each database unique name?
a. One
b. Two
c. Three
Answer: b
Answer: d
Creating a Configuration
You can access the Data Guard features in Enterprise Manager Grid Control by clicking
―Setup and Manage‖ in the Data Guard section on the Availability page.
Click the Add Standby Database link to invoke the Add Standby Database Wizard.
to an Existing Configuration
Instance Name
Oracle Home
File Locations
Configuration Parameters
Configuration Information
background is submitted in this step. The Add Standby Database process cannot be
canceled after this step begins.
• Adding standby database target: In this step, the standby database target in
Enterprise Manager is updated with additional information indicating membership in the
Data Guard configuration. This enables enhanced summary information to be displayed
on the Enterprise Manager home page of the standby database.
Answer: b
Answer: b
Reports
LCR
Reader Preparer LCR Builder
:
Redo Shared
records pool
Redo data from Logical change records not
Transactions to Transactions
be applied sorted in
Data files dependency
order
Unsupported Objects
If the primary database contains unsupported tables, log apply services automatically exclude
these tables when applying redo data to the logical standby database.
OWNER TABLE_NAME
20 rows selected.
9 rows selected.
A value of Y indicates that the table does not have a primary or unique constraint and that the
column is defined using an unbounded data type (such as CLOB). If two rows in the table match
except for values in their LOB columns, the table cannot be maintained properly and SQL Apply
stops.
A value of N indicates that the table does not have a primary or unique constraint, but that it
contains enough column information to maintain the table in the logical standby database.
However, the redo transport services and log apply services run more efficiently if you add a
primary key. You should consider adding a disabled RELY constraint to these tables (as
described in the next slide).
RELY Constraint
You can add a disabled RELY constraint to uniquely identify
rows:
SQL> ALTER TABLE hr.employees
2 ADD PRIMARY KEY (employee_id, last_name)
3 RELY DISABLE;
or
DGMGRL> EDIT DATABASE 'pc01sby1' set state='apply-off';
Succeeded.
Is Performing Properly
a. Verify that the archived redo log files were registered:
SQL> SELECT sequence#, first_time, next_time,
2 dict_begin, dict_end
3 FROM dba_logstdby_log ORDER BY sequence#;
Is Performing Properly
d. Verify that redo data is being applied correctly:
SQL> SELECT name, value FROM v$logstdby_stats
2 WHERE name = 'coordinator state';
by SQL Apply
Answer: b
Answer: a
Database
Primary
database MRP Snapshot
transactions standby
database
LGWR LNSn RFS
Transactions
Oracle n et
ARC0
ARC0
Configuration Status:
SUCCESS
Database - pc01sby1
Database Status:
SUCCESS
Answer: b
Redo Redo
transport apply
Database Status:
SUCCESS
The second SHOW DATABASE command may show an Apply Lag depending on redo activity
since Redo Apply had to be stopped during transition.
If your standby database is not managed by the Data Guard broker, you must temporarily stop
Redo Apply to open the physical standby database in read-only mode. After opening the
database, restart Redo Apply. This enables the physical standby database to stay current with
the primary database as users perform queries against data. This can be performed with the
following commands:
DGMGRL> edit database 'pc01sby1' set state='apply-off';
SQL> alter database open read only;
DGMGRL> edit database 'pc01sby1' set state='apply-on';
Configuration
• A standby database configured with real-time apply can
lag behind the primary database as a result of:
– Insufficient CPU capacity
– High network latency
– Limited bandwidth
V$STANDBY_EVENT_HISTOGRAM
• View histogram of apply lag on a physical standby
database.
• Use to assess value for STANDBY_MAX_DATA_DELAY.
• Use to focus on periods of time when the apply lag
exceeds desired levels so that issue can be resolved.
6 rows selected
Standby Databases
• Certain applications have zero tolerance for any lag.
• Query on the standby database must return the same
result as though it were executed on the primary database.
• Enforce by setting STANDBY_MAX_DATA_DELAY to 0.
• The standby database must have advanced to a value
Synchronization
• Use an AFTER LOGON trigger to force a wait for
synchronization between primary and standby databases.
• Use for dedicated connection only.
• This ensures that the reporting application starts with the
current data without requiring a change to the application
Primary Database
• Application characteristics:
– Executes as user U
– Reads table U.R (R) and writes to table U.W (W)
– User S has S.R synonym for U.R and S.W synonym for
U.W@primary.
List of changed
blocks 1011001010110 Change-
CTWR
0001110100101 tracking
Redo 1010101110011 file
generation
SGA Redo log
Answer: b
by Using DGMGRL
1. Configure standby redo logs.
2. Set the LogXptMode property (if necessary).
• Maximum protection: SYNC
• Maximum availability: SYNC
• Maximum performance: ASYNC
Click the
Answer: a, b, d
• Switchover
– Planned role transition
– Used for operating-system or hardware maintenance
– Manually invoked on primary database
• Failover
Switchover
A switchover operation transitions the primary database to the standby role and transitions the
standby database to the primary role, without resetting the online redo logs of the new primary
database.
The primary database at the start of a switchover operation will need to be shutdown and
restarted. The physical standby database is not shutdown and restarted during a switchover.
If the physical standby database is in the Active Data Guard mode, it is closed for the
transition then opened again after the switchover completes, but it is never totally shutdown to
require a restart.
If the switchover operation involves a logical standby database, there is no need to shut down
and restart either the primary database or any of the standby databases. Logical standby
databases do not need to be shut down and restarted.
Note: When necessary, the broker automatically starts and stops all but one instance in a
Real Application Clusters (RAC) environment for the primary database. If the broker is not
used, this must be done manually. Starting with Oracle Database 11g Release 2 (11.2), the
secondary RAC instances of a physical standby database no longer need to be shutdown
during the switchover. They can stay in the mounted or Active Data Guard state. The primary
still requires only one instance be running during a switchover.
Application
Application
Switchover: Before
As an example, suppose that the primary database is located in San Francisco and the
physical standby database is located in Boston. Switchovers are started only on the primary
database and completed on the target standby database. You can be connected to any
database in the configuration through DGMGRL to execute the SWITCHOVER command.
Application
Application
Switchover: After
After the switchover is completed, each database has the role opposite to the one that it had
before the switchover. In this example, Boston is now the primary database and San
Francisco is the standby database.
Because Data Guard does not automatically switch over sessions from one database to the
other, active sessions for each system need to reconnect. See the lesson titled ―Managing
Client Connectivity‖ for information about configuring automatic methods to reconnect
sessions.
Local
Archiving
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 primary database is disabled from the Data Guard environment and a standby database
assumes the primary database role. Failing over to a standby database is a one-way
operation. You cannot "fallback" and return the database to its former role as a standby
database. Because of this, you should invoke a failover operation only in an emergency.
It is not always necessary to fail over to the standby database. In some cases, recovery of the
primary database may be faster. Most failures can be resolved at a primary database in a
reasonable amount of time.
In a failover operation:
• The original primary database is presumed to be lost. (If you want, you can reinstate or
re-create the original primary database as a new standby database. You may then
initiate a switchover operation compared to a failover operation to return the databases
to their original roles.)
• Standby databases that are online at the time of the failover operation, but are not
involved in the role transition, do not need to be shut down and restarted unless they
were ahead of the failover target due to differences in apply lag situations. In that case,
they may need to be flashed back to the point the standby became a primary or re-
created.
Types of Failovers
A manual failover is invoked through DGMGRL or Enterprise Manager. There are two types of
manual failover:
• Complete: The maximum amount of redo data for the protection mode is recovered. In
this type of failover, the broker avoids disabling any standby databases that are not the
failover target. Complete failover is the default and recommended type of failover.
• Immediate: No additional redo data is applied to the standby database after the failover
is invoked. This is the fastest type of failover. After an immediate failover, you must re-
create or reinstate the original primary database and all standby databases that were
not a target of the failover.
Note: You should always try to perform a complete failover. Perform an immediate failover
only when a complete failover is unsuccessful. Depending on the destination attributes of redo
transport services, a complete failover can take place without incurring any data loss, while an
immediate failover usually results in the loss of data.
You can configure fast-start failover so that the broker automatically fails over to a chosen
standby database in the event of the loss of the primary database. For details, see the lesson
titled ―Enabling Fast-Start Failover.‖
Failover Considerations
During a failover operation, a standby database transitions to the primary role and the old
primary database is rendered unable to participate in the configuration. Depending on the
protection mode under which the old primary database was operating before the failover,
there may be some or no data loss during a failover.
A failover is typically used only when a primary database becomes incapacitated and there is
no possibility of performing a switchover or successfully repairing the primary database in a
reasonable amount of time.
The specific actions that are performed during a failover vary, depending on:
• Whether a logical or physical standby database is involved in the failover operation
• The state of the configuration at the time of the failover
• The specific SQL commands that are used to initiate the failover
by Using DGMGRL
• Disabled databases must be reinstated or re-created to
reenable broker management.
• Reinstate a database using REINSTATE DATABASE:
DGMGRL> REINSTATE DATABASE pc01prmy;
Answer: a
Answer: b
Configuration
Primary Standby2
database No delay
Real-Time Apply
RFS
Primary
database
MRP
Standby
ARC0
Archived Standby
redo logs database
Copy right © 2010, Oracle and/or its af f iliates. All rights reserv ed.
Primary Standby
database database
Redo
RESETLOGS
Redo
Primary database Standby database
3. Flash back the standby database to the ―before RESETLOGS‖ SCN that you queried in
step 1:
FLASHBACK STANDBY DATABASE TO SCN <before RESETLOGS SCN>;
4. Restart managed recovery on the standby database. The standby database will be
ready to receive and apply logs from the primary database.
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;
Logical Standby Configuration
For a logical standby database, it is possible that the SQL Apply service might not halt when it
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.
Primary Standby
database database
Redo 1
Flashback
Redo
New standby database New primary database
Answer: b
Observer
pc01sby2
pc01prmy pc01sby1
pc01prmy
EDIT CONFIGURATION
SET PROPERTY FastStartFailoverThreshold =
threshold-val;
Properties
• FastStartFailoverLagLimit: Establishes an
acceptable length of time for the standby to fall behind the
primary database with respect to applied redo
• FastStartFailoverPmyShutdown: Determines
whether the primary database shuts down if redo
original primary database by using DGMGRL or Enterprise Manager (as described later in this
lesson).
standby is in a valid fast-start failover state (observed and either synchronized or within lag
limits) to accept a failover. For example, if you experiencing a large amount of block corruptions
(ORA-1578), you can specify the following syntax:
ENABLE FAST_START FAILOVER CONDITON '1578'
Fast-start failover will then occur when the ORA-1578 is encountered. This will work for all
errors except ORA-7445 or ORA-600.
and target standby databases, including connect descriptors. Use the FILE qualifier with the
START OBSERVER command to specify an explicit directory path and name for the configuration
file on the observer computer:
DGMGRL> START OBSERVER FILE=$ORACLE_HOME/dbs/Boston.dat;
If you do not specify the FILE qualifier, the current working directory is searched for a file
named FSFO.dat. If the file does not exist, a new file is created. If the configuration file exists,
the observer checks whether the file describes a valid fast-start failover environment for the
Data Guard configuration to which the observer is connected.
Note: You can execute the START OBSERVER command regardless of whether fast-start failover
Threshold: 90 seconds
Target: pc01sby1
Observer: EDBVR6P2
Lag Limit: 60 seconds
Application
DBMS_DG.INITIATE_FS_FAILOVER
OBS_HOST
-----------------------
edbvr6p2.us.oracle.com
start failover target standby database, fast-start failover is disabled only on that target standby
database. If the target standby database regains connectivity with the primary database, the
primary database disables fast-start failover (as previously described).
If the standby database does not have connectivity with the primary database when you
execute the DISABLE FAST_START FAILOVER command with the FORCE option on a
bystander standby database, it is ignored by the primary database. Fast-start failover is
reenabled on the bystander standby database automatically when connectivity with the
primary database is restored. You must issue the DISABLE FAST_START FAILOVER
command on the primary database or on a bystander standby database that has connectivity
Click Configure
Observer.
Answer: b
Answer: a
Using DG_PROD
Oracle Net
DG_PROD
Primary Standby
database database
Managing Services
Database services are implemented with the DBMS_SERVICE package. This package
provides for the creation, deletion, starting, and stopping of services for a single database
instance.
Note: For Oracle Real Application Clusters (RAC) and single-instance databases managed
by Oracle Restart or Oracle Clusterware (which includes ASM), the DBMS_SERVICE
procedure is deprecated in Oracle Database 11g Release 2 (11.2) and srvctl should be
used instead to create services.
Using DG_PROD
Oracle Net
DG_PROD service
Primary Standby
database database
Configuration Databases
DBMS_SERVICE.CREATE_SERVICE( -
SERVICE_NAME => 'DG_PROD', -
NETWORK_NAME => 'DG_PROD', -
FAILOVER_METHOD => 'BASIC', -
FAILOVER_TYPE => 'SELECT', -
FAILOVER_RETRIES => 180, -
FAILOVER_DELAY => 1);
Configuration
• Standby databases created with Enterprise Manager are
not automatically added to the Oracle Restart
configuration.
• Use SRVCTL to add the standby databases.
srvctl add database -d <db_unique_name> -o <oracle_home>
• Example:
srvctl add database -d pc01sby1 –o
/u01/app/oracle/product/11.2.0/dbhome_1 –m example.com –p
/u01/app/oracle/product/11.2.0/dbhome_1/dbs/spfilepc01sb1.ora
-r PHYSICAL_STANDBY –n pc01prmy –a "SBDAT,SBFRA"
tnsnames.ora File
PROD = (DESCRIPTION =
(ADDRESS=(PROTOCOL = TCP)(HOST = EDBVR6P1)(PORT = 1521))
(ADDRESS=(PROTOCOL = TCP)(HOST = EDBVR6P2)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = DG_PROD)))
RTQ = (DESCRIPTION =
(ADDRESS=(PROTOCOL = TCP)(HOST = EDBVR6P1)(PORT = 1521))
SNAP = (DESCRIPTION =
(ADDRESS=(PROTOCOL = TCP)(HOST = EDBVR6P1)(PORT = 1521))
(ADDRESS=(PROTOCOL = TCP)(HOST = EDBVR6P2)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = DG_SNAP)))
LSBY = (DESCRIPTION =
(ADDRESS=(PROTOCOL = TCP)(HOST = EDBVR6P1)(PORT = 1521))
(ADDRESS=(PROTOCOL = TCP)(HOST = EDBVR6P2)(PORT = 1521))
(CONNECT_DATA = (SERVICE_NAME = DG_LSBY)))
Primary Database
Primary site Standby site
Application Tier
Oracle Application
Server Clusters
3
Primary Manual or
database automatic failover
Notification (FAN)
• The Data Guard broker publishes FAN events at failover
time.
• Applications respond to FAN events without programmatic
changes if using Oracle-integrated database clients:
– Oracle Database JDBC
Environment
To enable FAN events in an Oracle Restart environment:
1. Choose the correct SRVCTL to run.
2. Add the database to the Oracle Restart configuration.
3. Add ONS and eONS to the configuration.
srvctl add ons
This parameter enables clients to quickly traverse an address list in the event of a
failure. If a client attempts to connect to a host that is unavailable, the connection
attempt is bounded to the time specified by the
SQLNET.OUTBOUND_CONNECT_TIMEOUT parameter, after which the client attempts to
connect to the next host in the address list. This behavior continues for each host in the
address list until a successful connection is made.
5. Register a callback that is invoked when a high-availability event occurs.
Note: For details, see the Oracle Call Interface Programmer’s Guide.
Answer: a
Answer: a
$ rman
RMAN> CONNECT CATALOG rcowner/rcpass
RMAN> CREATE CATALOG;
Copyright (c) 1982, 2009, Oracle and/or its affiliates. All rights reserved.
that RMAN can connect remotely and perform resynchronization when the RESYNC
CATALOG FROM DB_UNIQUE_NAME command is executed. The connect identifier is the
Oracle Net service name that can be used from any database site to connect to the
specified database site. CONFIGURE DB_UNIQUE_NAME implicitly registers the database.
• BACKUP DEVICE TYPE DISK INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG
'dgbkup' DATABASE: Creates a new level 1 incremental backup.
- On day 1, a level 0 incremental backup is created.
- On day 2 and the following days, a level 1 incremental backup is created.
• BACKUP DEVICE TYPE DISK ARCHIVELOG ALL: Backs up archived logs to disk.
• BACKUP BACKUPSET ALL: Backs up any backup sets that were created as a result of
incremental backup.
• DELETE ARCHIVELOG ALL: Deletes archived logs according to the log deletion policy set
Using a Physical Standby Database Data File to Recover a Data File on the
Primary Database
To use a current data file from the physical standby database to recover a data file on the
primary database:
1. Connect to the standby database as the target database:
CONNECT TARGET sys/oracle@pc01sby1
Connect to the primary database as the auxiliary database:
CONNECT AUXILIARY sys/oracle@pc01prmy
2. Back up the data file on the standby host across the network to a location on the
primary host, as in the following example:
BACKUP AS COPY DATAFILE 5
AUXILIARY FORMAT '/u02/oracle/restore/df5copy.dbf';
Using a Physical Standby Database Data File to Recover a Data File on the
Primary Database (continued)
3. Exit the RMAN session. Invoke RMAN again and connect to the primary database as
the target database and connect to the recovery catalog, as in this example:
CONNECT TARGET sys/oracle@pc01prmy
CATALOG rcowner/rcpass@pc01db11;
4. Use the CATALOG DATAFILECOPY command to catalog this data file copy so that
RMAN can use it.
CATALOG DATAFILECOPY '/u02/oracle/restore/df5copy.dbf';
5. Use the SWITCH DATAFILE command to switch the data file copy so that the cataloged
file becomes the current data file.
RUN {
SET NEWNAME FOR DATAFILE 5 TO
'/u02/oracle/restore/df5copy.dbf';
SWITCH DATAFILE 5;
}
Answer: b
Answer: b
Guard Configuration
Objectives
The methods outlined in this lesson are applicable for a patch, a critical patch update (CPU),
a patch set, or a major release.
Broker Configuration
• If you are using the Data Guard broker, you must perform
the following steps before upgrading your databases:
1. Disable broker management of the configuration.
DGMGRL> DISABLE CONFIGURATION;
2. Stop the Data Guard broker.
SQL Apply
Primary Standby
database database
Primary Standby
database database
SQL Apply
Oracle Database, Oracle Database,
Release x Release y
Standby Primary
database database
Primary Standby
database database
Redo
Oracle Database, stream Oracle Database,
Release x Release x
SQL Apply
Oracle Database, Oracle Database,
Release x Release x
Answer: b
Answer: b
Configuration
to Identify a Failure
1. Check the configuration status:
DGMGRL> SHOW CONFIGURATION;
Configuration - DGConfig1
Configuration Status:
SUCCESS
Database Status:
SUCCESS
in V$LOGFILE
SQL> SELECT group#, member
2 FROM v$logfile
3 WHERE type = 'STANDBY';
in V$STANDBY_LOG
SQL> SELECT group#, dbid, archived, status
2 FROM v$standby_log;
The VALID_TYPE and VALID_ROLE columns are the values from the VALID_FOR attribute
that is specified for each archive log destination.
Initialization Parameter
• LOG_ARCHIVE_TRACE is optional and is used for
diagnostic purposes.
• Set this parameter to an integer value to see the
progression of redo log archiving to the standby system.
– On the primary database, processes write an audit trail of the
setting the value of the LOG_ARCHIVE_TRACE parameter to the sum of the individual levels. For
example, setting the parameter to 6 generates level 2 and level 4 trace output.
The following integer levels are available:
Level Meaning
0 Disables archived redo log tracing (default setting)
1 Tracks archiving of redo log file
2 Tracks archival status per archived redo log destination
by Querying V$MANAGED_STANDBY
SQL> SELECT process, status, group#, thread#, sequence#
2 FROM v$managed_standby
3 order by process, group#, thread#, sequence#;
by Querying V$DATAGUARD_STATS
SQL> SELECT name, value, time_computed
2 FROM v$dataguard_stats;
by Querying V$DATAGUARD_STATUS
SQL> SELECT timestamp, facility, dest_id, message_num,
2 error_code, message
3 FROM v$dataguard_status
4 ORDER by timestamp;
TIMESTAMP FACILITY DEST_ID MESSAGE_NUM ERROR_CODE
--------- --------------- ------- ----------- ----------
Viewing V$LOGSTDBY_TRANSACTION
Query V$LOGSTDBY_TRANSACTION to view information about the transactions that are
actively being processed by SQL Apply. The transaction identifiers shown in this view
correspond to transaction identifiers assigned at the primary database and do not correspond
to the transactions that are active at the logical standby database. Query the
V$TRANSACTION view on the logical standby database for information about transactions that
are active in the logical standby database, including those that were created as part of SQL
Apply.
You can click the Data Guard performance charts that show
real-time data in Oracle Enterprise Manager to view historical
data.
a. True
b. False
Answer: a
Answer: b
MaxConnections
Primary
database MRP or
transactions LSP Standby
database
LGWR LNSn
RFS
Oracle Net
ARC0
ARC1
ARC2
Production Standby
database database
Answer: a
Answer: b