Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Database cache fusion analysis

2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article focuses on "database cache fusion analysis", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "Database Cache Fusion Analysis".

Concept

Simply put, cache convergence means that all database caches in the Oracle RAC database are taken as a shared database cache and shared by all nodes in the RAC. It is the basic technology to implement RAC.

Cache fusion mainly has the following four functions:

(1) provide scalable transmission.

(2) transfer the mapping of the database between instances.

(3) track the current location and status of resources.

(4) Save the resource information in the directory structure of the SGA of each instance.

The figure depicts the operation of the two-node RAC database. Each node runs a database instance, each containing a set of Oracle processes and a system-wide area (SGA) for caching. In addition to each node in these clusters, there is a special set of processes: global cache service process (Global Cache Service, GCS) and global queue service process (Global Enqueue Service,GES). GES is mainly responsible for maintaining consistency within dictionary cache and repository cache. GCS is mainly responsible for coordinating access to data blocks between different instances. They maintain and record the state of each data block through Global Resource Directory (GRD). Enables it to synchronize and serialize access to data between nodes in the cluster. At the same time, each data block belongs to a node, and for this data block, this node is called the Master. In order to balance the workload among servers, all servers in the cluster can become the master node of some data blocks, and GCS is the mechanism used by oracle to implement cache convergence.

How cache fusion works

We know that Oracle RAC is a cluster that uses shared disks to implement databases. In a cluster environment, all nodes share and update databases on disk concurrently, and additional synchronization and serial mechanisms are required with other nodes to prevent two or more nodes from updating records on the same data page at the same time. So how does Oracle RAC use cache fusion to handle data synchronization? In the following, the synchronization principle of cache is simulated and analyzed in several cases.

(1) Node A reads a new data block, which is not read by any node.

The request from ① node An is sent to GCS,GCS to forward the request to the master node of the data block, which is assumed to be node B. Because the block is not in any node's memory, GCS marks the block state as S (shared, shared state) and records it in GRD.

② then B tells node A that the state has changed and the preparations are complete. Node A then records the shared status in its own instance and reads the data block. At this point, node A holds the data block and records it in GRD, and the tag holds the data block. At this point, an IO operation takes place throughout the process.

(2) Node C wants to modify the data block read by node A just now. Here, it is assumed that the data block read by node A just now is SCN 100.

① node C finds the master node of the data block, that is, node B, and requires that it be marked with an X (exclusive, exclusive state) to indicate that the data is to be modified. But this data block may already exist in instances of multiple nodes, each with an S flag.

② GCS tells all instances that hold the block to convert the status S tag to an N flag (null, null state).

The last instance of ③ that converts from the S tag to the N tag sends the data block to the node that needs to be modified, such as node C.

④ at this time, the instance of node C can mark the data block with X, and inform the master node of the data block, that is, the GCS,GCS of node B, to record the latest tag and location to GRD, and close the resource record of the previous node. At this point, node C can modify the data block, assuming that the SCN is changed from 100to 101. at this time, the data block SCN on the disk is still 100. the whole process is to exchange data through internal interconnection, and no disk IO is generated.

(3) Node D also needs to modify the data block

① is similar to node C in modifying the data block. Node D also finds the master node of the data block, that is, node B, and requires an X (exclusive) lock to indicate that the data block is to be modified.

② at this point GCS will tell the last modified node C to discard its X tag because other nodes also need to modify the data block.

③ node C ensures that the data block has been changed, has been recorded in the online log, then converts X to N tag, and copies the block to node D.

④ node D is marked with X, and informs the master node of the data block, that is, the GCS,GCS of node B, to expose the latest tag and location to GRD, and close the resource records on the previous node. At this point, node D can modify the data block, assuming that the SCN of the data block is changed from 101 to 102, but the SCN on the data block of the disk is still 100. It can be found that RAC does not have any disk operations in this process, and it is also done through internal interconnection.

(4) Node A needs to re-read the data block.

① node An is still the same, first find the master node of the data block, that is, node B, and hope to read the latest data block, that is, the content with a SCN of 102.

② GCS learns from GRD that the latest data block is on node D, so GCS notifies node D. Node D needs to ensure that the data block that has just been modified has been recorded in the online log, and if it has been confirmed that it has been recorded, convert the original X tag to the S tag.

③ Node D copies the data block to the instance of Node A, where Node A gets the data block and gets the S tag.

④ finally tells the master node of the data block, that is, node BMageGCS, to record the latest mark and location to GRD. At this time, node An and node D simultaneously hold the same data block marked by S, and the SCN of the data block is 102.However, the SCN of the data block in the disk is still 100. finally, if a write operation occurs, as long as a write operation occurs on the latest node. Therefore, although the data block has changed many times in different nodes and different instances, there is only one write IO operation in the end.

At this point, I believe that you have a deeper understanding of the "database cache fusion analysis", might as well come to the actual operation of it! Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report