Resizing Recreating Online Redo Log Files

Embed Size (px)

DESCRIPTION

Resizing - Recreating 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 recreate online redo log files and keep the current sequence isto perform it online. In this example, we will resize all online redo logs from 100MB to 250MB while thedatabase 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 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 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

  • 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 CURRENT 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 are 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 instance ORA920 (thread 1)ORA-00312: online log 1 thread 1: ''

    Easy problem to resolve. Simply perform a checkpoint 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 createdshould 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, continue to re-create (or resize) all online redo log groupsuntil all of them are rebuilt.

    5.

    After rebuilding (resizing) all online redo log groups, 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, and anOracle ACE. Jeff currently works as a Senior Database Administrator for The DBA Zone, Inc. located inPittsburgh, Pennsylvania. His work includes advanced performance tuning, Java and PL/SQL programming,developing high availability solutions, capacity planning, database security, and physical / logical databasedesign in a UNIX / Linux server environment. Jeff's other interests include mathematical encryption theory,tutoring advanced mathematics, programming language processors (compilers and interpreters) in Java andC, LDAP, writing web-based database administration tools, and of course Linux. He has been a Sr. DatabaseAdministrator and Software Engineer for over 20 years 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 in Turlock, California, with aBachelor's degree in Computer Science and Mathematics.

    Copyright (c) 1998-2015 Jeffrey M. Hunter. All rights reserved.All articles, scripts and material located at the Internet address of http://www.idevelopment.info is the copyright of Jeffrey M. Hunter and

    is protected under copyright laws of the United States. This document may not be hosted on any other site 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 making sure that the material included on my web site is technically accurate, but Idisclaim any and all responsibility for any loss, damage 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