Showing posts with label Log File. Show all posts
Showing posts with label Log File. Show all posts

Monday, August 3, 2015

Resize the Redo log file.

We can not resize the redo log file. We must drop and recreate redo log file. When we want to drop redo log file it must be in INACTIVE, if redo log file status are not INACTIVE we have to change the status after dropped from database it will update in control file and we need to remove operating system file manually.

Forcing Checkpoint : Forcing a checkpoint are ensure that all changed in the database buffer cache are written in datafile by using ALTER SYSTEM CHECKPOINT GLOBAL;

[oracle@OEL64BN1 ~]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.3.0 Production on Mon Aug 3 16:08:18 2015
Copyright (c) 1982, 2011, Oracle.  All rights reserved.
SQL> conn /as sysdbda
Connected.
SQL> SELECT GROUP#,SEQUENCE#,BYTES,ARCHIVED,STATUS FROM V$LOG;
    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
 1  49752428800 YES INACTIVE
 2  49652428800 YES INACTIVE
 3  49852428800 NO  CURRENT
SQL>  alter system checkpoint global ;
System altered.
SQL> select sum(bytes)/1024/1024 file_size, group# group_number from v$log group by GROUP#;
 FILE_SIZE GROUP_NUMBER
---------- ------------
50      1
50      2
50      3
SQL> col member format a35
col member format a65
set lines 130
set pages 100
select group#,type, member from v$logfile;SQL> SQL> SQL> SQL>
    GROUP# TYPE    MEMBER
---------- ------- -----------------------------------------------------------------
 3 ONLINE  /u01/app/oracle/oradata/orcln1/redo03.log
 2 ONLINE  /u01/app/oracle/oradata/orcln1/redo02.log
 1 ONLINE  /u01/app/oracle/oradata/orcln1/redo01.log
3 rows selected.
SQL> ALTER DATABASE DROP LOGFILE GROUP 1;
Database altered.
SQL> !
[oracle@OEL64BN1 ~]$ rm /u01/app/oracle/oradata/orcln1/redo01.log
[oracle@OEL64BN1 ~]$ exit
exit
SQL> ALTER DATABASE ADD LOGFILE GROUP 1 '/u01/app/oracle/oradata/orcln1/redo01.log' SIZE 1G;
Database altered.
SQL> ALTER DATABASE DROP LOGFILE GROUP 2;
Database altered.
SQL> exit    !
[oracle@OEL64BN1 ~]$ exitrm /u01/app/oracle/oradata/orcln1/redo01.log.log2.log
[oracle@OEL64BN1 ~]$ exit
exit
SQL> SELECT GROUP#,SEQUENCE#,BYTES,ARCHIVED,STATUS FROM V$LOG;
    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
 1    0 1073741824 YES UNUSED
 3  49852428800 NO  CURRENT
SQL> ALTER DATABASE ADD LOGFILE GROUP 2 '/u01/app/oracle/oradata/orcln1/redo02.log' SIZE 1G;
Database altered.
SQL> SELECT GROUP#,SEQUENCE#,BYTES,ARCHIVED,STATUS FROM V$LOG;
    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
 1    0 1073741824 YES UNUSED
 2    0 1073741824 YES UNUSED
 3  49852428800 NO  CURRENT
SQL> ALTER SYSTEM SWITCH LOGFILE ;
System altered.
SQL> SELECT GROUP#,SEQUENCE#,BYTES,ARCHIVED,STATUS FROM V$LOG;
    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
 1  499 1073741824 NO  CURRENT
 2    0 1073741824 YES UNUSED
 3  498 52428800 YES ACTIVE
SQL> ALTER SYSTEM SWITCH LOGFILE ;
System altered.
SQL> alter system checkpoint global;
System altered.
SQL> SELECT GROUP#,SEQUENCE#,BYTES,ARCHIVED,STATUS FROM V$LOG;
    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
 1  499 1073741824 YES INACTIVE
 2  500 1073741824 NO  CURRENT
 3  49852428800 YES INACTIVE
SQL> ALTER DATABASE DROP LOGFILE GROUP 3;
Database altered.
SQL> !
[oracle@OEL64BN1 ~]$ rm /u01/app/oracle/oradata/orcln1/redo02.log.log3.log
[oracle@OEL64BN1 ~]$ exit
exit
SQL> ALTER DATABASE ADD LOGFILE GROUP 3 '/u01/app/oracle/oradata/orcln1/redo03.log' SIZE 1G;
Database altered.
SQL>  SELECT GROUP#,SEQUENCE#,BYTES,ARCHIVED,STATUS FROM V$LOG;
    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
 1  499 1073741824 YES INACTIVE
 2  500 1073741824 NO  CURRENT
 3    0 1073741824 YES UNUSED
SQL> ALTER SYSTEM SWITCH LOGFILE ;
System altered.
SQL> alter system checkpoint global;
System altered.
SQL> SELECT GROUP#,SEQUENCE#,BYTES,ARCHIVED,STATUS FROM V$LOG;
    GROUP#  SEQUENCE#   BYTES ARC STATUS
---------- ---------- ---------- --- ----------------
 1  499 1073741824 YES INACTIVE
 2  500 1073741824 YES INACTIVE
 3  501 1073741824 NO  CURRENT
SQL> select sum(bytes)/1024/1024 file_size, group# group_number from v$log group by GROUP#;
 FILE_SIZE GROUP_NUMBER
---------- ------------
      1024      1
      1024      2
      1024      3

log file switch (checkpoint incomplete)

Checkpoint : When LGWR (Log Writer) need to switch next log file, it asks DBWR(DB Writer) to flash dirty (Updated) block into the disk this is checkpoint.

log file switch (checkpoint incomplete): Oracle can't reuse a log file if all modified blocks are not flashed onto the disk, it will wait until flash modified blocks by the previous checkpoint.

Cause : If there are few/ too small redo logs and system produces enough redo to cycle through all the logs before DBWR has been able to complete the checkpoint, then increase the size or number of redo logs.

             If DBWR performance slow due to System I/O.

Solution : If few/small redo logs increase the redo logs, analyze DBWR performance In my case redo was small size.


SQL> SET LINE 200
SQL> col INSTANCE_NAME FORMAT A10
SQL> col SESSION_INFO FORMAT A15
SQL> col EVENT FORMAT A40
SQL> col WAIT_CLASS FORMAT A20
SQL> col WAIT_TIME FORMAT 99999999
SQL>
SQL> SELECT I.INSTANCE_NAME, W.SID||':'||S.SERIAL# SESSION_INFO, W.EVENT, W.WAIT_CLASS_ID, W.WAIT_CLASS, W.WAIT_TIME
  2  FROM GV$SESSION_WAIT W, GV$SESSION S, GV$SQL Q, GV$INSTANCE I
  3  WHERE W.INST_ID=S.INST_ID
  4  AND S.INST_ID=Q.INST_ID
  5  AND I.INST_ID=Q.INST_ID
  6  AND W.SID=S.SID
  7  AND S.SQL_ID=Q.SQL_ID
  8  AND W.WAIT_TIME =0
AND W.EVENT<>'SQL*Net message from client'
AND W.WAIT_CLASS<>'Idle'
  9   10   11  ORDER BY W.SID;
INSTANCE_N SESSION_INFO    EVENT                                    WAIT_CLASS_ID WAIT_CLASS           WAIT_TIME
---------- --------------- ---------------------------------------- ------------- -------------------- ---------
spftldb    3408:1595       log file switch (checkpoint incomplete)     3290255840 Configuration                0
spftldb    5666:895        log file switch (checkpoint incomplete)     3290255840 Configuration                0
spftldb    5666:895        log file switch (checkpoint incomplete)     3290255840 Configuration                0
spftldb    5666:895        log file switch (checkpoint incomplete)     3290255840 Configuration                0
SQL>