On the cache (turn) in the database system

Source: Internet
Author: User

The cache and buffer are two different concepts, simply put, the cache is accelerated "read", and buffer is buffered "write", the former solve the problem of reading, save the data read from the disk, the latter is to solve the write problem, save the data that will be written to disk. In many cases, these two nouns are not strictly differentiated, often the read-write mixed type is called buffer cache, the subsequent discussion in this article, the unification is called the cache.

The log buffer in Oracle solves the problem of Redo writes, while the data buffer cache resolves the read and write problems of data block. For Oracle, if IO is not hit in the SGA, physical io,oracle are not concerned with the type of underlying storage, possibly a set of storage systems, possibly a local disk, possibly raid 10, or RAID 5, possibly a file system, or a bare device, or ASM. In summary, Oracle calls the underlying storage system a storage subsystem.

In the storage system, the cache is almost ubiquitous (in the later discussion, we collectively refer to the cache), the file system has the cache, the cache is stored on the Cache,raid controller, and the cache is on the disk. To improve performance, one of Oracle's write operations is likely to be written back on the stored cache, and if there is a problem with the storage system, how can oracle ensure data consistency.

The most important feature of the Oracle database is the write ahead logging, before the data block is written, it must be guaranteed to write redo log first, and at the time of transaction commit, the redo log must be guaranteed to be written. To ensure data consistency, Oracle uses direct IOfor redo log, and direct IO skips the cache layer of the filesystem on the OS. However, the OS cannot store this layer, although it skips the cache of the file system, but it may still be written on the stored cache.

General storage has the cache, in order to improve performance, write operation on the cache to return to the OS, we call this write operation is write back, in order to ensure that the cache when the power is not lost, the storage is battery protection, these batteries can be stored in the power loss after a certain period of work, Ensure that the data in the cache is brushed into the disk and is not lost. Unlike UPS, the battery can be supported for a short time, typically within 30 minutes, as long as the data in the cache is guaranteed to be written. The store can shut down the write cache, when all writes must be written to the disk to return, we call this write Throuogh, and when the store finds some parts are unhealthy, the store automatically shuts down the write cache, when write performance degrades.

The RAID card also has the cache, usually 256M, is also protected by the battery, different from the storage, the battery does not guarantee that the data can be written to the disk, but to power the cache to protect the data is not lost, generally can support a few days of time. There are also some RAID cards have flash cache, after power-down can be written to the cache content in the Flash cache, to ensure that the data is not lost. If your database is not stored, but on the local hard disk of the normal PC, make sure that the RAID card in the host has a battery, and many hardware providers do not configure the battery by default. Of course, the cache on the raid card also has the option to close.

The cache on disk is generally 16m-64m, and many storage vendors have made it clear that the cache of the disks in the storage is disabled, which is understandable, in order to guarantee the reliability of the data, and the storage itself provides a very large cache, compared to the cache on disk is no longer so important. The SCSI directive has a FUA (Force Unit Access) parameter that, when set, writes must be completed on disk to be returned, which is equivalent to disabling the disk's write cache. Although the information is not verified, I personally believe that once the disk is plugged into the RAID controller, the write cache will be disabled, which is also for the sake of data reliability, I believe the storage vendor should consider this issue.

At this point, we can see that one of Oracle's physical IO has gone through a series of caches and is eventually written to disk. While the cache can improve performance, it also has to consider the issue of power-down protection. The consistency of the data is ensured by the Oracle database, the operating system, and the storage subsystem.

On the cache (turn) in the database system

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.