Presentation is loading. Please wait.

Presentation is loading. Please wait.

7 Maintaining Redo Log Files. 7-2 Objectives Explaining the use of online redo log files Obtaining log and archive information Controlling log switches.

Similar presentations


Presentation on theme: "7 Maintaining Redo Log Files. 7-2 Objectives Explaining the use of online redo log files Obtaining log and archive information Controlling log switches."— Presentation transcript:

1 7 Maintaining Redo Log Files

2 7-2 Objectives Explaining the use of online redo log files Obtaining log and archive information Controlling log switches and checkpoints Multiplexing and maintaining online redo log files Planning online redo log files Troubleshooting common redo log file problems Explaining the use of online redo log files Obtaining log and archive information Controlling log switches and checkpoints Multiplexing and maintaining online redo log files Planning online redo log files Troubleshooting common redo log file problems

3 7-3 Using Redo Log Files Redo log files Database Control files Data files Record all Record all changes made to the database Used only for Used only forrecovery

4 7-4 Introduction to Online Redo Log Files Components: Redo log group Online redo log file or member Archived redo log file ARCn

5 7-5 Introduction to Online Redo Log Files Components: Redo log buffer LGWR CKPT

6 7-6 Introduction to Online Redo Log Files File 1 is written to File A by the ARCn process after the log switch is complete

7 7-7 Introduction to Online Redo Log Files File 1 and File 3 are written to by the LGWR process simultaneously until both are full

8 7-8 Redo Log Groups and Members Group 2 Group 3 Group 1 Member Member Disk 1 Disk 2 Member Member Member Member Min. 2 groups Min. 1 and up to 5 members/group

9 7-9 Redo Log Groups and Members LGWR concurrently writes to all members of a group Log Sequence numbers are written to the group Log Sequence number is assigned to a group by Oracle each time: unique id Current log number is stored in control file LGWR concurrently writes to all members of a group Log Sequence numbers are written to the group Log Sequence number is assigned to a group by Oracle each time: unique id Current log number is stored in control file

10 7-10 Oracle Architecture Database Instance SGA CKPT LGWR DBWR Database buffer cache Control files Data files Redo log files Redo log buffer ARCH Parameter file Password file Archived log files

11 7-11 LGWR, Log Switches and Checkpoints LGWR writes from buffer to file when: A transaction commits Redo buffer is one-third full >1MB of changed records Timeout occurs (every 3 secs) Before DBWR writes buffer to data files LGWR writes from buffer to file when: A transaction commits Redo buffer is one-third full >1MB of changed records Timeout occurs (every 3 secs) Before DBWR writes buffer to data files

12 7-12 LGWR, Log Switches and Checkpoints Log switch: event when LGWR switches to a new group; Oracle then assigns a new sequence number DBA can force a switch Checkpoint: Dirty DB buffers written to data files Updates headers of data and control files Occurs when Every log switch Instance shuts down Manually by DBA Log switch: event when LGWR switches to a new group; Oracle then assigns a new sequence number DBA can force a switch Checkpoint: Dirty DB buffers written to data files Updates headers of data and control files Occurs when Every log switch Instance shuts down Manually by DBA

13 7-13 Without Archiving Backup Disk failure 100 101 t1 t2 Data files Control files 5051

14 7-14 50 With Archiving Backup Disk failure Data files Control files 5051 100 101 Archived redo logs t1t2 99

15 7-15 To Archive Or Not? Oracle can be configured to operate in: ARCHIVELOG or NOARCHIVELOG mode Two ways to archive redo log files: Manually or Automatically LOG_ARCHIVE_START parameter indicates if manual or automatic Oracle can be configured to operate in: ARCHIVELOG or NOARCHIVELOG mode Two ways to archive redo log files: Manually or Automatically LOG_ARCHIVE_START parameter indicates if manual or automatic

16 7-16 Server Manager command: V$DATABASE: – NAME (select name, log_mode from v$databse) – LOG_MODE V$INSTANCE – ARCHIVER (select archiver from v$instance) Server Manager command: V$DATABASE: – NAME (select name, log_mode from v$databse) – LOG_MODE V$INSTANCE – ARCHIVER (select archiver from v$instance) Obtaining Information About Archiving SQL>ARCHIVE LOG LIST;

17 7-17 Obtaining Information About Groups V$THREAD: GROUPS CURRENT_GROUP# SEQUENCE# select groups, current_group#, sequence# from v$thread; V$THREAD: GROUPS CURRENT_GROUP# SEQUENCE# select groups, current_group#, sequence# from v$thread;

18 7-18 Obtaining Information About Groups and Members V$LOG: GROUP# MEMBERS STATUS SEQUENCE# BYTES select group#, sequence#, bytes, members, status from v$log;

19 7-19 Obtaining Information About Groups and Members V$LOGFILE: GROUP# STATUS MEMBER select * from v$logfile; STATUS for groups(G) and members (M): UNUSED(G): never been written to CURRENT(G): current group ACTIVE(G): active but not current; needed for recovery INACTIVE(G): no longer needed for recovery INVALID(M): file is inaccessible BLANK(M): file is in use

20 7-20 Force log switches with the command: Control checkpoints with the initialization parameters: – LOG_CHECKPOINT_INTERVAL – LOG_CHECKPOINT_TIMEOUT SQL> ALTER SYSTEM CHECKPOINT Force log switches with the command: Control checkpoints with the initialization parameters: – LOG_CHECKPOINT_INTERVAL – LOG_CHECKPOINT_TIMEOUT SQL> ALTER SYSTEM CHECKPOINT Log Switches and Checkpoints SQL> ALTER SYSTEM SWITCH LOGFILE;

21 7-21 log3a.rdo Adding Online Redo Log Groups Group 1 Group 2 Group 3 ALTER DATABASE ADD LOGFILE (‘/DISK3/log3a.rdo’, ‘/DISK4/log3b.rdo’) size 1M; ALTER DATABASE ADD LOGFILE (‘/DISK3/log3a.rdo’, ‘/DISK4/log3b.rdo’) size 1M; log3b.rdo log1a.rdo log1b.rdo log2b.rdo

22 7-22 Adding Online Redo Log Members Group 2 Group 1 ALTER DATABASE ADD LOGFILE MEMBER ‘/DISK4/log1b.rdo’ TO GROUP 1, ‘/DISK4/log2b.rdo’ TO GROUP 2; ALTER DATABASE ADD LOGFILE MEMBER ‘/DISK4/log1b.rdo’ TO GROUP 1, ‘/DISK4/log2b.rdo’ TO GROUP 2; log2b.rdo log2a.rdo log1b.rdo log1a.rdo

23 7-23 How to Relocate Online Redo Log Files 1. Shut down the database. 2. Copy the online redo log files to the new location. 3. Mount the database. 4. Execute the ALTER DATABASE RENAME FILE command. ALTER DATBASE RENAME FILE ‘fname’ TO ‘fname’ 5. Open the database. 1. Shut down the database. 2. Copy the online redo log files to the new location. 3. Mount the database. 4. Execute the ALTER DATABASE RENAME FILE command. ALTER DATBASE RENAME FILE ‘fname’ TO ‘fname’ 5. Open the database.

24 7-24 Dropping Online Redo Log Groups Group 1 Group 2 Group 3 ALTER DATABASE DROP LOGFILE GROUP 3; ALTER DATABASE DROP LOGFILE GROUP 3; log1a.rdo log2a.rdo log3b.rdo log3a.rdo log1b.rdo log2b.rdo

25 7-25 Dropping Online Redo Log Members Group 2 Group 1 ALTER DATABASE DROP LOGFILE MEMBER ‘/DISK4/log2b.dbf’; ALTER DATABASE DROP LOGFILE MEMBER ‘/DISK4/log2b.dbf’; log1a.rdo log2b.rdo log1b.rdo log2a.rdo

26 7-26 Clearing Online Redo Log Files ALTER DATABASE CLEAR LOGFILE ‘/DISK3/log2a.rdo’; ALTER DATABASE CLEAR LOGFILE ‘/DISK3/log2a.rdo’; If it gets corrupted. Example

27 7-27 Online Redo Log Configuration Group 1 Group 2 Group 3 Member Member Disk 3 Disk 2 Disk 1 Member Member Member

28 7-28 Possible LGWR Errors One member of a group of two or more is not available. All members of the next group are not available. All members of the current group are not available. One member of a group of two or more is not available. All members of the next group are not available. All members of the current group are not available.

29 7-29 OMF and Log Files You can create as many redo log groups as you need, bounded by MAXLOGFILES setting (when database was created). You can multiplex each of those groups with up to five additional OMF members (bounded by the MAXLOGMEMBERS). D Different redo log group members are created in different locations, as defined by parameters such as db_create_online_log_dest_n You can create as many redo log groups as you need, bounded by MAXLOGFILES setting (when database was created). You can multiplex each of those groups with up to five additional OMF members (bounded by the MAXLOGMEMBERS). D Different redo log group members are created in different locations, as defined by parameters such as db_create_online_log_dest_n

30 7-30 OMF and Log Files (cont.) Examples ALTER DATABASE ADD LOGFILE; or ALTER DATABASE ADD LOGFILE GROUP 3 SIZE 300M; - to add a log group ALTER DATABASE DROP LOGFILE GROUP 1; - to drop a log group (may not be current log group) Not possible to add an additional log group member that is an OMF Can drop an OMF redo log member:ALTER DATABASE DROP LOGFILE MEMBER.... Oracle will remove the dropped redo log member. Examples ALTER DATABASE ADD LOGFILE; or ALTER DATABASE ADD LOGFILE GROUP 3 SIZE 300M; - to add a log group ALTER DATABASE DROP LOGFILE GROUP 1; - to drop a log group (may not be current log group) Not possible to add an additional log group member that is an OMF Can drop an OMF redo log member:ALTER DATABASE DROP LOGFILE MEMBER.... Oracle will remove the dropped redo log member.

31 7-31 OMF and Log Files (cont.) Example Create Database Command: CREATE DATABASE mydb DATAFILE SIZE 500M LOGFILE GROUP 1 SIZE 10M, GROUP 2 SIZE 10M DEFAULT TEMPORARY TABLESPACE temp TEMPFILE SIZE 100M UNDO TABLESPACE undotbs1 DATAFILE SIZE 50M MAXLOGFILES = 5 MAXLOGMEMBERS = 5 MAXDATAFILES = 600 NOARCHIVELOG; Example Create Database Command: CREATE DATABASE mydb DATAFILE SIZE 500M LOGFILE GROUP 1 SIZE 10M, GROUP 2 SIZE 10M DEFAULT TEMPORARY TABLESPACE temp TEMPFILE SIZE 100M UNDO TABLESPACE undotbs1 DATAFILE SIZE 50M MAXLOGFILES = 5 MAXLOGMEMBERS = 5 MAXDATAFILES = 600 NOARCHIVELOG;

32 7-32 Summary Controlling log switches and checkpoints Administering online redo log files Controlling log switches and checkpoints Administering online redo log files


Download ppt "7 Maintaining Redo Log Files. 7-2 Objectives Explaining the use of online redo log files Obtaining log and archive information Controlling log switches."

Similar presentations


Ads by Google