Monday, August 24, 2020

Redo Log Files in Oracle Database

 Introduction


Redo Log Files(.log): Oracle maintains logs of all the transaction against the database,These transactions are recoreded in files called online redo log files(Redo logs) The main purpose of the redo log files is to hold information as recovery in the event of system failure,redo log stores a log of all changes made to the database the redolog files must perform well and be protected against hardware failures (through software or hardware fault tolerance).if redolog information is lost,one cannot recover the system when a transcation occurs in the database,it is entered in the redo log buffers,while the data blocks affected by the transactions are not immediately written to disk,in an oracle database there are at atleast three or more redolog files,oracle  writes to redolog files in a cyclical order i.e after the first log file is filled ,it writes to the second log file,untill that one is filled .when all the redo log files have been filled,it returns to the first log file and begin overwrite its content with new transaction data.note if the database is running in ARCHIVELOG mode,the database will make a copy of the online redolog files before overwriting them


How to increase the size of the redo log files?


Steps :

`       Add new groups with larger size

        drop existing inactive members.


sql>select member from v$logfile;


  eg: expected : 100m Current : 50M  (recommended 1G-2G in live for faster performance)


Adding New Groups:


sql>ALTER DATABASE

ADD LOGFILE GROUP 4 '/oradata/prod/redo4.log' size 200m;


ALTER DATABASE

ADD LOGFILE GROUP 5 '/oradata/prod/redo5.log' size 200m;


ALTER DATABASE

ADD LOGFILE GROUP 6 '/oradata/prod/redo6.log' size 200m;



sql>select group#,members,bytes/1024/1024,status from v$log;


Use manual log switch to make use of new redo groups.


sql>alter system switch logfile;




Now drop inactive groups of different in size.


sql>ALTER DATABASE DROP LOGFILE GROUP 1;

sql>ALTER DATABASE DROP LOGFILE GROUP 2;

sql>ALTER DATABASE DROP LOGFILE GROUP 3;


IF found active - use log switch to make it inactive


sql>alter system switch logfile;


sql>select group#,members,bytes/1024/1024,status from v$log;



Managing Archive log files



logbuffer(1/3rdor3 secs)-lgwr-logfiles->archiver->arc log files


The process of turning online redo logfiles into offline

redolog files is known has archiving.


The offline redo logfiles are called Archivelog files.

with .arc ext


Its mandatory in production to enable archiving and optional in Development.


The content of archives can be used for recovery of datafiles.


Enabling Archive log mode:



Physical Dest - /archives/prod - .arc

mkdir -p /archives/prod


sql>archive log list

sql>show parameter log_archive_dest_1


format

sql>show parameter log_archive_format


sql>alter system set log_archive_dest_1='LOCATION=/archives/prod' scope=both;


sql>alter system set log_archive_format='%t_%r_%s.arc' scope=spfile;


%t - thread number associated with instance number1

%r - redo sequence

%s - log sequence number


sql>shutdown immediate

sql>startup mount

sql>alter database archivelog;

sql>alter database open;

sql>archive log list

sql>alter system switch logfile;

sql>exit

cd /archives/prod


redologfiles->arch(bg process) -> archivelogfile(.arc)


Here archiver is the background process writes from online

redo log files to off archivelog files when log switch occurs.


sql>show parameter log_archive_max_processes


We can have up to 30 max processes of archiver


$ps -ef | grep arc

default - 4


Note: Info on redolog it may be differ from your environment production,testing,dev naming conventions,and directory structure etc


THANKS FOR VIEWING MY BLOG FOR MORE UPDATES FOLLOW ME OR SUBSCRIBE ME



ITIL Process

ITIL Process Introduction In this Blog i am going to explain  ITIL Process, ITIL stands for Information Technology Infrastructure Library ...