Wednesday, March 10, 2010

Real-time apply in Data Guard

Real-time apply:

When real-time apply is enabled, the log apply services can apply redo data as it is received, without waiting for the current standby redo log file to be archived.

In this example we are going to use LGWR on the primary for redo transport just to prove that a committed record on the primary without switching a log will show up on the standby. However real-time apply will work with both LGWR and ARCH using SRL's.

- Set up log_archive_dest_2 on the primary with LGWR ASYNC or SYNC

log_archive_dest_2='SERVICE=rhclu2p LGWR ASYNC
VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE)
DB_UNIQUE_NAME=rhclu2p'

- shutdown and startup the primary or if done dynamically switch a log file
- You will see the following message in the alert log
****************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
*****************************************************************

- On the standby cancel out of the current managed recovery


SQL>ALTER DATABASER RECOVER MANAGED STANDBY DATABASE CANCEL;

- Place it back in recovery with Real time apply

SQL>ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USINGCURRENT
LOGFILE DISCONNECT;

Test Real time apply :

Primary : create a table 'test' and insert a record.

SQL>INSERT INTO test VALUES ( 101, 'testing');
SQL>COMMIT;

Do not switch a log

On the standby :

SQL>SELECT PROCESS, STATUS,SEQUENCE#,BLOCK#,BLOCKS, DELAY_MINS FROM
V$MANAGED_STANDBY;

Notice the block# for the RFS and MRP0 increasing
Cancel out of real time apply and open it in read only mode

SQL>
ALTER DATABASER RECOVER MANAGED STANDBY DATABASE CANCEL;

SQL>ALTER DATABASE OPEN READ ONLY;

SQL>SELECT * FROM.test;

You will see the committed record.

Place the standby back in managed recover mode

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENTLOGFILE DISCONNECT;

( This will take the standby directly from read only mode and place it in managedrecovery mode )

No comments:

Post a Comment