7 Maintaining Redo Log Files. 7-2 Objectives Explaining the use of online redo log files Obtaining...
-
Upload
julius-hill -
Category
Documents
-
view
231 -
download
5
Transcript of 7 Maintaining Redo Log Files. 7-2 Objectives Explaining the use of online redo log files Obtaining...
77
Maintaining Redo Log FilesMaintaining Redo Log Files
7-7-22
ObjectivesObjectives
• 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
7-7-33
Using Redo Log FilesUsing Redo Log Files
Redo logfiles
Database
Controlfiles
Data files
• Record allRecord all
changes madechanges made
to the databaseto the database
• Used only forUsed only for
recoveryrecovery
7-7-44
Introduction to Online Redo Log Files
Introduction to Online Redo Log Files
Components:•Redo log group•Online redo log file or member•Archived redo log file•ARCn
7-7-55
Introduction to Online Redo Log Files
Introduction to Online Redo Log Files
Components:•Redo log buffer•LGWR•CKPT
7-7-66
Introduction to Online Redo Log Files
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-77
Introduction to Online Redo Log Files
Introduction to Online Redo Log Files
File 1 and File 3 are written to by the LGWR process simultaneouslyuntil both are full
7-7-88
Redo Log Groups and MembersRedo Log Groups and Members
Group 2Group 2 Group 3Group 3Group 1Group 1
MemberMember
MemberMember
Disk 1Disk 1
Disk 2Disk 2MemberMember
MemberMember MemberMember
MemberMember
Min. 2 groupsMin. 2 groups
Min. 1 and up to 5 members/groupMin. 1 and up to 5 members/group
7-7-99
Redo Log Groups and Members 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
7-7-1010
Oracle Architecture Oracle Architecture
Database
InstanceSGA
CKPT LGWR DBWR
Database buffercache
Control files
Data files Redo logfiles
Redo logbuffer
ARCH
Parameterfile
Password file
Archived log files
7-7-1111
LGWR, Log Switches and Checkpoints 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
7-7-1212
LGWR, Log Switches and Checkpoints 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
7-7-1313
Without Archiving Without Archiving
BackupBackup Disk failureDisk failure
100 101
t1t1 t2t2
Data files Control files
50 51
7-7-1414
50
With ArchivingWith Archiving
BackupBackup
Disk failureDisk failureData files Control
files
50 51100 101
ArchivedArchivedredo logsredo logs
t1t1 t2t2
99
7-7-1515
To Archive Or Not? 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
7-7-1616
• 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
Obtaining Information About Archiving
SQL>ARCHIVE LOG LIST;SQL>ARCHIVE LOG LIST;
7-7-1717
Obtaining Information About Groups
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;
7-7-1818
Obtaining Information About Groups and Members
Obtaining Information About Groups and Members
V$LOG:
• GROUP#
• MEMBERS
• STATUS
• SEQUENCE#
• BYTESselect group#, sequence#, bytes, members, status
from v$log;
7-7-1919
Obtaining Information About Groups and Members
Obtaining Information About Groups and Members
V$LOGFILE:
• GROUP#
• STATUS
• MEMBERselect * 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
7-7-2020
• Force log switches with the command:
• Control checkpoints with the initialization parameters:
– LOG_CHECKPOINT_INTERVAL
– LOG_CHECKPOINT_TIMEOUTSQL> ALTER SYSTEM CHECKPOINT
• Force log switches with the command:
• Control checkpoints with the initialization parameters:
– LOG_CHECKPOINT_INTERVAL
– LOG_CHECKPOINT_TIMEOUTSQL> ALTER SYSTEM CHECKPOINT
Log Switches and CheckpointsLog Switches and Checkpoints
SQL> ALTER SYSTEM SWITCH LOGFILE;SQL> ALTER SYSTEM SWITCH LOGFILE;
7-7-2121
log3a.rdo
Adding Online Redo Log GroupsAdding Online Redo Log Groups
Group 1Group 1 Group 2Group 2 Group 3Group 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.rdolog1a.rdo
log1b.rdo log2b.rdo
7-7-2222
Adding Online Redo Log Members
Adding Online Redo Log Members
Group 2Group 2Group 1Group 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.rdolog2a.rdolog1b.rdolog1a.rdo
7-7-2323
How to RelocateOnline Redo Log Files
How to RelocateOnline 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.
7-7-2424
Dropping Online Redo Log Groups
Dropping Online Redo Log Groups
Group 1Group 1 Group 2Group 2 Group 3Group 3
ALTER DATABASE DROP LOGFILE
GROUP 3;
ALTER DATABASE DROP LOGFILE
GROUP 3;
log1a.rdo log2a.rdolog3b.rdo
log3a.rdo
log1b.rdo log2b.rdo
7-7-2525
Dropping Online Redo Log Members
Dropping Online Redo Log Members
Group 2Group 2Group 1Group 1
ALTER DATABASE DROP LOGFILE MEMBER
‘/DISK4/log2b.dbf’;
ALTER DATABASE DROP LOGFILE MEMBER
‘/DISK4/log2b.dbf’;
log1a.rdo
log2b.rdolog1b.rdo log2a.rdo
7-7-2626
Clearing Online Redo Log FilesClearing Online Redo Log Files
ALTER DATABASE CLEAR LOGFILE
‘/DISK3/log2a.rdo’;
ALTER DATABASE CLEAR LOGFILE
‘/DISK3/log2a.rdo’;
If it gets corrupted. If it gets corrupted.
ExampleExample
7-7-2727
Online Redo Log ConfigurationOnline Redo Log Configuration
Group 1Group 1 Group 2Group 2 Group 3Group 3
MemberMember
MemberMember
Disk 3Disk 3Disk 2Disk 2Disk 1Disk 1
MemberMember
MemberMember
MemberMember
7-7-2828
Possible LGWR ErrorsPossible 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.
7-7-2929
OMF and Log FilesOMF 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
7-7-3030
OMF and Log Files (cont.)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.
7-7-3131
OMF and Log Files (cont.)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;
7-7-3232
SummarySummary
• Controlling log switches and checkpoints
• Administering online redo log files
• Controlling log switches and checkpoints
• Administering online redo log files