Redolog file management :
The purpose of checkpoint process to synchronize the buffer cache information with
the information on the disk
-->Redolog record all the block level updating made to the database.
Every database must have at least two redolog groups and one file per group.
-->These files can be mirrored to avoid single point failure.
-->These are used by oracle during instance recovery and media failure.these files are written
in circular fashion to save disk space.
-->The filled redolog files will be archived if the databse is running in archivedlog mode.
-->It is strongly recommended that database should archivelog mode
For example:
the information on the disk
-->Redolog record all the block level updating made to the database.
Every database must have at least two redolog groups and one file per group.
-->These files can be mirrored to avoid single point failure.
-->These are used by oracle during instance recovery and media failure.these files are written
in circular fashion to save disk space.
-->The filled redolog files will be archived if the databse is running in archivedlog mode.
-->It is strongly recommended that database should archivelog mode
For example:
If power failures abruptly and data in memory cannot be written on datafiles,however oracle recovers the unrecorded data in datafiles by applying redologs.the process of applying the redolog during recovery operation is called as rolling forward.
Mirrored REDO Logs :
The recommended redolog file configuration is,at least 2 redolog members per group.
All memebers of a group of logfiles contain the same information.
Group member update simultaneously.
Each group may or may not contain the same number of members as other groups.
Log switches :
A log switches occurs when oracle switches from one redolog to another.
A log switc occurs LGWR has filled one log file group.
A log switch can be forced by a DBA when the current redo log needs to be archived.
At alog switch the current redolog file is assigned a log sequence number that identifies the information stored
in that redolog and is also used for synchornization.A checkpoint automatically occurs at a logswitch.
Number of stages in redolog file
1.UNUSED
2.CURRENT
3.ACTIVE
4.INACTIVE
1. UNUSED: New creates redolog file.
2.CURRENT: Is the redolog file the log writter is currently writing to disk.
3.ACTIVE : when ever logwritter occurs the sattus of current redolog file changes to active and check point process is invoke.the checkpoint process invoke the and it take the snap shot of redolog file and stored it into at archive redolog file.after that the status of redolog file changes into inactive.
-->When ever a new data gets into database buffer cache it moves to redolog buffer and from redolog b-uffer to it moves to redolog file.
-->In case of 1st redolog file filled up automatically a log switch occurs and a log sequence number is
generated is also know as (LSN).
-->oracle generates log sequence number to uniquely identify every log switch status.if the second file is alsofilled up logwriter starts overwriting the first redolog file.therefore recovery of entire of data impossible from theredolog file.
-->by default archivelog mode is disabled
To check the name of the database instance
sys>>select name from v$database;
To check the archive log status
sys>>select log_mode from v$database;
sys>>archive log list;
-->In case of 1st redolog file filled up automatically a log switch occurs and a log sequence number is
generated is also know as (LSN).
-->oracle generates log sequence number to uniquely identify every log switch status.if the second file is alsofilled up logwriter starts overwriting the first redolog file.therefore recovery of entire of data impossible from theredolog file.
-->by default archivelog mode is disabled
To check the name of the database instance
sys>>select name from v$database;
To check the archive log status
sys>>select log_mode from v$database;
sys>>archive log list;
Steps to enable the archive log mode;
Step 1: Shutdown the database
sys>>shutdown immediate;
Step 2: Edit the p file
$cd $ORACLE_HOME/dbs
$vi init$ORACLE_SID.ora
log_archive_dest=/disk1/oradata/ORCL/arch/
:wq (save and exit)
$mkdir -p /disk1/oradata/ORCL/arch
Step 3: sqlplus / as sysdba
sys>>startup mount;
Step 4 : Enable the archive log mode
sys>>alter database archivelog;
Step 5: sys>>alter database open;
Check the status of databse and archivelog.
sys>>select status from v$instance;
sys>>select log_mode from v$database;
sys>>archive log list;
sys>>select status from v$instance;
sys>>select log_mode from v$database;
sys>>archive log list;
To switch logfile
sys>>alter system switch logfile;
sys>>select GROUP#,members,sequence#,archived,status from v$log;
sys>>select group#,bytes/1024/1024 from v$log;
ADDING redolog GROUP:
sys>>alter database add logfile group 3 ('/disk1/oradata/ORCL/redolog3a.log',
'/disk1/oradata/ORCL/redolog3a.log') size 4m;
ADDING redolog file :
sys>>alter database add logfile member '/disk1/oradata/ORCL/redolog2b.log' to group 2;
sys>>alter system switch logfile;
sys>>select GROUP#,members,sequence#,archived,status from v$log;
sys>>select group#,bytes/1024/1024 from v$log;
ADDING redolog GROUP:
sys>>alter database add logfile group 3 ('/disk1/oradata/ORCL/redolog3a.log',
'/disk1/oradata/ORCL/redolog3a.log') size 4m;
ADDING redolog file :
sys>>alter database add logfile member '/disk1/oradata/ORCL/redolog2b.log' to group 2;
To rename redolog file :
Bring the database to mountstate
Step 1: Sshutdown the database
sys>>shutdown immediate;
Step 2: Copy and move the redolog file to different location
$cp /disk1/oradata/ORCL/redolog2a.log /disk2/oradata/ORCL/redolog2a.log
Step 3: Bring the databse to mount
sys>>startup mount;
Step 4: Alter database rename file '/disk1/oradata/ORCL/redolog2a.log'
To '/disk1/oradata/ORCL/redolog2new.log';
Step 5: Open the database
sys>>alter database open;
To clear Online redolog files
sys>>alter database clear unarchived logfile group 2;
Dropping a redolog group :
sys>>alter database drop logfile group 3;
Dropping a logfile from Group
sys>>alter database drop logfile member '/disk1/oradata/ORCL/redolog2a.log';
Note :
we cannot drop a file which is active or current
SQL> select group#,members,status from v$log;
GROUP# MEMBERS STATUS
---------- ---------- ----------------
1 1 INACTIVE
2 1 CURRENT
3 1 INACTIVE
for more information check the Data dictionary views :
V$LOG
V$LOGFILE
V$LOG_HISTORY
V$LOGHIST
V$RECOVERY_LOG
V$ARCHIVED_LOG
Step 1: Sshutdown the database
sys>>shutdown immediate;
Step 2: Copy and move the redolog file to different location
$cp /disk1/oradata/ORCL/redolog2a.log /disk2/oradata/ORCL/redolog2a.log
Step 3: Bring the databse to mount
sys>>startup mount;
Step 4: Alter database rename file '/disk1/oradata/ORCL/redolog2a.log'
To '/disk1/oradata/ORCL/redolog2new.log';
Step 5: Open the database
sys>>alter database open;
To clear Online redolog files
sys>>alter database clear unarchived logfile group 2;
Dropping a redolog group :
sys>>alter database drop logfile group 3;
Dropping a logfile from Group
sys>>alter database drop logfile member '/disk1/oradata/ORCL/redolog2a.log';
Note :
we cannot drop a file which is active or current
SQL> select group#,members,status from v$log;
GROUP# MEMBERS STATUS
---------- ---------- ----------------
1 1 INACTIVE
2 1 CURRENT
3 1 INACTIVE
for more information check the Data dictionary views :
V$LOG
V$LOGFILE
V$LOG_HISTORY
V$LOGHIST
V$RECOVERY_LOG
V$ARCHIVED_LOG
No comments:
Post a Comment