Log Writer Process 는 redo log buffer disk 에 write 하는 일을 가진다.
redo log buffer 는 원형 buffer 이다.
LGWR은 redo log buffer의 내용을 redo log file로 내려 쓰는 기능을 한다
DBWR은 데이터를 디스크에 저장하는 역할을 하지만, 데이터베이스에 COMMIT이 발생할 때마다 저장되는 것이 아니기 때문에 데이터를 손실할 수도 있다. DBWR과 달리 LGWR은 COMMIT이 발생하면, LGWR이 redo log file에 기록하기 때문에 손실을 최소화 할 수 있다.
다시 말해서, 사용자가 임의의 트랜젝션(transaction)에 대하여 커밋(commit)을 수행하고 나면 LGWR가 그 시점에서의 리두 로그 버퍼에 저장되어 있는 모든 리두 로그 기록들을 리두 로그 파일로 내려쓰게 된다.
LGWR은 다음과 같은 경우에 redo log file에 기록한다
• COMMIT 발생시 • redo log buffer가 1/3 이상 찼을 때 • redo log buffer에 쓰여진 양이 1MB가 되었을 때 • Checkpoint 발생하여 DBWR가 쓰기 작업을 하기전에 • 이전에 기록된 시점에서 3초가 지났을 때http://radiocom.kunsan.ac.kr/lecture/oracle/what_is/LGWR.html
What Is the Redo Log?
The most crucial structure for recovery operations is the redo log, which consists of two or more preallocated files that store all changes made to the database as they occur. Every instance of an Oracle Database has an associated redo log to protect the database in case of an instance failure.
Redo Threads
When speaking in the context of multiple database instances, the redo log for each database instance is also referred to as a redo thread. In typical configurations, only one database instance accesses an Oracle Database, so only one thread is present. In an Oracle Real Application Clusters environment, however, two or more instances concurrently access a single database and each instance has its own thread of redo. A separate redo thread for each instance avoids contention for a single set of redo log files, thereby eliminating a potential performance bottleneck.
This chapter describes how to configure and manage the redo log on a standard single-instance Oracle Database. The thread number can be assumed to be 1 in all discussions and examples of statements. For information about redo log groups in an Oracle Real Application Clusters environment, please refer to Oracle Real Application Clusters Administration and Deployment Guide.
Redo Log Contents
Redo log files are filled with redo records. A redo record, also called a redo entry, is made up of a group of change vectors, each of which is a description of a change made to a single block in the database. For example, if you change a salary value in an employee table, you generate a redo record containing change vectors that describe changes to the data segment block for the table, the undo segment data block, and the transaction table of the undo segments.
Redo entries record data that you can use to reconstruct all changes made to the database, including the undo segments. Therefore, the redo log also protects rollback data. When you recover the database using redo data, the database reads the change vectors in the redo records and applies the changes to the relevant blocks.
Redo records are buffered in a circular fashion in the redo log buffer of the SGA (see "How Oracle Database Writes to the Redo Log") and are written to one of the redo log files by the Log Writer (LGWR) database background process. Whenever a transaction is committed, LGWR writes the transaction redo records from the redo log buffer of the SGA to a redo log file, and assigns a system change number (SCN) to identify the redo records for each committed transaction. Only when all redo records associated with a given transaction are safely on disk in the online logs is the user process notified that the transaction has been committed.
Redo records can also be written to a redo log file before the corresponding transaction is committed. If the redo log buffer fills, or another transaction commits, LGWR flushes all of the redo log entries in the redo log buffer to a redo log file, even though some redo records may not be committed. If necessary, the database can roll back these changes.
How Oracle Database Writes to the Redo Log
The redo log of a database consists of two or more redo log files. The database requires a minimum of two files to guarantee that one is always available for writing while the other is being archived (if the database is in ARCHIVELOG
mode). See "Managing Archived Redo Logs" for more information.
LGWR writes to redo log files in a circular fashion. When the current redo log file fills, LGWR begins writing to the next available redo log file. When the last available redo log file is filled, LGWR returns to the first redo log file and writes to it, starting the cycle again. Figure 10-1 illustrates the circular writing of the redo log file. The numbers next to each line indicate the sequence in which LGWR writes to each redo log file.
Filled redo log files are available to LGWR for reuse depending on whether archiving is enabled.
-
If archiving is disabled (the database is in
NOARCHIVELOG
mode), a filled redo log file is available after the changes recorded in it have been written to the datafiles. -
If archiving is enabled (the database is in
ARCHIVELOG
mode), a filled redo log file is available to LGWR after the changes recorded in it have been written to the datafiles and the file has been archived.
Figure 10-1 Reuse of Redo Log Files by LGWR
Description of "Figure 10-1 Reuse of Redo Log Files by LGWR"
Active (Current) and Inactive Redo Log Files
Oracle Database uses only one redo log files at a time to store redo records written from the redo log buffer. The redo log file that LGWR is actively writing to is called the current redo log file.
Redo log files that are required for instance recovery are called active redo log files. Redo log files that are no longer required for instance recovery are called inactive redo log files.
If you have enabled archiving (the database is in ARCHIVELOG
mode), then the database cannot reuse or overwrite an active online log file until one of the archiver background processes (ARCn) has archived its contents. If archiving is disabled (the database is in NOARCHIVELOG
mode), then when the last redo log file is full, LGWR continues by overwriting the first available active file.
Log Switches and Log Sequence Numbers
A log switch is the point at which the database stops writing to one redo log file and begins writing to another. Normally, a log switch occurs when the current redo log file is completely filled and writing must continue to the next redo log file. However, you can configure log switches to occur at regular intervals, regardless of whether the current redo log file is completely filled. You can also force log switches manually.
Oracle Database assigns each redo log file a new log sequence number every time a log switch occurs and LGWR begins writing to it. When the database archives redo log files, the archived log retains its log sequence number. A redo log file that is cycled back for use is given the next available log sequence number.
Each online or archived redo log file is uniquely identified by its log sequence number. During crash, instance, or media recovery, the database properly applies redo log files in ascending order by using the log sequence number of the necessary archived and redo log files.
http://download.oracle.com/docs/cd/B28359_01/server.111/b28310/onlineredo001.htm#ADMIN11305
댓글 없음:
댓글 쓰기