Tuesday, October 4, 2016

REDOLOGFILES

                   REDO LOG FILE MANAGEMENT

when ever any concurrent user says commit or Rollback oracle immediately invokes the LGWR bg proccess to flush the entire content of Redollog buffer to Redologfile.

Redolog file holds Redorecords which are moved from redologbuffer .

During the time logwriter copies the data from Redologbuffer to redologfiles  it wakes on wait event called 'logfile sync'.

Redlogfile use for instance Recovery.

While the database opening SMON bg process cross check start scn value with the stop _scn value if both are not matching the smon initites instance recovery.

As a part of instance recovery SMON reads  and apply all redologrecords which are generated between previous checkpoint scn number to the current scn number and top of the corresponding datafile Blocks.after its open the database.Redologfiles are also used for Media Recovery.


Redologfile structure:
------------------------------
Redologfile is Made up of o.s blocks.
if the first two blocks inside a redologfile is denoted as redologfile header.
every Redologfile in a database will have it's own header.
The first block inside a header containts information like o.s block size and total no of blocks allocated to that file and o.s name.
second block of header contains information like database name,databaseid,thread number(1),start scn,,start time,endscn,endtime etc.
All the remaining blocks inside a Redologfile are used fir holding the Redorecords.
If redorecords size is smallerthan pair of osblock inside a redologfile than that can be accomodated perfectly in that pair otherwise a redorecord can span across multiple o.s block if redorecord size is very high.
structure of Redorecord.
-------------------------------
Every Redorecord will have it's own header. The first 20bytes of space it's reserved fo it's header.
Every Redorecord holds below imformation.
They are Thread number,scnnumber,Redobyteaddress(RBA)
Thread number is always 1.
SCN number indicates at what time record got generated .
RBA specefies as address of redorecord.
RBA is a collection of logsequence number(LSN)+os block number+offset.
LOG SEQUENCE NUMBER:
----------------------------------------
When we start database first time log sequence number will be 1 for every logswitch LSN number will keep on incrementing by 1.
Log sequence number is used to identify a group of records inside an a database.
LSN plays major role in case of recoveries.
There are 3 types of logswitches in
1>Automatic
2>Manual
3>Time based logswitch.
Automatic:
when Redologfile is completely full it automatically switches to next redologfile.

Manual:
As a DBA we can issue below command to force on immediate log switch.
SQL>alter system switch logfile;

Time based logswitch:
To perform logswitch based on a time we used the parameter archive_log_target dynamic parameter in pfile.
SQL>alter system set archive_log_target=1800 scope=spfile;
This parameter guarantee logswitch for the time specified by this parameter.
In real time we 30min logswitch occurs.In day 48 log switch occurs.
Logwriter cannot able to write into corrupted redologfiles.
If unable to write than database will go into hangstate,To overcome to this problem we use multiplex the redlogfiles.
If you maintain morethan one redologfile even one redologfile gets corrupted in that oracle can still operate with remaining corrupted files.
To bring all redologfiles under a single unit we use concept called redolog group.
Redolog group is a logical entity which is collection of one or more redologfiles.







No comments:

Post a Comment