Redo Log Management

Redo Log Management

The maximum size permitted for a redo log is 4MB.
However, with a block size of 4K, there is increased redo wastage. In fact, the amount of redo wastage in 4K blocks versus 512B blocks is significant. You can determine the amount of redo wastage by viewing the statistics stored in the V$SESSTAT and V$SYSSTAT views.

SQL>SELECT name, value FROM v$sysstat WHERE name = 'redo wastage';

The following statement adds a redo log file group with a block size of 512B. The BLOCKSIZE 512 clause is valid but not required for 512B sector size disks. For 4K sector size emulation-mode disks, the BLOCKSIZE 512 clause overrides the default 4K size

o    SQL>ALTER DATABASE orcl ADD LOGFILE
o    GROUP 4 ('/u01/logs/orcl/redo04a.log','/u01/logs/orcl/redo04b.log')
o    SIZE 100M BLOCKSIZE 512 REUSE;
To ascertain the redo log file block size, run the following query
o    SQL> SELECT BLOCKSIZE FROM V$LOG;

o    BLOCKSIZE
o    ---------
o    512

The changes that are being applied by the standby database can lag behind the changes that are occurring on the primary database, because the standby database must wait for the changes in the primary database redo log to be archived (into the archived redo log) and then shipped to it. To limit this lag, you can set the ARCHIVE_LAG_TARGET initialization parameter. Setting this parameter lets you specify in seconds how long that lag can be.

o    ARCHIVE_LAG_TARGET = 1800
ARCHIVE_LAG_TARGET is a dynamic parameter and can be set with the ALTER SYSTEM SET statement.

This parameter can be set even if you are not using standby database. To forced the log to e switched and archived.

ALTER SYSTEM SET ARCHIVE_LAG_TARGET=1800

Creating Redo Log Groups and Members
Ø  Creating Redo Log Groups
ALTER DATABASE ADD LOGFILE ('/oracle/dbs/log1c.rdo', '/oracle/dbs/log2c.rdo') SIZE 100M;

Using group numbers can make administering redo log groups easier. However, the group number must be between 1 and MAXLOGFILES

ALTER DATABASE ADD LOGFILE GROUP 10 ('/oracle/dbs/log1c.rdo', '/oracle/dbs/log2c.rdo') SIZE 100M BLOCKSIZE 512;  * Block size clause is optional
v  Creating Redo Log Members:
Ø  Creating a log file member
ALTER DATABASE ADD LOGFILE MEMBER '/oracle/dbs/log2b.rdo' TO GROUP 2;

Notice that filenames must be specified, but sizes need not be. The size of the new members is determined from the size of the existing members of the group

When using the ALTER DATABASE statement, you can alternatively identify the target group by specifying all of the other members of the group in the TO clause, as shown in the following example:
ALTER DATABASE ADD LOGFILE MEMBER '/oracle/dbs/log2c.rdo'
    TO ('/oracle/dbs/log2a.rdo', '/oracle/dbs/log2b.rdo');

*        Fully specify the filenames of new log members to indicate where the operating system files should be created. Otherwise, the files will be created in either the default or current directory of the database server, depending upon your operating system. You may also note that the status of the new log member is shown as INVALID. This is normal and it will change to active (blank) when it is first used.
v  Relocating and Renaming Redo Log Members:
Ø  Steps for Renaming and Relocate the  Redo Log Members
1.       SHUTDOWN

The following example uses operating system commands (UNIX) to move the redo log members to a new location:
mv /diska/logs/log1a.rdo /diskc/logs/log1c.rdo
mv /diska/logs/log2a.rdo /diskc/logs/log2c.rdo

2.       Startup the database, mount, but do not open it.
CONNECT / as SYSDBA
STARTUP MOUNT

3.       Rename the redo log members.
Uses the ALTER DATABASE statement with the RENAME FILE clause to rename the database redo log files.

ALTER DATABASE
  RENAME FILE '/diska/logs/log1a.rdo', '/diska/logs/log2a.rdo'
           TO '/diskc/logs/log1c.rdo', '/diskc/logs/log2c.rdo';

Open the database for normal operation:
ALTER DATABASE OPEN;

v  Dropping Redo Log Groups and Members:
Dropping Log Groups:

Condition for dropping a redo log Group
·          An instance requires at least two groups of redo log files, regardless of the number of members in the groups. (A group comprises one or more members.)

·          You can drop a redo log group only if it is inactive. If you must drop the current group, then first force a log switch to occur.

·          Make sure a redo log group is archived (if archiving is enabled) before dropping it. To see whether this has happened, use the V$LOG view.

SELECT GROUP#, ARCHIVED, STATUS FROM V$LOG;

   GROUP# ARC STATUS
--------- --- ----------------
        1 YES ACTIVE
        2 NO  CURRENT
        3 YES INACTIVE
        4 YES INACTIVE

ALTER DATABASE DROP LOGFILE GROUP 3;
                      Conditions for dropping a redo log member of the group.
·          It is permissible to drop redo log files so that a multiplexed redo log becomes temporarily asymmetric. For example, if you use duplexed groups of redo log files, you can drop one member of one group, even though all other groups have two members each. However, you should rectify this situation immediately so that all groups have at least two members, and thereby eliminate the single point of failure possible for the redo log.

·          An instance always requires at least two valid groups of redo log files, regardless of the number of members in the groups. (A group comprises one or more members.) If the member you want to drop is the last valid member of the group, you cannot drop the member until the other members become valid. To see a redo log file status, use the V$LOGFILE view. A redo log file becomes INVALID if the database cannot access it. It becomes STALE if the database suspects that it is not complete or correct. A stale log file becomes valid again the next time its group is made the active group.

·          You can drop a redo log member only if it is not part of an active or current group. To drop a member of an active group, first force a log switch to occur.

·          Make sure the group to which a redo log member belongs is archived (if archiving is enabled) before dropping the member. To see whether this has happened, use the V$LOG view.

ALTER DATABASE DROP LOGFILE MEMBER '/oracle/dbs/log3c.rdo';

v  FORCING  LOG SWITCHES:
For example, you want to drop the currently active group, but are not able to do so until the group is inactive. You may also want to force a log switch if the currently active group must be archived at a specific time before the members of the group are completely filled.

ALTER SYSTEM SWITCH LOGFILE;

v  VERFYING BLOCK S IN THE REDO LOG FILES:

DB_BLOCK_CHECKSUM to TYPICAL
An error is raised and written to the alert log if corruption is detected.

If corruption is detected in a redo log block while trying to archive it, the system attempts to read the block from another member in the group. If the block is corrupted in all members of the redo log group, then archiving cannot proceed.
The value of the DB_BLOCK_CHECKSUM parameter can be changed dynamically using the ALTER SYSTEM statement.

v  CLEARING A REDO LOGFILE:
A redo log file might become corrupted while the database is open, and ultimately stop database activity because archiving cannot continue. In this situation the ALTER DATABASE CLEAR LOGFILE statement can be used to reinitialize the file without shutting down the database.
ALTER DATABASE CLEAR LOGFILE GROUP 3;

If the corrupt redo log file has not been archived, use the UNARCHIVED keyword in the statement.

ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 3;

Note* : If you clear an unarchieved redo log file, you should make another backup of the database.

To clear an unarchived redo log that is needed to bring an offline tablespace online, use the UNRECOVERABLE DATAFILE clause in the ALTER DATABASE CLEAR LOGFILE statement.

If you clear a redo log needed to bring an offline tablespace online, you will not be able to bring the tablespace online again. You will have to drop the tablespace or perform an incomplete recovery. Note that tablespaces taken offline normal do not require recovery.

v  Redo Log Data Dictionary Views
V$LOG                                              Displays the redo log file information from the control file
V$LOGFILE                                     Identifies redo log groups and members and member status
V$LOG_HISTORY                         Contains log history information
                      SELECT * FROM   V$LOGFILE;
                   GROUP#   STATUS  MEMBER
                   ------  -------  ----------------------------------
                                      1                  D:\ORANT\ORADATA\IDDB2\REDO04.LOG
                                      2                  D:\ORANT\ORADATA\IDDB2\REDO03.LOG
                                      3                  D:\ORANT\ORADATA\IDDB2\REDO02.LOG
                                      4                  D:\ORANT\ORADATA\IDDB2\REDO01.LOG
Note *: If STATUS is blank for a member, then the file is in use.

No comments:

Post a Comment