Oracle DBA Tips Corner |
Data Protection Modes - (Oracle9i Release 2 and higher)
by Jeff Hunter, Sr. Database Administrator
Contents
Overview
Oracle9i Release 2 was greatly enhanced with new features and functionality
to not only enable better flexibility, but to also make it easier
for the DBA to build a stable and available infrastructure.
One of those new features in Oracle9i R2 is the ability for the
DBA to place the database into one of the following protection modes:
A Data Guard configuration will always run in one of the three data protection modes listed
above. Each of the three modes provide a high degree of data protection; however they differ
with regards to data availability and performance of the primary database.
When selecting a protection mode, always consider the one that best meets the needs of your
business. Carefully take into account the need to protect the data against any loss vs. availability
and performance expectations of the primary database. This article will explain the new
protection modes available
in Oracle9i Release 2, how Log Transport Services works to support them, and
finally the steps necessary to configure the standby database to the desired protection mode.
Log Transport Services
Log transport services also controls the level of data protection for your database.
The DBA will configure log transport services to balance data protection and
availability against database performance. Log transport services will also
coordinate with log apply services and role management services for switchover
and failover operations.
Maximum Protection Mode
In a multiple-instance RAC database environment,
Data Guard will shut down the primary database if it is unable to write the
redo data to at least one properly configured database instance (see minimum requirements below).
In order to participate in maximum protection mode:
For example:
The SYNC attribute with the LGWR process specifies that network I/O is to be
performed synchronously for the destination. This means that once the I/O (redo data) is
initiated, the archiving process waits for the I/O to complete before continuing. When specifying
the SYNC attribute, all network I/O operations are performed synchronously, in conjunction
with each write operation to the online redo log. The transaction is not committed on the primary
database until the redo data necessary to recover that transaction is received by the destination.
Maximum Availability Mode
Just like maximum protection mode, maximum availability requires:
For example:
Maximum Performance Mode
When configuring the destination standby instance in the
LOG_ARCHIVE_DEST_n, log transport services can be set to
use either LGWR / ASYNC or ARCH. In order to reduce the amount of data
loss on the standby destination if the primary database were to fail,
set the LGWR and ASYNC attribute. Using this configuration, the primary database
writes its redo stream to the standby database asynchronously with respect to the
commitment of the transactions
that create the redo data. When the nodes are connected with sufficient bandwidth, this mode provides
a level of data protection that approaches that of maximum availability mode
with minimal impact on primary database performance.
Note that the use of standby redo logs is only necessary when configuring
log transport services to use LGWR. When log transport services is configured
to use ARCH, standby redo logs are not needed.
The following table describes the attributes that should be
defined for the LOG_ARCHIVE_DEST_n
instance parameter for the standby database destination to participate in maximum performance mode:
For example:
When configuring log transport services to use LGWR and remotely archive in ASYNC mode,
the LGWR process does not wait
for each network I/O to complete before proceeding. This behavior is made possible by
the use of an intermediate process, known as a Log Writer Network Server Process (LNS), which
performs the actual network I/O and waits for each network I/O to complete. Each LNS has
a user configurable buffer that is used to accept outbound redo data from the LGWR process.
This is configured by specifying the size in 512 byte blocks on the ASYNC attribute in the
archivelog destination parameter. For example, ASYNC=2048 indicates a 1MB buffer. As long
as the LNS process is able to empty this buffer faster than the LGWR can fill it, the
LGWR process will never stall. If the LNS cannot keep up, then the buffer will become full and the
LGWR process will stall until either sufficient buffer space is freed up by a successful network
transmission or a timeout occurs.
When configuring log transport services to remotely archive using the ARCH
attribute, redo logs are transmitted to the
destination only during an archival operation. The background archiver processes
(ARCn) or a foreground archival process operation serves as the redo log transport
service. Using ARCH to remotely archive redo data does not impact the primary database throughput
as long as enough redo log groups exist so that the most recently used group can be archived
before it must be reopened.
Setting the Data Protection Mode of a Data Guard Configuration
First though, let's review the available protection modes discussed in the previous
sections. The protection modes run in the order from highest (most data protection)
to the lowest (least data protection):
Each of the Data Guard data protection modes require that at least one standby
database in the configuration meet the minimum set of requirements listed in
the table below.
Use the following steps to upgrade the protection mode from the default of MAXIMUM PERFORMANCE
Set the LOG_ARCHIVE_DEST_n instance parameter on the
primary database to support the required protection mode:
For MAXIMUM PROTECTION mode:
For MAXIMUM AVAILABILITY mode:
Use the following steps to downgrade the protection mode from the current
higher protection mode.
Further Reading
All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter
and is protected under copyright laws of the United States. This document may not be hosted on any other site without my express,
prior, written permission. Application to host any of the material elsewhere can be made by contacting me at jhunter@idevelopment.info.
I have made every effort and taken great care in making sure that the material included on my web site is technically accurate,
but I disclaim any and all responsibility for any loss, damage or destruction of data or any other property which may arise from
relying on it. I will in no case be liable for any monetary damages arising from such loss, damage or destruction.
Oracle Data Guard (known as Oracle Standby Database
prior to Oracle9i), provides organizations with
high availability, data protection, and disaster recovery
for enterprise databases with extraordinary ease of use.
The DBA has many services included with Oracle Data Guard
for creating, maintaining, managing, and monitoring one or more
standby database instances. Oracle Data Guard provides
functionality to enable enterprise data systems to
survive both data corruption as well as major disasters.
These three new modes replace the guaranteed, instance, rapid, and delayed modes of
data protection available in Oracle9i Release 1 (9.0.1).
Log transport services enables and controls the automated transfer of redo data
within a Data Guard configuration from the primary site to each of its
standby sites.
Maximum protection mode offers the ultimate in data protection. It guarantees
no data loss will occur in the event the primary database fails. In order to provide
this level of protection, the redo data needed to recover each transaction
must be written to both the local (online) redo log and to a
standby redo log on at least one standby database before the transaction
can be committed. In order to guarantee no loss of data can occur, the primary
database will shut down if a fault prevents it from writing its redo data
to at least one remote standby redo log.
The minimum requirements are described in the following table:
Maximum Protection Mode Minimum Requirements
Redo Archival Process
LGWR
Network Transmission Mode
SYNC
Disk Write Option
AFFIRM
Standby Redo Logs?
Yes
Standby Database Type
Physical Only
log_archive_dest_2='service=testdb_standby LGWR SYNC AFFIRM'
It is highly recommended that a Data Guard configuration that is
run in maximum protection mode contain at least two physical standby
databases that meets the requirements listed in the table above. That way,
the primary database can continue processing if one of the physical standby
databases cannot receive redo data from the primary database. If only one standby
database is configured with the minimum requirements listed above, the
primary database will shut down when the physical standby
databases cannot receive redo data from the primary database!
Maximum availability mode provides the highest level of data protection
that is possible without affecting the availability of the primary database.
This protection mode is very similar to maximum protection where a transaction
will not commit until the redo data needed to recover that transaction is written
to both the local (online) redo log and to at least one remote standby redo log.
Unlike maximum protection mode; however, the primary database will not shut down if a fault
prevents it from writing its redo data to a remote standby redo log. Instead, the
primary database will operate in maximum performance mode until the fault is corrected and all log
gaps have been resolved. After all log gaps have been resolved, the primary database
automatically resumes operating in maximum availability mode.
Please note that maximum availability mode guarantees that no data will be lost
if the primary fails, but only if a second fault does not prevent a complete
set of redo data from being sent from the primary database to at least one
standby database.
The minimum requirements are described in the following table:
Maximum Availability Mode Minimum Requirements
Redo Archival Process
LGWR
Network Transmission Mode
SYNC
Disk Write Option
AFFIRM
Standby Redo Logs?
Required for physical standby databases only. Standby redo logs are not supported for logical standby databases.
Standby Database Type
Physical or Logical
log_archive_dest_2='service=testdb_standby LGWR SYNC AFFIRM'
Maximum performance is the default protection mode and provides the highest level
of data protection that is possible without affecting the performance
or availability of the primary database. With this protection mode, a transaction
is committed as soon as the redo data needed to recover the transaction is written
to the local (online) redo log.
Maximum Performance Mode Minimum Requirements
Redo Archival Process
LGWR or ARCH
Network Transmission Mode
ASYNC when using LGWR process. Not applicable when using the ARCH process.
Disk Write Option
NOAFFIRM
Standby Redo Logs?
Required for physical standby databases using the LGWR process.
Standby Database Type
Physical or Logical
log_archive_dest_2='service=testdb_standby ARCH NOAFFIRM'
or
log_archive_dest_2='service=testdb_standby LGWR ASYNC NOAFFIRM''
In this section, I will provide the steps necessary to change
the protection mode of an existing physical Data Guard configuration
setup using a default protection mode of MAXIMUM PERFORMANCE to
MAXIMUM PROTECTION.
Minimum Requirements for Data Protection Modes
Maximum Protection
Maximum Availability
Maximum Performance
Redo Archival Process
LGWR
LGWR
LGWR or ARCH
Network Transmission Mode
SYNC
SYNC
ASYNC when using LGWR process. Not applicable when using ARCH process.
Disk Write Option
AFFIRM
AFFIRM
NOAFFIRM
Standby Redo Logs Required?
Yes
Required for physical standby databases only. Standby redo logs are not supported for logical standby databases.
Required for physical standby databases using the LGWR process.
Database Type
Physical only
Physical and Logical
Physical and Logical
Take note of the following important points to understand when configuring the standby database:
The Remote File Server process runs on the standby database and can receive redo data over
the network from both LGWR and ARCn. The RFS process will write
the redo data it receives to either a standby redo log or to a standby archived
redo log.
When a log
switch occurs on the primary database, a log switch is also triggered on the standby database where
the ARCH process then archives the standby redo logs to the archive destination
specified on the standby database. After the archival process has completed on the standby
database, the Managed Recovery Process (MRP) then writes the changes to the
actual database files from the archived redo log files.
Why is this important to point out?
It illustrates the fact that the actual changes (transactions) being made and committed on the primary database
do indeed make it over to the standby database, but get applied to the standby redo logs.
These changes are only made to the actual database files on the standby database
when a log switch occurs on the primary. Note that in Oracle10g, it is
possible to configure changes made on the primary database to immediately write the changes
to the database files on the standby database.
Upgrading the Protection Mode
SQL> -- [Connect to the standby database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux4.idevelopment.info AS SYSDBA
SQL> -- [Verify if using Oracle Managed Files]
SQL> SELECT VALUE FROM V$PARAMETER WHERE NAME = 'db_create_online_log_dest_1';
VALUE
-------------------
/u02/oradata/TESTDB
SQL> -- [Do any standby redo logs exist on the standby database?]
SQL> SELECT GROUP#, BYTES, 'ONLINE' AS TYPE FROM V$LOG
2 UNION
3 SELECT GROUP#, BYTES, 'STANDBY' AS TYPE FROM V$STANDBY_LOG
4 ORDER BY 1;
GROUP# BYTES TYPE
---------- ---------- -------
1 104857600 ONLINE
2 104857600 ONLINE
3 104857600 ONLINE
SQL> -- [Need to first cancel managed recovery mode if it is running]
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> -- [Create standby redo log files]
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 100M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 SIZE 100M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 SIZE 100M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 SIZE 100M;
SQL> -- [Put standby database into managed recovery mode]
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
SQL> -- [Verify new standby redo logs on standby database]
SQL> SELECT GROUP#, BYTES, 'ONLINE' AS TYPE FROM V$LOG
2 UNION
3 SELECT GROUP#, BYTES, 'STANDBY' AS TYPE FROM V$STANDBY_LOG
4 ORDER BY 1;
GROUP# BYTES TYPE
---------- ---------- -------
1 104857600 ONLINE
2 104857600 ONLINE
3 104857600 ONLINE
4 104857600 STANDBY
5 104857600 STANDBY
6 104857600 STANDBY
7 104857600 STANDBY
For the mode of MAXIMUM PROTECTION,
the standby database must be up and mounted!
SQL> -- [Connect to the primary database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux3.idevelopment.info AS SYSDBA
SQL> -- [Configure log transport services to support the desired protection mode]
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=testdb_vmlinux4.idevelopment.info LGWR SYNC AFFIRM';
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=enable;
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP MOUNT
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PROTECTION;
SQL> ALTER DATABASE OPEN;
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE AVAILABILITY;
SQL> ALTER DATABASE OPEN;
SQL> SELECT PROTECTION_MODE, PROTECTION_LEVEL, DATABASE_ROLE FROM V$DATABASE;
PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE
------------------- ------------------- --------------
MAXIMUM PROTECTION MAXIMUM PROTECTION PRIMARY
SQL> -- [Connect to the primary database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux3.idevelopment.info AS SYSDBA
SQL> -- [Do any standby redo logs exist on the primary database?]
SQL> SELECT GROUP#, BYTES, 'ONLINE' AS TYPE FROM V$LOG
2 UNION
3 SELECT GROUP#, BYTES, 'STANDBY' AS TYPE FROM V$STANDBY_LOG
4 ORDER BY 1;
GROUP# BYTES TYPE
---------- ---------- -------
1 104857600 ONLINE
2 104857600 ONLINE
3 104857600 ONLINE
SQL> -- [Create standby redo log files]
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 SIZE 100M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 SIZE 100M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 SIZE 100M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 SIZE 100M;
SQL> -- [Verify new standby redo logs on primary database]
SQL> SELECT GROUP#, BYTES, 'ONLINE' AS TYPE FROM V$LOG
2 UNION
3 SELECT GROUP#, BYTES, 'STANDBY' AS TYPE FROM V$STANDBY_LOG
4 ORDER BY 1;
GROUP# BYTES TYPE
---------- ---------- -------
1 104857600 ONLINE
2 104857600 ONLINE
3 104857600 ONLINE
4 104857600 STANDBY
5 104857600 STANDBY
6 104857600 STANDBY
7 104857600 STANDBY
Also, on the standby database(s), configure the LOG_ARCHIVE_DEST_n
parameter attributes so the Data Guard configuration can continue to operate
in the new protection mode after a switchover:
SQL> -- [Connect to the standby database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux4.idevelopment.info AS SYSDBA
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=testdb_vmlinux3.idevelopment.info LGWR SYNC AFFIRM';
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=defer;
Downgrading the Protection Mode
SQL> -- [Connect to the primary database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux3.idevelopment.info AS SYSDBA
SQL> -- [Configure log transport services to support the desired protection mode]
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_2='SERVICE=testdb_vmlinux4.idevelopment.info ARCH';
SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_STATE_2=enable;
SQL> -- [Connect to the primary database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux3.idevelopment.info AS SYSDBA
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP MOUNT
SQL> -- [Connect to the standby database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux4.idevelopment.info AS SYSDBA
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> SHUTDOWN IMMEDIATE
SQL> STARTUP NOMOUNT
SQL> ALTER DATABASE MOUNT STANDBY DATABASE;
SQL> -- [Connect to the primary database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux3.idevelopment.info AS SYSDBA
SQL> -- [For MAXIMUM PERFORMANCE mode]
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE;
SQL> -- [For MAXIMUM AVAILABILITY mode]
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE AVAILABILITY;
SQL> -- [Connect to the standby database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux4.idevelopment.info AS SYSDBA
SQL> -- [Drop any standby redo logs from the standby database]
SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 4;
SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 5;
SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 6;
SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 7;
If standby redo logs exist on the primary and you are downgrading to maximum performance
mode, they can be removed:
SQL> -- [Connect to the primary database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux3.idevelopment.info AS SYSDBA
SQL> -- [Drop any standby redo logs from the primary database]
SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 4;
SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 5;
SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 6;
SQL> ALTER DATABASE DROP STANDBY LOGFILE GROUP 7;
SQL> -- [Connect to the standby database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux4.idevelopment.info AS SYSDBA
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT FROM SESSION;
SQL> -- [Connect to the primary database]
SQL> CONNECT sys/change_on_install@testdb_vmlinux3.idevelopment.info AS SYSDBA
SQL> ALTER DATABASE OPEN;
SQL> SELECT PROTECTION_MODE, PROTECTION_LEVEL, DATABASE_ROLE FROM V$DATABASE;
PROTECTION_MODE PROTECTION_LEVEL DATABASE_ROLE
-------------------- -------------------- --------------
MAXIMUM PERFORMANCE MAXIMUM PERFORMANCE PRIMARY
Additional information on Oracle Data Guard can be found
in the Data Guard Concepts and Administration guide
which is available from the Oracle Documentation Library:
Data Guard Concepts and Administration - (Oracle9i Release 2)
Data Guard Concepts and Administration - (Oracle10g Release 2)
Wednesday, 02-Jan-2008 16:25:51 EST
Page Count: 1327