The only redo log files play the important role to record the data transactions, and provide the recovery mechanism to ensure data integrity.
Online redo log files have the those characteristics:
- Record all changes made to data
- Provide a recovery mechanism
- Can be organized into groups
- At least two groups required
A transaction not being 'logged' into redo log files includes issuing 'NOLOGGING' clause in the statement or when using direct load insert.
Redo log files are group based, and at two online redo log groups are required.
Online Redo Log File Groups:
- A set of identical copies of online redo log files is called an online redo log file group.
- The LGWR background process concurrently writes the same information to all online redo log files in a group.
- The Oracle server needs a minimum of two online redo log file groups for the normal operation of a database.
- Each online redo log file in a groiup is called a member.
- Each member in a group has identical log sequence numbers and are of the same size. The log sequence number is assigned each time that the oracle server writes to a log group to uniquely identify each online redo log file. The current log sequence number is tored in the control file and in the header of all data files.
Parameters below limit the number of online redo log files:
- MAXLOGFILES: it's the parameter in CREATE DATABASE command specifies the absolute maximum of online redo log file groups.
- The maximum and default value for MAXLOGFILES depends on operating system.
- MAXLOGMEMBERS: the parameter in CREATE DATABASE command determines the maximum number of members per redo log file group.
The Oracle server sequentially records all changes made to the database in the Redo Log Buffer. The redo entries are written from the Redo Log Buffer to the current online redo log file group by the LGWR process. LGWR writes under the following situations:
- When a transaction commites
- When the Redo LOg Buffer becomes one-third full
- When there is more than a megabyte of changed records in the Redo Log Buffer
- Before the DBWn writes modified blocks in the Database Buffer Cache to the data files
LGWR writes to the online redo log files sequenctially. When the current online redo log file group is filled, LGWR begins writing to the next group. This is called a log switch.
Checkpoints
During a checkpoint:
- DBWn writes a number of dirty database buffers, which are covered by the logthat is being checkpointed, to the data files.
- The checkpoint backgroud process CKPT updates the control file to reflect that it has completed a checkpoint successfully. If the checkpint is caused by a log switch, CKPT also updates the headers of the data files.
- At every log switch
- When an instance has been shut down with the normal, trasactional, or immediate option
- When forced by setting the FAST_START_MTTR_TARGET initialization parameter
- When manually requested by the database administrator
- When the ALTER TABLESPACE [OFFLINE NORMAL|READ ONLY|BEGIN BACKUP] command causes checkpointing on specific data files
- Forcing a log switch:
SQL> ALTER SYSTEM SWITCH LOGFILE; |
- Checkpoints can be forced by setting FAST_START_MTTR_TARGET parameter, this parameter force the Oracle instance to reach the goal of that instance recovery should not take more than certain seconds, in this case 600 seconds:
FAST_START_MTTR_TARGET = 600 |
- ALTER SYSTEM CHECKPOINT command
ALTER SYSTEM CHECKPOINT; |
Adding Online Redo Log File Groups:
In some cases you might need to create additional log file groups. To create a new group of online redo log files, use the following SQL command:
ALTER DATABASE [database]
ADD LOGFILE [GROUP interger] filespec
[, [GROUP integer] filespec]...]
Ex:
ALTER DATABASE ADD LOGFILE GROUP 3 (‘$HOME/ORADATA/u01/log3a.rdo’, ‘$HOME/ORADATA/u02/log3b.rdo’) Size 1M; |
Adding new member to exsiting online redo log group:
ALTER DATABASE [database]
ADD LOGFILE MEMBER
[ ‘FILENAME’ [REUSE] [, ‘FILENAME’ [REUSE]…
TO {GROUP integer
| (‘filename’ [, ‘filename’]…)
} ]…
ALTER DATABASE ADD LOGFILE MEMBER ‘$HOME/ORADATA/u04/log1c.rdo’ TO GROUP1, ‘$HOME/ORADATA/u04/log2c.rdo’ TO GROUP2, ‘$HOME/ORADATA/u04/log3c.rdo’ TO GROUP3; |
ALTER DATABASE DROP LOGFILE GROUP 3; |
ALTER DATABASE DROP LOGFILE MEMBER ‘$HOME/ORADATA/u04/log3c.rdo’; |
2. Copy the online redo log fiels to the new location.
ALTER DATABASE RENAME FILE ‘$HOME/ORADATA/u01/log2a.rdo’ TO ‘$HOME/ORADATA/u02/log1c.rdo’; |
SQL> ALTER DATABASE OPEN;
Clearing Online Redo Log Files
ALTER DATABASE CLEAR LOGFILE command can be used to reinitialize an online redo log file.
Ex:
ALTER DATABASE CLEAR LOGFILE GROUP 2; |
Ex:
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2; |
- V$LOG
- V$LOGFILE
Archived Redo Log Files
- filled online redo log fiels can be archived.
- There are two advantages in running the database in ARCHIVELOG mode and archiving online redo log files:
- Recovery: A database backup together with online and archived redo log fiels can quarantee recovery of all committed transactions.
- Backup: This can be performed while the database is open.
- By default, the database is created in NOARCHIVELOG mode.
- Accomplished manually through SQL statements
- When successfullyu archived:
- An entry in the control file is made
- Records: archive log name, log sequence number, and high and low system change number (SCN).
- Filled online redo log files cannot be reused until:
- A checkpoint has taken place
- File has been archived by ARCn
- Can be multiplexed
- Maintained by the DBA
No comments:
Post a Comment