7
DBA Tips Archive for Oracle Resizing / Recreating Online Redo Log Files by Jeff Hunter, Sr. Database Administrator One of the best ways I have found to resize or recreate online redo log files and keep the current sequence is to perform it online. In this example, we will resize all online redo logs from 100MB to 250MB while the database is running and use SQL*Plus to drop/recreate them in stages. Before looking at the tasks involved to perform the resize, let's look at the current online redo log groups and their sizes: SQL> SELECT a.group#, a.member, b.bytes 2 FROM v$logfile a, v$log b WHERE a.group# = b.group#; GROUP# MEMBER BYTES ---------- ---------------------------------------- ------------ 1 /u03/app/oradata/ORA920/redo_g01a.log 104,857,600 1 /u04/app/oradata/ORA920/redo_g01b.log 104,857,600 1 /u05/app/oradata/ORA920/redo_g01c.log 104,857,600 2 /u03/app/oradata/ORA920/redo_g02a.log 104,857,600 2 /u04/app/oradata/ORA920/redo_g02b.log 104,857,600 2 /u05/app/oradata/ORA920/redo_g02c.log 104,857,600 3 /u03/app/oradata/ORA920/redo_g03a.log 104,857,600 3 /u04/app/oradata/ORA920/redo_g03b.log 104,857,600 3 /u05/app/oradata/ORA920/redo_g03c.log 104,857,600 9 rows selected. Now let's take a look at the steps involved to resize / recreate all online redo log groups: Make the last redo log CURRENT Force a log switch until the last redo log is marked "CURRENT" by issuing the following command: SQL> select group#, status from v$log; GROUP# STATUS ---------- ---------------- 1 CURRENT 2 INACTIVE 3 INACTIVE SQL> alter system switch logfile; 1. DBA Tips Archive for Oracle hp://www.idevelopment.info/data/Oracle/DBA_ps/Database_Admini... 1 of 4 1/26/2015 3:17 PM

How to Resize the Online Redo Logfiles (Doc ID 1035935.6)

Embed Size (px)

DESCRIPTION

Resize online redo log files

Citation preview

  • DBA Tips Archive for Oracle

    Resizing / Recreating Online Redo Log Filesby Jeff Hunter, Sr. Database Administrator

    One of the best ways I have found to resize or recr eate online redo log files and keep the current seq uence isto perform it online. In this example, we will resi ze all online redo logs from 100MB to 250MB while t hedatabase is running and use SQL*Plus to drop/recrea te them in stages.

    Before looking at the tasks involved to perform the resize, let's look at the current online redo log groups andtheir sizes:

    SQL> SELECT a.group#, a.member, b.bytes 2 FROM v$logfile a, v$log b WHERE a.group# = b.group# ;

    GROUP# MEMBER BYTES---------- ---------------------------------------- ------------ 1 /u03/app/oradata/ORA920/redo_g01a.log 104,857,600 1 /u04/app/oradata/ORA920/redo_g01b.log 104,857,600 1 /u05/app/oradata/ORA920/redo_g01c.log 104,857,600 2 /u03/app/oradata/ORA920/redo_g02a.log 104,857,600 2 /u04/app/oradata/ORA920/redo_g02b.log 104,857,600 2 /u05/app/oradata/ORA920/redo_g02c.log 104,857,600 3 /u03/app/oradata/ORA920/redo_g03a.log 104,857,600 3 /u04/app/oradata/ORA920/redo_g03b.log 104,857,600 3 /u05/app/oradata/ORA920/redo_g03c.log 104,857,600

    9 rows selected.

    Now let's take a look at the steps involved to resi ze / recreate all online redo log groups:

    Make the last redo log CURRENT

    Force a log switch until the last redo log is marke d "CURRENT" by issuing the following command:

    SQL> select group#, status from v$log;

    GROUP# STATUS---------- ---------------- 1 CURRENT 2 INACTIVE 3 INACTIVE

    SQL> alter system switch logfile;

    1.

    DBA Tips Archive for Oracle hp://www.idevelopment.info/data/Oracle/DBA_ps/Database_Admini...

    1 of 4 1/26/2015 3:17 PM

  • SQL> alter system switch logfile;

    SQL> select group#, status from v$log;

    GROUP# STATUS---------- ---------------- 1 INACTIVE 2 INACTIVE 3 CURRENT

    Drop first redo log

    After making the last online redo log file the CURR ENT one, drop the first online redo log:

    SQL> alter database drop logfile group 1;

    Database altered.

    As a DBA, you should already be aware that if you a re going to drop a logfile group, itcannot be the current logfile group. I have run into instances; however, where attemptingto drop the logfile group resulted in the following error as a result of the logfile grouphaving an active status:

    SQL> ALTER DATABASE DROP LOGFILE GROUP 1;ALTER DATABASE DROP LOGFILE GROUP 1*ERROR at line 1:ORA-01624: log 1 needed for crash recovery of insta nce ORA920 (thread 1)ORA-00312: online log 1 thread 1: ' '

    Easy problem to resolve. Simply perform a checkpoin t on the database:

    SQL> ALTER SYSTEM CHECKPOINT GLOBAL;

    System altered.

    SQL> ALTER DATABASE DROP LOGFILE GROUP 1;

    Database altered.

    2.

    Re-create dropped online redo log group

    Re-create the dropped redo log group with different size (if desired):

    SQL> alter database add logfile group 1 ( 2 '/u03/app/oradata/ORA920/redo_g01a.log', 3 '/u04/app/oradata/ORA920/redo_g01b.log', 4 '/u05/app/oradata/ORA920/redo_g01c.log') size 250m reuse;

    Database altered.

    3.

    Force another log switch4.

    DBA Tips Archive for Oracle hp://www.idevelopment.info/data/Oracle/DBA_ps/Database_Admini...

    2 of 4 1/26/2015 3:17 PM

  • After re-creating the online redo log group, force a log switch. The online redo log group just create dshould become the "CURRENT" one:

    SQL> select group#, status from v$log;

    GROUP# STATUS---------- ---------------- 1 UNUSED 2 INACTIVE 3 CURRENT

    SQL> alter system switch logfile;

    SQL> select group#, status from v$log;

    GROUP# STATUS---------- ---------------- 1 CURRENT 2 INACTIVE 3 ACTIVE

    Loop back to Step 2 until all logs are rebuilt

    After re-creating an online redo log group, continu e to re-create (or resize) all online redo log grou psuntil all of them are rebuilt.

    5.

    After rebuilding (resizing) all online redo log gro ups, here is a snapshot of all physical files:

    SQL> SELECT a.group#, a.member, b.bytes 2 FROM v$logfile a, v$log b WHERE a.group# = b.group# ;

    GROUP# MEMBER BYTES---------- ---------------------------------------- ------------ 1 /u03/app/oradata/ORA920/redo_g01a.log 262,144,000 1 /u04/app/oradata/ORA920/redo_g01b.log 262,144,000 1 /u05/app/oradata/ORA920/redo_g01c.log 262,144,000 2 /u03/app/oradata/ORA920/redo_g02a.log 262,144,000 2 /u04/app/oradata/ORA920/redo_g02b.log 262,144,000 2 /u05/app/oradata/ORA920/redo_g02c.log 262,144,000 3 /u03/app/oradata/ORA920/redo_g03a.log 262,144,000 3 /u04/app/oradata/ORA920/redo_g03b.log 262,144,000 3 /u05/app/oradata/ORA920/redo_g03c.log 262,144,000

    9 rows selected.

    About the Author

    Jeffrey Hunter is an Oracle Certified Professional, Java Development Certified Professional, Author, a nd anOracle ACE . Jeff currently works as a Senior Database Adminis trator for The DBA Zone, Inc. located inPittsburgh, Pennsylvania. His work includes advance d performance tuning, Java and PL/SQL programming,developing high availability solutions, capacity pl anning, database security, and physical / logical d atabasedesign in a UNIX / Linux server environment. Jeff's other interests include mathematical encryption th eory,tutoring advanced mathematics, programming language processors (compilers and interpreters) in Java an dC, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. Datab aseAdministrator and Software Engineer for over 20 yea rs and maintains his own website site at:

    DBA Tips Archive for Oracle hp://www.idevelopment.info/data/Oracle/DBA_ps/Database_Admini...

    3 of 4 1/26/2015 3:17 PM

  • http://www.iDevelopment.info . Jeff graduated from Stanislaus State University i n Turlock, California, with aBachelor's degree in Computer Science and Mathemati cs.

    Copyright (c) 1998-2015 Jeffrey M. Hunter. All righ ts reserved.

    All articles, scripts and material located at the I nternet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter andis protected under copyright laws of the United Sta tes. This document may not be hosted on any other s ite without my express, prior,

    written permission. Application to host any of the material elsewhere can be made by contacting me at [email protected] .

    I have made every effort and taken great care in ma king sure that the material included on my web site is technically accurate, but Idisclaim any and all responsibility for any loss, d amage or destruction of data or any other property which may arise from relying on it. I

    will in no case be liable for any monetary damages arising from such loss, damage or destruction.

    Last modified onWednesday, 28-Dec-2011 13:57:14 EST

    Page Count: 175978

    DBA Tips Archive for Oracle hp://www.idevelopment.info/data/Oracle/DBA_ps/Database_Admini...

    4 of 4 1/26/2015 3:17 PM

  • Example of How To Resize the Online Redo Logfiles (Doc ID 1035935.6)

    APPLIES TO:

    Oracle Database - Enterprise Edition - Version 8.1.7.4 to 11.2.0.3 [Release 8.1.7 to 11.2]Oracle Database - Enterprise Edition - Version 11.2.0.4 to 11.2.0.4 [Release 11.2]Information in this document applies to any platform.

    PURPOSE

    DETAILS

    EXAMPLE OF HOW TO RESIZE THE ONLINE REDO LOGS:==============================================

    Often times the online redo logs are sized too smal l causing databaseperformance problems.

    The following is an example of how to resize the on line log groups:

    NOTE: Examples are given for 9i and higher. In p rior releases, you neededto use Server Manager and connect as the internal u ser.

    1. First see the size of the current logs: > sqlplus /nolog SQL> connect / as sysdba

    SQL> select group#, bytes, status from v$log; GROUP# BYTES STATUS ---------- ---------- ---------------- 1 1048576 INACTIVE 2 1048576 CURRENT 3 1048576 INACTIVE Logs are 1MB from above, let's size them to 10M B.

    2. Retrieve all the log member names for the groups : SQL> select group#, member from v$logfile; GROUP# MEMBER --------------- -------------------------------- -------- 1 /usr/oracle/dbs/log1PROD.dbf 2 /usr/oracle/dbs/log2PROD.dbf 3 /usr/oracle/dbs/log3PROD.dbf 3. In older versions of the database you needed to shutdown and issue the following commands in restricted mode. You can still do this, but the database can be online to perform these changes.

    Let's create 3 new log groups and name them grou ps 4, 5, and 6, each 10MB in size: SQL> alter database add logfile group 4 '/usr/oracle/dbs/log4PROD.dbf' size 10M; SQL> alter database add logfile group 5 '/usr/oracle/dbs/log5PROD.dbf' size 10M; SQL> alter database add logfile group 6 '/usr/oracle/dbs/log6PROD.dbf' size 10M;

    4. Now run a query to view the v$log status: SQL> select group#, status from v$log;

    GROUP# STATUS --------- ----------------

    Document 1035935.6 hps://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-st...

    1 of 3 1/26/2015 3:19 PM

  • 1 INACTIVE 2 CURRENT 3 INACTIVE 4 UNUSED 5 UNUSED 6 UNUSED From the above we can see log group 2 is current , and this is one of the smaller groups we must drop. Therefore let's swi tch out of this group into one of the newly created log groups.

    5. Switch until we are into log group 4, so we can drop log groups 1, 2, and 3: SQL> alter system switch logfile; ** repeat as necessary until group 4 is CURRENT ** 6. Run the query again to verify the current log gr oup is group 4: SQL> select group#, status from v$log; GROUP# STATUS --------- ---------------- 1 INACTIVE 2 INACTIVE 3 INACTIVE 4 CURRENT 5 UNUSED 6 UNUSED

    Note: redo log Group 1 or 2 or 3 can be active aft er "alter system switch log file" which means could not be dropped, in this casyou need to do "alter system checkpoint" to make re do log groups 1,2 and 3 inactive. 7. Now drop redo log groups 1, 2, and 3:

    SQL> alter database drop logfile group 1; SQL> alter database drop logfile group 2; SQL> alter database drop logfile group 3; Verify the groups were dropped, and the new grou ps' sizes are correct.

    SVRMGR> select group#, bytes, status from v$log;

    GROUP# BYTES STATUS --------- --------- ---------------- 4 10485760 CURRENT 5 10485760 UNUSED 6 10485760 UNUSED

    8. At this point, you consider taking a backup of the database.

    9. You can now go out to the operating system and delete the files associated with redo log groups 1, 2, and 3 in step 2 abov e as they are no longer needed: % rm /usr/oracle/dbs/log1PROD.dbf % rm /usr/oracle/dbs/log2PROD.dbf % rm /usr/oracle/dbs/log3PROD.dbf Monitor the alert.log for the times of redo log switches. Due to increased redo log size, the groups should not switch as f requently under the same load conditions.

    References:===========

    Chapter 6 of the Oracle8i Administrator's Guide, Re lease 8.1.5,Part No. A67772-01 for further information on redo log maintenance.

    Chapter 7 of the Oracle 9i Administrator's guidePart No. A96521-01 for further information on redo log maintenance.

    Chapter 6 of the Oracle 10g Administrator's guide

    Document 1035935.6 hps://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-st...

    2 of 3 1/26/2015 3:19 PM

  • Part No. B10739-01 for further information on redo log maintenance.

    Chapter 10 of the Oracle 11g Administrator's guidePart No. B28310-04 for further information on redo log maintenance.

    Document 1035935.6 hps://support.oracle.com/epmos/faces/DocumentDisplay?_adf.ctrl-st...

    3 of 3 1/26/2015 3:19 PM