Redo mechanism--the first layer of data security

Source: Internet
Author: User

It is only the individual understanding of the redo operating mechanism, the wrong place, hope Cheese point out, learn together. If you want to make your understanding of redo more clear, then you can choose to continue to watch.

The fundamental meaning of the existence of redo:

It is known that the database modification data is modified in the buffer cache, but after commit, the data file is not immediately written (No-force -at-commit strategy), because such fragmented writes are very resource-intensive, and Io is always the most likely performance bottleneck, but in order to ensure that the submitted data can be The redo mechanism is created by recording the modification of the database into the redo log buffer and writing it out to the redo file to delay the writing of the data, up to to the effect of batch processing, improve the efficiency. So redo is extremely important for the database.

The composition of the redo mechanism:

Redo mechanism, contains three components: Redo log BUFFER,LGWR background process, redo log file log files (if archive mode also has arch background process and archive

log files);

So it was created  redo log  buffer (an area of memory allocated by Oracle, which exists in the SGA, is recycled), but the memory area is recycled, which requires a at the same time  redo log file same as Redo log buffer is also recycled, how to ensure the security of the data?   So every time I log switch, I go. Check enumeration, prompting the DBWR process to be full of redo log  FILE-protected dirty data is written out into the data file so that,redo log file  becomes  inactive  after the checkpoint is complete and can be emptied and reused.

Redo mechanism Detailed:

Redo Log Buffer:

Redo Entries (Redo entry): Contains the refactoring, redo database change information, which includes Update,insert,delete,drop,alert, Create, etc.;

A redo entry is generated in the user Global Zone (PGA) and then copied by the Oracle service process to the redo log buffer, under certain conditions by LGWR the process is written to the redo log file. Because redo log buffer is a shared memory area, in a highly concurrent system, redo log buffer contention may occur, resulting in the latch mechanism, which is created by the Redo_allocation_ Latch protection, the service process must first obtain the Redo_allocation_latch to allocate the corresponding log buffer;

The process of writing redo entries to redo log buffer is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/54/5A/wKiom1R_8x_zYvzAAACfVOnDmu8010.jpg "title=" 1.jpg " alt= "Wkiom1r_8x_zyvzaaacfvondmu8010.jpg"/>

1>redo Parallel Mechanism:

In highly concurrent environments, there is bound to be redo_allocation_latch contention (redo log buffer has only one redo_allocation_latch), in order to reduce redo_allocation_latch Wait, in oracle9.2, introduced the parallel mechanism of log buffer.  

2>share Strand:

The log buffer is divided into smaller buffer, these small buffer called strand, also known as Shared strand, each strand has a redo_alloction_latch protection, the allocation of the previously sequential redo buffer becomes a parallel process that now occurs after multiple strand, greatly improving the efficiency.  

3>priate Strand:

to further improve the contention for reducing redo buffer, oracle10g introduces a new mechanism---priate strand,priate strand is not produced in the PGA, andis a chunk of shared memory allocated in the share pool, each priate Starand protected by a single redo_allocation_latch, and each priate strand serves only oneactive transaction, get to Priate strand transaction, will not generate redo in the PGA, but in Priate Strand, when flash priate strand or commit, the priate strand will be batched into the redo log file, and if the transaction does not get Priate strand, it will continue to follow the old log buffer mechanism, i.e.shared Strand, so when the alarm log appears private strand flush not complete can choose to ignore regardless.

As mentioned above, Priate Strand will write directly to the redo log file at Flush/commit without passing the redo log buffer, which reduces the share strand of the Redo_allocation_latch application, improve the efficiency;

The process of priate strand is as follows:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/54/58/wKioL1R_87zxOFtkAADbWcTL0qw853.jpg "title=" 2.jpg " alt= "Wkiol1r_87zxoftkaadbwctl0qw853.jpg"/>

Note: Before the end of a successful transaction that does not get priate strand, even if there are other things that end up releasing latch, the thing will not apply priate strand. Redo_allocation_ Latch

LGWR Background process:

Redo log buffer is a shared loop of memory area, LGWR is responsible for the timely release of its dirty logs quickly, providing new logs for the next use. It is sequential write to the log file, and not as DBWR as random write, so much faster;

Trigger conditions for LGWR:

  • When the Commit/rollback statement is manipulated

  • LGWR is triggered when the total log information reaches 1/3 of the log buffer, or when the number of log messages reaches 1M, both of which are triggered by a hidden

  • Parameter _log_io_size, so if LGWR trigger frequent cases, you can choose to set this parameter to 3 m, so that 1/3 and 1M is a trigger condition.

  • One trigger per 3 seconds

  • When the DBWR is triggered, the data is written before it is determined that the part of the data is logged to the log file, and if not, a block that needs to be written to the log is placed in a

  • Queue, trigger Lgwr to write, DBWR will continue to write data to the data file after completion.

Redo log File:

Related views:

SELECT * from V$log;

SELECT * from V$logfile;

SELECT * from V$archived_log;

SELECT * from V$recover_file;

SELECT * from V$log_history;

SELECT * from V$loghist;

Redo log File Status:

  • UNUSED: The file that corresponds to the online redo log file group has never been written to data, and the online redo log filegroup that you just created is displayed in this state. When a log is switched to this group, it changes state

  • Current: Represents the group of log files that are currently in use. The online Redo log group is active. The online redo log file group that is currently in use by the Oracle database.

  • Active: Indicates that the group is active but not the current group, and this set of logs is required for instance recovery. If in this state, indicates that the current log group is being archived, if the logs are switched on full standby is active state, the alarm log will generate checkpoint not complete information, and accompanied by cannot allocate new log error message , the response to the wait event is log file sync;

  • INACTIVE: Indicates that the set of online redo log groups is no longer required for instance recovery. Indicates that the contents of the corresponding online redo log file have been properly processed and that the group online redo log is currently in an idle state

  • Clearing: Indicates that the group redo log file is being rebuilt (the state becomes unused after the rebuild).

  • Clearing_current: Indicates an error occurred during the group redo log rebuild.

This article is from the "TOP" blog, so be sure to keep this source http://dbguy.blog.51cto.com/8921728/1586232

Redo mechanism--the first layer of data security

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.