Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 5

MAITAINING REDO LOG FILES

1. List number and location of existing log files and display the number of redo
log file group and members your database has
Hint:
- Query the dynamic view V$LOGFILE
- Use the dynamic view V$LOG
SQL> SELECT MEMBER FROM V$LOGFILE;
-----------------------------------------------------------------
D:\ORACLE\ORADATA\LEARNING\REDO03.LOG
D:\ORACLE\ORADATA\LEARNING\REDO02.LOG
D:\ORACLE\ORADATA\LEARNING\REDO01.LOG

SQL> SELECT GROUP#,MEMBERS FROM V$LOG;


GROUP# MEMBERS
---------- ----------
1 1
2 1
3 1

2. In which database mode is your database configured? Is archiving enabled?


Hint:
- Query the dynamic view V$DATABASE
- Query the dynamic view V$INSTANCE
SQL> SELECT LOG_MODE FROM V$DATABASE;
LOG_MODE
------------
NOARCHIVELOG
SQL> SELECT ARCHIVER FROM V$INSTANCE;
ARCHIVE
-------
STOPPED

3. Add a redo log member to each group in your database located on u04, using
the follwing naming convention:
Add member to Group 1: log01b.rdo
Add member to Group 2: log02b.rdo
Verify the result
Hint:
- Execute the ALTER DATABASE ADD LOGFILE MEMBER
command to add a redo log member to each group
- Query the dynamic performance view V$LOGFILE to
verify the result.
SQL> Alter database add logfile member/
'd:\oracle\oradata\u04\redo1b.log' to group 1;
Database altered.

SQL> Alter database add logfile member


'd:\oracle\oradata\u04\redo2b.log' to group 2;
Database altered.
SQL> Alter database add logfile member
'd:\oracle\oradata\u04\redo3b.log' to group 3;

Database altered.

SQL> col group# format 99


SQL> col member format a40
SQL> select group#,member from v$logfile;
GROUP# MEMBER
------ ----------------------------------------
3 D:\ORACLE\ORADATA\LEARNING\REDO03.LOG
2 D:\ORACLE\ORADATA\LEARNING\REDO02.LOG
1 D:\ORACLE\ORADATA\LEARNING\REDO01.LOG
1 D:\ORACLE\ORADATA\U04\REDO1B.LOG
2 D:\ORACLE\ORADATA\U04\REDO2B.LOG
3 D:\ORACLE\ORADATA\U04\REDO3B.LOG

6 rows selected.

4. Add a redo log group in your database with two members located on u03 and
u04 using the following naming conventions:
Add Group 3: log03.rdo and log03b.rdo verify the result
Hint:
- Execute the ALTER DATABASE ADD LOGFILE command
to create a new group
- Query the dynamic view V$LOGFILE to display the name
of the view members of the new group
- Query the Dynamic view V$LOG to display the number
of redo log file groups and members

SQL> alter database add logfile group 4


('d:\oracle\oradata\u03\log04a.log',
'd:\oracle\oradata\u04\redo4b.log') size 1M

SQL> col group# format 99


SQL> col member format a40
SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER


------ ------- ------- ----------------------------------------
1 ONLINE
D:\ORACLE\ORADATA\LEARNING\REDO01.LOG
1 INVALID ONLINE
D:\ORACLE\ORADATA\U04\REDO1B.LOG
2 STALE ONLINE
D:\ORACLE\ORADATA\LEARNING\REDO02.LOG
2 INVALID ONLINE
D:\ORACLE\ORADATA\U04\REDO2B.LOG
3 STALE ONLINE
D:\ORACLE\ORADATA\LEARNING\REDO03.LOG
3 INVALID ONLINE
D:\ORACLE\ORADATA\U04\REDO3B.LOG
4 ONLINE
D:\ORACLE\ORADATA\U03\LOG04A.LOG
4 ONLINE
D:\ORACLE\ORADATA\U04\REDO4B.LOG

5. Remove the redo log group created in step 4


Hint:
- Execute the ALTER DATABASE DROP LOGFILE GROUP
command to remove the log group
- Query the dynamic view V$LOG to verify the result
- Remove the operating system files for th group

SQL> alter system switch logfile;


SQL> alter database drop logfile group 4;
Database altered.

Note: co the dung


SQL> alter database drop logfile member
'd:\oracle\oradata\u04\redo3b.log';

6. Resize all online redo lof files to 1024 KB. (Because we cannot resize log files,
we have to add new logs and drop the old.)
Hint:
- Execute the ALTER DATABASE ADD LOGFILE GROUP
command to add two new groups with the size 1024 KB
- Query the dynamic view V$LOG to check the active
group
- Execute the ALTER SYSTEM SWITCH LOGFILE command
to force log switches and change the group stage in
inactive. The number of log switches required will vary.
- Execute the ALTER DATABASE DROP LOGIFLE command
to remove th inactive groups
- Query the dynamic view V$LOG to verify the result.
MAINTAINING REDO LOG FILES

 Using Redo Log Files

Redo log files record all changes made to data and provide a recovery
mechanism from a system or media failure
 Redo log files are organized into groups
 An Oracle database requires at least two groups
 Each redo log within a group is called a member

 Purposes of the Redo Log Files


Redo log files provide the means to redo transactions in the event of a
database failure. Every transaction is write synchronously to the redo log
files in order to provide a recovery mechanism in case of media failure.
(With exceptions such as : direct loads and direct reads done with the
NOLOGGING option.) this includes transactions that have not yet been
committed, undo segment information, and schema and object
management statements. Redo log files are used in a situation such as an
instance failure to recover committed data that has not been written to
the data files. The redo log files are used only for recovery
 Structure of redo lof files
The database administrator can set up the Oracle database to maintain
copies of online redo log files to avoid lossing database information due to
a single point of failure
 Online Redo Log Group
 A set of identical copies of online redo log files is called an online
redo log group
 The LGWR backgroud 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
 Online redo log members
 Each online redo log file in group is called a member
 Each member in a group has identical log sequence numbers
How redo logs work
 Forcing Log swithes and checkpoints
 Adding online redo lof groups
 Adding online redo log members
 Dropping online redo log group
 Droping Online redo log members
 Clearing, relocating, or Renaming online redo log files
 Online redo log configuration
 Managing online redo logs with OMF
 Obtaining group and member information
 V$LogFile:
SQL> select group#,status,member from v$logfile;

GROUP# STATUS MEMBER


---------- ------- -----------------------------------
3 D:\ORACLE\ORADATA\TEST\REDO03.LOG
2 STALE D:\ORACLE\ORADATA\TEST\REDO02.LOG
1 STALE D:\ORACLE\ORADATA\TEST\REDO01.LOG
5 D:\ORACLE\ORADATA\TEST\RED05A.LOG
5 D:\ORACLE\ORADATA\TEST\RED05B.LOG

Status
 INVALID indicates the file is inaccessible
 STALE indicates that the contents of the file are
incomplete
 Delete indicates that the file is no longer used
 Blan indicate that the file is in use

 V$Log

SQL> select GROUP#,SEQUENCE#,BYTES,MEMBERS,STATUS from v$log;

GROUP# SEQUENCE# BYTES MEMBERS STATUS


---------- ---------- ---------- ---------- ----------------
1 164 104857600 1 INACTIVE
2 165 104857600 1 INACTIVE
3 166 104857600 1 CURRENT
5 0 5242880 2 UNUSED

Status

UNUSED
CURRENT
ACTIVE
CLEARING
CLEARING_CURRENT
INACTIVE

 Archived redo log files


 Archived redo log files
 Summary
 In this lession, you should have learned how to
 Explain the use of online redo log files
 Obtain redo lof information
 Control log switches and checkpoints
 Multiplex and maintain online redo log files
 Manage online redo log files with OMF
 Quick Reference

You might also like