I am an IT professional with 10 years of professional experience,I have good proficiency on Oracle technologies, and at last 2 years of my career to study Real Application Clusters,data guard and participate actively on Oracle community ,If you want to hire me on Contract or to quote on project basis contact me at khurrampc@hotmail.com.

Thursday, September 25, 2008

How standby redo apply

A log switch on the primary database triggers a log switch on the standby database, Causing ARCn processes on the standby database to archive the standby redo log Files To archive redo log files on the standby database. Then, Redo Apply (MRP process) Or SQL Apply (LSP process) applies the redo data to the standby database. If real-Time apply is enabled, Data Guard recovers redo data directly from the current standby redo log file as it is being filled up by the RFS process. What you can conclude from above statement is that Recovery at standby database via MRP happen after log switch at standby, unless you don’t log switch you will not get Recovery (log applied data) at standby. When you explicitly log switch then MRP start its process to roll forward, roll back. Here I am going to demonstrate you that after inserting even number record I am committing the data, it’s a procedure which insert 1000000 records, during this insertion lot of log switch occurs after every log Switch occurring obliged MRP to apply redo at data file from its standby redo log Files. But the commit is also stamping to data in data file which you may validate from yours data file. What I will do I will cancel the managed recovery after 4 to 5 log switching before Completion of this procedure and will see what MRP awaked after 4 to 5 log switch And applied the standby redo logs to my data files with committed stamped. At standby I have enabled managed recovery as a background detached process.
SQL>  ALTER DATABASE RECOVER MANAGED STANDBY DATABASE DISCONNECT;

Database altered.

No proces doing something cause at PROD (primary database) no any activity going on 
except MRP waiting for next log 924.

SQL> select process,status,thread#,sequence#,block#,blocks
  2    from v$managed_standby
  3  /

PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS
--------- ------------ ---------- ---------- ---------- ----------
ARCH      CONNECTED             0          0          0          0
ARCH      CONNECTED             0          0          0          0
MRP0      WAIT_FOR_LOG          1        924          0          0
RFS       RECEIVING             0          0          0          0



Come to Prod server...

SQL> show parameter log_archive_dest_2

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2                   string      SERVICE=stby LGWR SYNC VALID_FOR= 
                                                 (ONLINE_LOGFILES,PRIMARY_ROLE) 
                                                 DB_UNIQUE_NAME=STBY


SQL> create table lalo (a number)
  2  /

Table created.


SQL> begin
  2   for i in 1..1000000
  3   loop
  4      insert into lalo values (i);
  5      if mod(i,2)=0 then
  6      commit;
  7      end if;
  8    end loop;
  9  end;
 10  .
SQL> /


At Standby see 

SQL> select process,status,thread#,sequence#,block#,blocks
  2    from v$managed_standby
  3  /

PROCESS   STATUS          THREAD#  SEQUENCE#     BLOCK#     BLOCKS
--------- ------------ ---------- ---------- ---------- ----------
ARCH      CONNECTED             0          0          0          0
ARCH      CLOSING               1        930      18433        622
MRP0      APPLYING_LOG          1        927      15132      19054
RFS       RECEIVING             0          0          0          0
RFS       WRITING               1        931      18699        356
RFS       RECEIVING             0          0          0          0

6 rows selected.

SQL>  RECOVER MANAGED STANDBY DATABASE CANCEL
Media recovery complete.

SQL> ALTER DATABASE OPEN
  2  /

Database altered.

SQL> CONN SCOTT/TIGER@STBY
Connected.
SQL> select count(*)
  2    from lalo
  3  /

  COUNT(*)
----------
    194162


4 comments:

Anonymous said...

Hi,
So does that mean you have only partial records at STANDBY when you cancel reovery process by not allowing complete logs to be applied?

you have setting of
"log_archive_dest_2 string SERVICE=stby LGWR SYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) "
that means it'll write directly to STANDBY DB online logs.
so as soon as logswitch happens on Primary Db, it should happen on Standby DB (not necessory) as well.
so every record should be applied to STANDBY DB.
so why in your case Partial records are applied? just because you have canceld recovery process in middle?

Regards!
Nitin

Khurram Siddiqui said...

Nitin Please See this link
log swtich trigger fir recovery

Khurram

Pascal said...

Hi Khurram

When I create a standby redolods in standby database, what should I do to activate them?
I think I can use standby redologs no matter the protection mode is (max performance, max availability,max protection)

Khurram Siddiqui said...

no its matter standby redo log is required for the max protection and availability modes and the LGWR ASYNC transport mode is recommended for all databases.

Data Guard can recover and apply more redo data from a standby redo log than from archived redo log files alone which is for max performance mode.

Followers

About Me

My photo
Melbourne, Victoria, Australia