Sunteți pe pagina 1din 4

Redo Log Files

The redo log files record all changes made to data in the database buffer cache. It is
used in a situation such as instance failure to recover committed data that has not
been written to the data files.
We must multiplex the redo log files to avoid the loss of data information due to a
single point of failure.

Online Redo Log Groups


- set of identical copies of online redo log files is called an online redo log
group.
- LGWR background process concurrently writes the same information to
all online redo log files in a group.
- Needs a minimum of two online redo log file groups for the normal
operation of a database.

Online Redo Log Members

- each online redo log file in a group is called member.


- Each member in a group has identical log sequence numbers and the same
size which is assigned each time the oracle aserver starts writing to a log
group to identify each redo log file uniquely. Current log sequence
number is stored in the CF and in the header of all data files.

Initial set of online redo groups and members are created during the database creation:
Parameters limit the number of online redo log files:
MAXLOGFILES - used in CREATE DB command specifies the absolute
max of online redo log groups. Max and default depends on O/S.
MAXLOGMEMBERS- used in CREATE DB command determines the max
number of members per group. Max and default depends on O/S.
LOG_FILES - initialization parameter sets the current max number of the log
groups that can be opened at run time for the db, and cant exceed MAXLOGFILES.

REDO LOG BUFFER

LGWR

ONLINE REDO LOG FILE

Oracle server sequentially records all changes made to the db in the redo log
buffer. The redo log buffer is used in a circular manner. The redo entries are
written to one of the online redo log groups called the current online redo log
group by the LGWR process when
- when a transaction commits.
- When the redo log buffer becomes 1/3 full.
- When there is more than a MB of changed records in the RLB.
- When a timeout occurs (every 3 secs).
- When the DBWR writes modified blocks in the DBBC to the DF.
LOG SWITCHES
LGWR writes to the online redo log files sequentially – that is, when the current
online redo group is filed, LGWR begins writing to the next group. When the last is
filled, LGWR returns to the first group and starts writing again.
DBA can also force log switches. Each time a log switch occurs and LGWR begins
writing a new log group, the oracle server assigns a number known as the log
sequence number to identify the set of redo entries.
When a log switch occurs, an event called a checkpoint is initiated.
Its the event during which LGWR stops writing to one online redo log group and
starts writing to another. You can even force it by:
ALTER SYSTEM SWITCH LOGFILE;

Checkpoints
During a checkpoint
A number of dirty database buffers covered by the log being checkpointed r written to
the datafile’s by DBWn. The number of buffers being written by DBWn is determined
by the parameter FAST_START_IO_TARGET, if specified. CKPT occurs at:
- every log switch.
- shutdown
- when forced by LOG_CHECKPOINT_INTERVAL,
LOG_CHECKPOINT_TIMEOUT.
- info about each is recorded in alert file, if
LOG_CHECKPOINTS_TO_ALERT is set to TRUE.
- force by DBA
ALTER SYSTEM CHECKPOINT;
Find the status of redo log files
V$LOG : GROUP#, MEMBERS, STATUS
Unused : indicates that the online redo log group has never been written
to.
Current : indicates the current online redo log group. Implies that the
online redo log group is active.
Active : indicates that the online log group is active but is not the
current redo log group. It is needed for crash recovery.
V$LOGFILE : STATUS
invalid : indicates that the file is inaccessible
stale : indicates that contents of the file are incomplete; e.g.
adding a log file member.
deleted : indicates that the file is no longer used.
Blank indicates that the file is in use.

select a.group#,a.status,b.member from v$log a,v$logfile b


where a.group#=b.group#
Adding a log group
- ALTER DATABASE ADD LOGFILE GROUP 3
(‘PATH\REDO01.LOG’) SIZE 1M;
- ALTER DATABASE ADD LOGFILE GROUP 3
(‘PATH\REDO01.LOG’) SIZE 1M REUSE;

- ALTER DATABASE DROP LOGFILE GROUP 3;

- Adding a log member to a log group


ALTER DATABASE ADD LOGFILE MEMBER
‘PATH….LOG’ TO GROUP 1

- ALTER DATABASE DROP LOGFILE MEMBER


‘PATH….LOG’ ;

- how to relocate or rename online Redo Log File


ALTER DATABASE RENAME <OLD> TO <NEW>

- if a redo log file is corrupted in all members


ALTER DATABASE CLEAR LOGFILE
‘PATH….LOG’;

- If an online redo log file has been corrupted while the database is opened.
ALTER DATABASE CLEAR LOGFILE;
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP1;

It overcomes two situations where dropping redo logs is not possible:


If there r only two logs groups.
The corrupt redo log file belongs to the current group.

Loss of inactive Redo Logs

Circumstances:
Archive mode
Redo logs files lost re not current.
Redo log files r mirrored.

1. when started up thrown error.


Open failed for members of log group 1 of thread 1
Online log 1 thread 1 : ‘d:\data\log1a.rdo’
2. check from select * from v$log; group 2 is current.
3. find the location of where the file was previously located
select * from V$LOGFILE;

status : invalid : indicates that the file is inaccessible


stale : indicates that contents of the file are incomplete; e.g.
adding a log file member.
deleted : indicates that the file is no longer used.
Blank : indicates that the file is in use.
4. you cant drop a log group, since there must always be at least two log groups:
ALTER DATABASE ADD LOGFILE GROUP 3
‘C:\ORACLE\DATA\LOG3.RDO’ SIZE 150K;
5. now drop the log group
ALTER DATABASE DROP LOGFILE GROUP 1;
6. ALTER DATABASE OPEN;
7. immediately multiplex all redo logs. To reduce the chance of losing data.

1. Loss of INACTIVE online Redo Log Group

1. Shut down the instance.


2. mount the database.
3. if the lost log file was ARCHIVED, check the V$LOG.
V$LOG
Unused : indicates that the online redo log group has never been written
to.
Current : indicates the current online redo log group. Implies that the
online redo log group is active.
Active : indicates that the online log group is active but is not the
current redo log group. It is needed for crash recovery.

4. if there is an offline data file, check V$DATAFILE that requires the


cleared unarchived log to bring it online. Issue
ALTER DATABASE CLEAR LOGFILE;
The keywords UNRECOVERABLE DATAFILE are required.
The datafile and its entire tbs must be dropped from the DB because the
redo necessary to bring it online it being cleared, and there is no copy of it.
5. add a new redo log group by using the information noted on the DB
configuration checklist such as
ALTER DATABASE ADD LOGFILE GROUP 3
‘……….\DATA\DISK3\redo0301.log’ size 150k
6. drop the damaged redo log file group
ALTER DATABASE DROP LOGFILE GROUP X; Appropriate group#
7. add a member to the logfile group 3
ALTER DATABASE ADD LOGFILE MEMBER
‘……….\DATA\DISK’4\redo0302.log’ to group 3;
8. determine if a full offline backup is required, and perform one if necessary.
9. ensure that the instance is started and that the DB is open.