Search

Friday, July 15, 2016

MRP Speed (Log Apply Rate of a Standby Database)

You may want to calculate the apply rate of your standby database if you need performance tuning on your dataguard environment. Also if you are “Using a Physical Standby Database for Read/Write Testing and Reporting” in 10g or Snapshot Standby in 11g, you may need this value to calculate how much time does your standby database needs to re-syncronize in a point of time.

There are some ways of getting a value as log apply rate. For example, the following query shows the active and average apply rate.


set linesize 400
col Values for a65
col Recover_start for a21
select to_char(START_TIME,'dd.mm.yyyy hh24:mi:ss') "Recover_start",to_char(item)||' = '||to_char(sofar)||' '||to_char(units)||' '|| to_char(TIMESTAMP,'dd.mm.yyyy hh24:mi') "Values" from v$recovery_progress where start_time=(select max(start_time) from v$recovery_progress);

Recover_start Values
--------------------- -----------------------------------------------------------------
22.04.2010 09:02:38 Log Files = 83 Files
22.04.2010 09:02:38 Active Apply Rate = 8448 KB/sec
22.04.2010 09:02:38 Average Apply Rate = 3642 KB/sec
22.04.2010 09:02:38 Redo Applied = 85288 Megabytes
22.04.2010 09:02:38 Last Applied Redo = 2147483647 SCN+Time 21.04.2010 11:08
22.04.2010 09:02:38 Active Time = 23931 Seconds
22.04.2010 09:02:38 Apply Time per Log = 270 Seconds
22.04.2010 09:02:38 Checkpoint Time per Log = 16 Seconds
22.04.2010 09:02:38 Elapsed Time = 23974 Seconds



You should now that these values have some weakness in calculation and may not reflect your actual apply rate. “Active Apply Rate” is very momentary and changeable, where “Average Apply Rate” includes the time that MRP process waits for the archive log to arrive, into calculation.

Another and more accurate way may be collecting the archivelogs without applying (i mean stop recovery and keep standby mounted) and then starting recovery, monitoring alertlog and doing some calculations. For example 6 archivelogs were applied in 5 minutes and your log file size is 512mb. So apply rate is 10.2mbps. This value is more reliable but it may be time consuming to perform this process whenever you want to measure the speed.

Now let’s see what Oracle says in “Oracle Database 10g Best Practices: Data Guard Redo Apply and Media Recovery” paper:

Assess Recovery Rate

Use the following queries to get several snapshots while a redo log is being applied to obtain the current recovery rate:

i) Determine Log Block Size (lebsz) since it is different for each operating system. This query only needs to be executed once.

SQL> select lebsz LOG_BLOCK_SIZE from x$kccle where rownum=1;

ii) Derive recovery blocks applied for at least 2 snapshots:

(a) Media Recovery Cases (e.g. recover [standby] database)

select TYPE, ITEM, SOFAR, TO_CHAR(SYSDATE, ‘DD-MON-YYYY HH:MI:SS’) TIME from v$RECOVERY_PROGRESS where ITEM=’Redo Blocks’ and TOTAL=0;

(b) Managed Recovery Cases (e.g. recover managed standby database…)

select PROCESS, SEQUENCE#, THREAD#, BLOCK#, BLOCKS, TO_CHAR(SYSDATE, ‘DD-MON-YYYY HH:MI:SS’) TIME from V$MANAGED_STANDBY where PROCESS=’MRP0’;

iii) To determine the recovery rate (MB/sec) for this archive, use one of these formulas with the information derived above:

(a) Media Recovery Case:

((SOFAR_END – SOFAR_BEG) * LOG_BLOCK_SIZE) /
((TIME_END – TIME_BEG) * 1024 * 1024 )

(b) Managed Recovery Case:

((BLOCK#_END – BLOCK#_BEG) * LOG_BLOCK_SIZE)) /
((TIME_END – TIME_BEG) * 1024 * 1024)

By this way you will have different results in each test you perform. But this doesn’t mean that the method is wrong. The value depends on what kind of operation is your standby database performing (while applying the archivelog) and an average of multiple test results will be accurate enough. I prepared a shell script to perform this test several times and calculate the average. It takes two snapshots of the MRP0 process by waiting 10 seconds. If the snapshots are suitable to calculate the recovery rate (block number on second snapshot is bigger then the one on first snapshot and not equal to zero) it saves the recovery rate value. Then outputs the average of last 50 calculation. Here it is:


#!/usr/bin/sh
############# VARIABLES
#######################
export ORACLE_HOME=/…….
export ORACLE_SID=XXXX
export HOME=/home/oracle
export WORK_PATH=$HOME/DB_SCRIPTS/
export LBS=512
############# DEFINE
###################
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=$PATH:$ORACLE_HOME/bin
export TNS_ADMIN=$ORACLE_HOME/network/admin
############## MRP SNAP BY 10 seconds
###################################
$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF > $WORK_PATH/snap.log
set linesize 300;
SELECT PROCESS, SEQUENCE#, THREAD#, block#, BLOCKS, TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI:SS')
time from v\$MANAGED_STANDBY WHERE PROCESS='MRP0';
EOF
snap1=`cat $WORK_PATH/snap.log |tail -2 |head -1 |awk '{print $4}'`
echo $snap1
sleep 10
$ORACLE_HOME/bin/sqlplus -s '/ as sysdba' << EOF > $WORK_PATH/snap.log
set linesize 300;
SELECT PROCESS, SEQUENCE#, THREAD#, block#, BLOCKS, TO_CHAR(SYSDATE, 'DD-MON-YYYY HH:MI:SS')
time from v\$MANAGED_STANDBY WHERE PROCESS='MRP0';
EOF
snap2=`cat $WORK_PATH/snap.log |tail -2 |head -1 |awk '{print $4}'`
echo $snap2
############## CALCULATE THE MOMENTARY RATE
###########################################
if [[ "$snap1" != "0" && "$snap2" != "0" && "$snap1" -lt "$snap2" ]]
then
echo "ok"
mrpspeed=$(( `expr "$snap2" - "$snap1"` * $LBS ))
echo 'scale=4;'$mrpspeed'/10485760' | bc >> $WORK_PATH/mrpspeedlog
else
echo "not ok"
exit
fi
############# KEEP LAST 50 VALUE
###############################
tail -50 $WORK_PATH/mrpspeedlog > $WORK_PATH/temporary.log
mv $WORK_PATH/temporary.log $WORK_PATH/mrpspeedlog
############# CALCULATE THE AVERAGE
###################################
n=0
sum=0
while read x
do
sum=`echo "scale=4;$sum+$x" |bc`
    if [ "$?" -eq "0" ]; then
    n=`expr $n + 1`
    fi
done < $WORK_PATH/mrpspeedlog
echo "scale=2;$sum/$n" | bc > $WORK_PATH/averagespeed.txt
11gR1 New Features

· Compression of redo traffic over the network in a Data Guard configuration : This feature improves redo transport performance when resolving redo gaps by compressing redo before it is transmitted over the network.
· You can now find the DB_UNIQUE_NAME of the primary database from the standby database by querying the new PRIMARY_DB_UNIQUE_NAME column in the V$DATABASE view. Also, Oracle Data Guard release 11g ensures each database's DB_UNIQUE_NAME is different. After upgrading to 11g, any databases with the same DB_UNIQUE_NAME will not be able to communicate with each other.
· Heterogeneous Data Guard Configuration: This feature allows a mix of Linux and Windows primary and standby databases in the same Data Guard configuration.

Specific to Redo Apply (Physical Standby Database);
· Real-time query capability of physical standby
· Snapshot standby
· Lost-write detection using a physical standby : A "lost write" is a serious form of data corruption that can adversely impact a database. It occurs when an I/O subsystem acknowledges the completion of a block write in the database, while in fact the write did not occur in the persistent storage. This feature allows a physical standby database to detect lost writes to a primary or physical standby database.
· A number of enhancements in RMAN help to simplify backup and recovery operations across all primary and physical standby databases, when using a catalog. Also, you can use the RMAN DUPLICATE command to create a physical standby database over the network without a need for pre-existing database backups.

11gR2 New Features

· The new ALTER SYSTEM FLUSH REDO SQL statement can be used at failover time to flush unsent redo from a mounted primary database to a standby database, thereby allowing a zero data loss failover to be peformed even if the primary database is not running in a zero data loss data protection mode.
· The FAL_CLIENT database initialization parameter is no longer required.

Specific to Redo Apply (Physical Standby Database);
· A corrupted data block in a primary database can be automatically replaced with an uncorrupted copy of that block from a physical standby database that is operating in real-time query mode. A corrupted block in a physical standby database can also be automatically replaced with an uncorrupted copy of the block from the primary database.



Some Keynotes on Prerequisites

· The COMPATIBLE database initialization parameter must be set to the same value on all databases in a Data Guard configuration, except when using a logical standby database, which can have a higher COMPATIBLE setting than the primary database.
· To protect against unlogged direct writes in the primary database that cannot be propagated to the standby database, turn on FORCE LOGGING at the primary database before performing datafile backups for standby creation. Keep the database in FORCE LOGGING mode as long as the standby database is required.

Important Notes on Creating a Physical Standby

· If the standby database will be hosted on a Windows system, use the ORADIM utility to create a Windows service. For example:

WINNT> oradim –NEW –SID boston –STARTMODE manual
· If the primary database has a database encryption wallet, copy it to the standby database system and configure the standby database to use this wallet.(The database encryption wallet must be copied from the primary database system to each standby database system whenever the master encryption key is updated.)

· Post-Creation :
o Upgrade the data protection mode
o Enable Flashback Database : Flashback Database removes the need to re-create the primary database after a failover.

Important Notes on Creating a Logical Standby

· Note that a logical standby database uses standby redo logs (SRLs) for redo received from the primary database, and also writes to online redo logs (ORLs) as it applies changes to the standby database. Thus, logical standby databases often require additional ARCn processes to simultaneously archive SRLs and ORLs. Additionally, because archiving of ORLs takes precedence over archiving of SRLs, a greater number of SRLs may be needed on a logical standby during periods of very high workload.
· Determine Support for Data Types and Storage Attributes for Tables
· Ensure Table Rows in the Primary Database Can Be Uniquely Identified (Look doc. for details)
· Step-by-Step Instructions for Creating a Logical Standby Database:
    o Create a Physical Standby Database
    o Stop Redo Apply on the Physical Standby Database
    o Prepare the Primary Database to Support a Logical Standby Database
          § LOG_ARCHIVE_DEST_3= 'LOCATION=/arch2/chicago/VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=chicago'
          § EXECUTE DBMS_LOGSTDBY.BUILD;
    o Transition to a Logical Standby Database
          § ALTER DATABASE RECOVER TO LOGICAL STANDBY db_name;
          § In releases prior to Oracle Database 11g, you needed to create a new password file before you
             opened the logical standby database. This is no longer needed.
          § SHUTDOWN; / STARTUP MOUNT;
          § LOG_ARCHIVE_DEST_1= 'LOCATION=/arch1/boston/ VALID_FOR=
             (ONLINE_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=boston'
             LOG_ARCHIVE_DEST_2= 'SERVICE=chicago ASYNC VALID_FOR=          
             (ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=chicago'
             LOG_ARCHIVE_DEST_3= 'LOCATION=/arch2/boston/ VALID_FOR=
             (STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=boston'
    o Open the Logical Standby Database
          § ALTER DATABASE OPEN RESETLOGS;
          § ALTER DATABASE START LOGICAL STANDBY APPLY IMMEDIATE;

Protection Modes:
· Execute the following SQL statement on the primary database in order to set the data protection mode.
SQL> ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE {AVAILABILITY | PERFORMANCE | PROTECTION};
· Perform the following query on the primary db to confirm that it is operating in the new protection mode:
SQL> SELECT PROTECTION_MODE FROM V$DATABASE;

Redo Transport Services:
o Redo Transport Authentication Using SSL
o Redo Transport Authentication Using a Password File: By default, the password of the SYS user is used to authenticate redo transport sessions when a password file is used. The REDO_TRANSPORT_USER database initialization parameter can be used to select a different user password for redo transport authentication by setting this parameter to the name of any user who has been granted the SYSOPER privilege. For administrative ease, Oracle recommends that the REDO_TRANSPORT_USER parameter be set to the same value on the redo source database and at each redo transport destination.

· LOG_ARCHIVE_DEST_STATE_n Initialization Parameter Values: ENABLE, DEFER, ALTERNATE
· LOG_ARCHIVE_DEST_n parameter attributes :
    o AFFIRM and NOAFFIRM
    o ALTERNATE (not supported for LOG_ARCHIVE_DEST_11 through LOG_ARCHIVE_DEST_31)
    o COMPRESSION (licensed)
    o DB_UNIQUE_NAME
    o DELAY
    o LOCATION and SERVICE (LOCATION is not supported for LOG_ARCHIVE_DEST_11 thr 31)
    o MANDATORY (not supported for LOG_ARCHIVE_DEST_11 through 31)
    o MAX_CONNECTIONS
    o MAX_FAILURE
    o NET_TIMEOUT
    o NOREGISTER
    o REOPEN
    o SYNC and ASYNC (SYNC is not supported for LOG_ARCHIVE_DEST_11 through 31)
    o SERVICE (mandatory attribute for a redo transport destination)
    o TEMPLATE
    o VALID_FOR

· Redo received by a standby database is written directly to an archived redo log file if a standby redo log group is not available or if the redo was sent to resolve a redo gap. When this occurs, redo is written to the location specified by the LOCATION attribute of one LOG_ARCHIVE_DEST_n parameter that is valid for archiving redo received from another database.

· If the redo source database is an Oracle Real Applications Cluster (Oracle RAC) or Oracle One Node database, query the V$LOG view at the redo source database to determine how many redo threads exist and specify the corresponding thread numbers when adding redo log groups to the standby redo log.
SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 1 SIZE 500M;
SQL> ALTER DATABASE ADD STANDBY LOGFILE THREAD 2 SIZE 500M;

Apply Services
· Canceling a Time Delay
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE NODELAY;
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY NODELAY;

· If you define a delay for a destination that has real-time apply enabled, the delay is ignored.
· As an alternative to setting an apply delay, you can use Flashback Database to recover from the application of corrupted or erroneous data to the standby database. Flashback Database can quickly and easily flash back a standby database to an arbitrary point in time.

· Applying Redo Data to Logical Standby Databases

o Starting SQL Apply:
SQL> ALTER DATABASE START LOGICAL STANDBY APPLY [IMMEDIATTE];
o Stopping SQL Apply:
SQL> ALTER DATABASE STOP LOGICAL STANDBY APPLY;

Role Transitions

Switchover Notes
· Remove any delay in applying redo that may be in effect on the standby database that will become the new primary database.
· Before performing a switchover from an Oracle RAC primary database to a physical standby database, shut down all but one primary database instance.
· Before performing a switchover to a physical standby database that is in real-time query mode, consider bringing all instances of that standby database to the mounted but not open state for the fastest possible role transition.

SQL> SELECT NAME, VALUE, TIME_COMPUTED FROM V$DATAGUARD_STATS;

NAME VALUE
------------------------ ---------------- --
apply finish time +00 03:09:38.7
apply lag +00 02:09:53
estimated startup time 48
standby has been open N
transport lag +00 00:11:12

Failover Notes
· If a standby database currently running in maximum protection mode will be involved in the failover, first place it in maximum performance mode.
· If possible, copy the most recently archived redo log file for each primary database redo thread to the standby database if it does not exist there, and register it.
· Flush any unsent redo from the primary database to the target standby database. If the primary database can be mounted, it may be possible to flush any unsent archived and current redo from the primary database to the standby database
SQL> ALTER SYSTEM FLUSH REDO TO target_db_name;
· Stop Redo Apply
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
· Finish applying all received redo data
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH;
· SQL> ALTER DATABASE ACTIVATE PHYSICAL STANDBY DATABASE;
· SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY WITH SESSION SHUTDOWN
· SQL> ALTER DATABASE OPEN;

· Using Flashback Database After a Switchover:

If the switchover involved a physical standby database, the primary and standby database roles are preserved during the flashback operation. That is, the role in which the database is running does not change when the database is flashed back to the target SCN or time to which you flashed back the database.
If the switchover involved a logical standby database, flashing back changes the role of the standby database to what it was at the target SCN or time to which you flashed back the database.

· Using Flashback Database After a Failover
You can use Flashback Database to convert the failed primary database to a point in time before the failover occurred and then convert it into a standby database. (Converting a Failed Primary Into a Standby Database Using Flashback Database)

Real-time query
· A physical standby database instance cannot be opened if Redo Apply is active on a mounted instance of that database. Use the following SQL statements to stop Redo Apply, open a standby instance read-only, and restart Redo Apply:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> ALTER DATABASE OPEN;
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
SQL> SELECT open_mode FROM V$DATABASE;

OPEN_MODE
--------------------
READ ONLY WITH APPLY

Apply Lag

· To obtain the apply lag, query the V$DATAGUARD_STATS view. For example:
SQL> SELECT name, value, datum_time, time_computed FROM V$DATAGUARD_STATS WHERE name like 'apply lag';

NAME VALUE DATUM_TIME TIME_COMPUTED
--------- ------------- ------------------- ------------------
apply lag +00 00:00:00 05/27/2009 08:54:16 05/27/2009 08:54:17

The apply lag metric is computed using data that is periodically received from the primary database. The DATUM_TIME column contains a timestamp of when this data was last received by the standby database. The TIME_COMPUTED column contains a timestamp taken when the apply lag metric was calculated. The difference between the values in these columns should be less than 30 seconds. If the difference is larger
than this, the apply lag metric may not be accurate.

STANDBY_MAX_DATA_DELAY

· If STANDBY_MAX_DATA_DELAY is set to 0, a query issued to a physical standby database is guaranteed to return the exact same result as if the query were issued on the primary database, unless the standby database is lagging behind the primary database, in which case an ORA-3172 error is returned.
· The following additional restrictions apply if STANDBY_MAX_DATA_DELAY is set to 0 or if the ALTER SESSION SYNC WITH PRIMARY SQL statement is used:
    * The standby database must receive redo data via the SYNC transport.
    * The redo transport status at the standby database must be SYNCHRONIZED and the primary database must be running in either maximum protection mode or maximum availability mode.
    * Real-time apply must be enabled.

Automatic Repair of Corrupt Data Blocks

· A physical standby database operating in real-time query mode can also be used to repair corrupt data blocks in a primary database. If a corrupt data block is discovered on a physical standby database, the server attempts to automatically repair the corruption by obtaining a copy of the block from the primary database. No additional configuration is needed. If automatic repair is not possible, an ORA-1578 error is returned.

· The RMAN RECOVER BLOCK command is used to manually repair a corrupted data block. This command searches several locations for an uncorrupted copy of the data block.

Tuning Queries on a Physical Standby Database

· Appendix D of the Active Data Guard 11g Best Practices white paper describes how to tune queries for optimal performance on a physical standby database.


Using RMAN

Interchangeability of Backups in a Data Guard Environment

· RMAN commands use the recovery catalog metadata to behave transparently across different physical databases in the Data Guard environment. For example, you can back up a tablespace on a physical standby database and restore and recover it on the primary database. Similarly, you can back up a tablespace on a primary database and restore and recover it on a physical standby database.
Note: Backups of logical standby databases are not usable at the primary database.

· Backups of standby control files and nonstandby control files are interchangeable. For example, you can restore a standby control file on a primary database and a primary control file on a physical standby database. This interchangeability means that you can offload control file backups to one database in a Data Guard environment.

Association of Backups in a Data Guard Environment

· The recovery catalog tracks the files in the Data Guard environment by associating every database file or backup file with a DB_UNIQUE_NAME. The database that creates a file is associated with the file. For example, if RMAN backs up the database with the unique name of standby1, then standby1 is associated with this backup. A backup remains associated with the database that created it unless you use the CHANGE ... RESET DB_UNIQUE_NAME to associate the backup with a different database.

Accessibility of Backups in a Data Guard Environment

· In a Data Guard environment, the recovery catalog considers disk backups as accessible only to the database with which it is associated, whereas tape backups created on one database are accessible to all databases.
Note: You can FTP a backup from a standby host to a primary host or vice versa, connect as TARGET to the database on this host, and then CATALOG the backup. After a file is cataloged by the target database,
the file is associated with the target database.

RMAN Configurations

· For primary ;
Specify when archived logs can be deleted with the CONFIGURE ARCHIVELOG DELETION POLICY command. For example, if you want to delete logs after ensuring that they shipped to all destinations, use the following configuration:
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO SHIPPED TO ALL STANDBY;

If you want to delete logs after ensuring that they were applied on all standby destinations, use the following configuration: 
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;

For standby ;
Enable automatic deletion of archived logs once they are applied at the standby database:
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;

· Configure the connect string for the primary database and all standby databases, so that RMAN can connect remotely and perform resynchronization when the RESYNC CATALOG FROM DB_UNIQUE_NAME command is used.
RMAN> CONFIGURE DB_UNIQUE_NAME BOSTON CONNECT IDENTIFIER 'boston_conn_str';


· Commands for Daily Tape Backups Using Disk as Cache

The script to perform daily backups looks as follows:

RESYNC CATALOG FROM DB_UNIQUE_NAME ALL; -- Resynchronizes the information from all other database sites (primary and other standby databases)
RECOVER COPY OF DATABASE WITH TAG 'OSS'; -- Rolls forward level 0 copy of the database by applying the level 1 incremental backup taken the day before. On the first day this command is run there will be no roll forward because there is no incremental level 1 yet. A level 0 incremental will be created by the BACKUP DEVICE TYPE DISK ... DATABASE command. Again on the second day there is no roll forward because there is only a level 0 incremental.
BACKUP DEVICE TYPE DISK INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'OSS' DATABASE; -- Create a new level 1 incremental backup. On the first day this command is run, this will be a level 0 incremental. On the second and following days, this will be a level 1 incremental.
BACKUP DEVICE TYPE SBT ARCHIVELOG ALL; -- Backs up archived logs to tape according to the deletion policy in place.
BACKUP BACKUPSET ALL; -- Backs up any backup sets created as a result of incremental backup creation.
DELETE ARCHIVELOG ALL; -- Deletes archived logs according to the log deletion policy set by the CONFIGURE ARCHIVELOG DELETION POLICY command. If the archived logs are in a fast recovery area, then they are automatically deleted when more open disk space is required.

Registering and Unregistering Databases in a Data Guard Environment

· Only the primary database must be explicitly registered using the REGISTER DATABASE command. You do this after connecting RMAN to the recovery catalog and primary database as TARGET.
· A new standby is automatically registered in the recovery catalog when you connect to a standby database or when the CONFIGURE DB_UNIQUE_NAME command is used to configure the connect identifier.
· To unregister information about a specific standby database, you can use the UNREGISTER DB_UNIQUE_NAME command.

Reporting in a Data Guard Environment

· Use the RMAN LIST, REPORT, and SHOW commands with the FOR DB_UNIQUE_NAME clause to view information about a specific database.
RMAN> LIST DB_UNIQUE_NAME OF DATABASE;
RMAN> LIST ARCHIVELOG ALL FOR DB_UNIQUE_NAME BOSTON;
RMAN> REPORT SCHEMA FOR DB_UNIQUE_NAME BOSTON;
RMAN> SHOW ALL FOR DB_UNIQUE_NAME BOSTON;
To Improve Dataguard Performace


The following information is important about Physical Data Guard Redo Apply performance:




11g Media Recovery performance improvements include:

===========================================

•More parallelism by default
•More efficient asynchronous redo read, parse, and apply
•Fewer synchronization points in the parallel apply algorithm
•The media recovery checkpoint at a redo log boundary no longer blocks the apply of the next log


In 11g, when tuning redo apply consider following:
=====================================

•By default recovery parallelism = CPU Count-1. Do not use any other values.
•Keep PARALLEL_EXECUTION_MESSAGE_SIZE >= 8192
•Keep DB_CACHE_SIZE >= Primary value
•Keep DB_BLOCK_CHECKING = FALSE (if you have to)
•System Resources Needs to be assessed
•Query what MRP process is waiting

select a.event, a.wait_time, a.seconds_in_wait from gv$session_wait a, gv$session b where a.sid=b.sid and b.sid=(select SID from v$session where PADDR=(select PADDR from v$bgprocess where NAME='MRP0'))


 When tuning redo transport service, consider following:
==============================================

1 - Tune LOG_ARCHIVE_MAX_PROCESSES parameter on the primary.
•Specifies the parallelism of redo transport
•Default value is 2 in 10g, 4 in 11g
•Increase if there is high redo generation rate and/or multiple standbys
•Must be increased up to 30 in some cases.
•Significantly increases redo transport rate.

2 - Consider using Redo Transport Compression:
•In 11.2.0.2 redo transport compression can be always on
•Use if network bandwidth is insufficient
•and CPU power is available





Also consider:
===========
3 - Configuring TCP Send / Receive Buffer Sizes (RECV_BUF_SIZE / SEND_BUF_SIZE)
4 - Increasing SDU Size
5 - Setting TCP.NODELAY to YES


Problem: Recovery service has stopped for a while and there has been a gap between primary and standby side. After recovery process was started again, standby side is not able to catch primary side because of low log applying performance. Disk I/O and memory utilization on standby server are nearly 100%.



Solution:
1 –
Rebooting the standby server reduced memory utilization a little.
  
2 – ALTER DATABASE RECOVER MANAGED STANDBY DATABASE PARALLEL 8 DISCONNECT FROM SESSION;
In general, using the parallel recovery option is most effective at reducing recovery time when several datafiles on several different disks are being recovered concurrently. The performance improvement from the parallel recovery option is also dependent upon whether the operating system supports asynchronous I/O. If asynchronous I/O is not supported, the parallel recovery option can dramatically reduce recovery time. If asynchronous I/O is supported, the recovery time may be only slightly reduced by using parallel recovery.
3 – SQL>alter system Set PARALLEL_EXECUTION_MESSAGE_SIZE = 4096 scope = spfile;
Set PARALLEL_EXECUTION_MESSAGE_SIZE = 4096
When using parallel media recovery or parallel standby recovery, 
increasing the PARALLEL_EXECUTION_MESSAGE_SIZE database parameter to 4K (4096) can improve parallel recovery by as much as 20 percent
Set this parameter on both the primary and standby databases in preparation for switchover operations. Increasing this parameter requires more memory from the shared pool by each parallel execution slave process.
4 – Kernel parameters that changed in order to reduce file system cache size.
dbc_max_pct 10 10 Immed
dbc_min_pct 3 3 Immed
5 – For secure path (HP) load balancing, SQL Shortest Queue Length is chosen.
autopath set -l 6005-08B4-0007-4D25-0000-D000-025F-0000 -b SQL