Redo Log File in Oracle Database
Published by : Obay Salah , November 19, 2024
This file is to record the changes that occur in the database so that the changes that have been committed or not are recorded.
We benefit from these files in restoring the database in the event of a problem. So that there is some data that has not been written in the Data Files while it was written in the Redo Log Files.
This file is in the form of GROUP so that the database works with at least two groups.
So this file is used as a basis for the retrieval process in case of an error as it contains the changes that occur to the data.
To ensure the preservation of this file, each Group is organized in the form of Members and each Member within the Group is a copy of the original, the goal of which is to reduce the risk of loss.
LGWR Background Process writes the data in the Redo log Buffer to the Redo Log Files.
Once the Redo Log File is filled, LGWR switches to the other Redo Log File in a process known as Log Switch.
If Oracle Server writes all changes to the database in the Redo Log Buffer, these variables are written from the Buffer to the Redo Log File via LGWR in the following cases:-
1- The moment of committing the operations.
2- The moment the Buffer is filled to one third.
3- Before the DBWn operation.
So the Log Switch process happens automatically without any intervention from the database administrator, but the database administrator may sometimes need to do this task manually through the following command:
ALTER SYSTEM SWITCH LOGFILE;
Also, the Checkpoint process occurs automatically when the Log Switch occurs.
Also, the Checkpoint can be done automatically by the database manager with the following command:-
ALTER SYSTEM CHECKPOINT;
Add Online Redo Log Files Group:
Sometimes we need to add a new Online Redo Log Files Group, by doing the following:-
ALTER DATABASE ADD LOGFILE GROUP 4 ‘D:\ORACLE\PRODUCT\10.1.0\ORADATA\OBAY\REDO04.RDO’ SIZE 10M;
Add Groups to Members:
ALTER DATABASE ADD LOGFILE MEMBER 'D:\oracle\product\10.1.0\oradata\OBAY\RED1.RDO' TO GROUP 1, 'D:\oracle\product\10.1.0\oradata\OBAY\RED2.RDO ' TO GROUP ٢, 'D:\oracle\product\10.1.0\oradata\OBAY\RED3.RDO' TO GROUP 3, 'D:\oracle\product\10.1.0\oradata\OBAY\RED4RD O' TO GROUP 4;
Delete Online Redo Log Groups:
ALTER DATABASE DROP LOGFILE GROUP 4;
Note that the database operates on at least two Groups, and current or active Groups cannot be deleted.
Delete Online Redo Log Members:
ALTER DATABASE DROP LOGFILE MEMBER ‘D:\ORACLE\PRODUCT\10.1.0\ORADATA\OBAY\RED3.RDO;
Clearing Online Redo Log File:
It is to solve the problem of the failure that occurs to all members in the group, it implicitly means re-creating the Redo Log Files.
ALTER DATABASE CLEAR LOGFILE GROUP 2;
If the database is running in Archive log mode, the above Clearing process will fail if the 2 Groups are not archived. In general, we will talk about the subject of archiving later, but to solve this problem, the previous command can be modified as follows: -
ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2;
But before doing this, you must make a full backup of the database.
Renaming the Redo Log Files:-
You can rename the Redo Log Files or change their location by adding a new Log File and deleting the old one.
You can also use the ALTER DATABASE RENAME FILE command, but this command requires bringing the database to MOUNT mode.
Losing the Redo Log File:
If we lose a Member from the Redo Log Files Group, the database will remain open and available as long as there is another Member in the Group,
But we will receive warning messages in the Alert log File. Of course, it is possible to recover by making copies of one of the existing Members and then renaming it.
To receive the Redo Log File:
V$LOG
V$LOGFILE
Comments
no comment yet!