今天看书时看到了关于RAC中SCN的问题,为了进一步搞清楚其内部原理和机制,对该问题进行了广泛的查阅和搜索,遗憾的是,可以参考的资料很少,网上大部分是人云亦云的帖子,其中,详细介绍其内部原理和机制的资料更是几乎没有,现将一些有参考价值的资料片段在下面贴出,以供本人和同行参考。

1.Achieving Read Consistency
One of the main characteristics of the Oracle database is the ability to simultaneously provide different
views of data. This characteristic is called multi-version read consistency. Queries will be read
consistently; writers won’t block readers, and vice versa. Of course, multi-version read consistency also
holds true for RAC databases, but a little more work is involved.
The System Change Number is an Oracle internal timestamp that is crucial for read consistency. If
the local instance requires a read-consistent version of a block, it contacts the block’s resource master to
ascertain if a version of the block that has the same SCN, or if a more recent SCN exists in the buffer
cache of any remote instance. If such a block exists, then the resource master will send a request to the
relevant remote instance to forward a read-consistent version of the block to the local instance. If the
remote instance is holding a version of the block at the requested SCN, it sends the block immediately. If
the remote instance is holding a newer version of the block, it creates a copy of the block, called a past
image; applies undo to the copy to revert it to the correct SCN; and sends it over the interconnect.
2.Synchronizing System Change Numbers
System Change Numbers are internal time stamps generated and used by the Oracle database. All events
happening in the database are assigned SCNs, and so are transactions. The implementation Oracle uses
to allow read consistency relies heavily on SCNs and information in the undo tablespaces to produce
read-consistent information. System change numbers needs to be in sync across the cluster. Two
different schemes to keep SCNs current on all cluster nodes are used in Real Application Clusters: the
broadcast-on-commit scheme and the Lamport scheme.
The broadcast-on-commit scheme is the default scheme in 10g Release 2 and newer; it addresses a
known problem with the Lamport scheme. Historically, the Lamport scheme was the default scheme—it
promised better scalability as SCN propagation happened as part of other (not necessarily related)
cluster communication and not immediately after a commit is issued on a node. This was deemed
sufficient in most situations by Oracle, and documents available on My Oracle Support seem to confirm
this. However, there was a problem with the Lamport scheme: It was possible for SCNs of a node to lag
behind another node’s SCNs—especially if there was little messaging activity. The lagging of system
change numbers meant that committed transactions on a node were “seen” a little later by the instance
lagging behind.
On the other hand, the broadcast-on-commit scheme is a bit more resource intensive. The log
writer process LGWR updates the global SCN after every commit and broadcasts it to all other instances.
The deprecated max_commit_propagation_delay initialization parameter allowed the database
administrator to influence the default behavior in RAC 11.1; the parameter has been removed in Oracle
11.2.
3.Wait for master SCN
Each instance in the cluster will generate its own SCN and subsequently, using the propagation method,
will resynchronize to the highest SCN in the cluster.
This wait indicates the number of times the foreground processes waited for SCNs to be acknowledged from
other instances in the cluster.
Before Oracle database 10g Release 2, the method of SCN propagation was driven by the parameter
MAX_COMMIT_PROPAGATION_DELAY. Setting this to a value higher than zero uses the Lamport algorithm. Now this
parameter is deprecated and is maintained for backward compatibility only and defaults to zero. This functionality
is now driven by the underscore (hidden) parameter _IMMEDIATE_COMMIT_PROPAGATION and has a Boolean value of
TRUE or FALSE.
When the value of the parameter is set to TRUE (default) Oracle uses the “Block on Commit” (BOC) algorithm for
messaging. Although the method of propagation remains similar to the Lamport algorithm, in the case of BOC, the
global high water mark for the SCNs sent and received is maintained, thereby reducing messaging traffic for global
SCN synchronization and in turn improving overall performance.
4.
In earlier versions such as Oracle 9i, every commit System
Commit Numbers (Commit SCN) is broadcasted to all the nodes, and the log writer is held up
until all the pending redos are written to the disk. Starting with Oracle 10g, the wait is greatly
reduced because the broadcast and commit are asynchronous. This means the system waits until it
is sure that all nodes have seen the Commit SCN. Any message with an SCN greater than
Commit SCN is deemed sufficient.
Before doing a broadcast, the process checks whether it has already received a higher SCN
from that instance. It used the same SCN to determine whether a foreground or an LMS has to
be posted. With Oracle 10g, this is decoupled: an SCN is needed to release foregrounds and an
SCN is needed for shipping buffers. The init.ora parameter “_lgwr_async_broadcasts = true” can
be used to change the broadcast method.
5.
1)The number of outstanding broadcasts increased from 3 to 8.This improves throughput but does not affect latency.
2)LGWR can now issue direct and indirect sends.This frees up the local LMS processes and improves latency.
3)Processing is not limited to LMS0. The SCN is hashed to determine which LMS process will send the message (indirect send) or process the broadcast and send the ACK back to the broadcasting node.This improves general performance by reducing the load on the local (indirect sends) and remote LMS0 processes.
4)Broadcast and acknowledgement messages are no longer blocked by DRM events.This improves BOC latency by eliminating the up to 0.5-second delay introduced by Dynamic Remastering.
5)All Cache Fusion messages can now carry the broadcast SCN.This reduces the need for explicit broadcasts thereby reducing the number of messages on the private interconnect and possibly reducing latency.
观点:
1)很多资料中,谈到在所有节点中的同步是为了数据视图的一致性,其实,仔细想想,如果仅仅是为了各节点间数据的一致性,只需要在commit时将SCN同步给资源的master节点就可以了,没必要同步给所有节点。
2)接续以上问题,那么,commit时将SCN同步给所有节点的目的,更主要是为了在整个cluster内保持SCN的最高水位线,以便cluster中的任意节点可以随时获取到SCN的最高值,避免了过多的信息通信和性能延迟问题。
 

关于Oracle RAC中SCN原理和机制的探索的更多相关文章

  1. Oracle rac架构和原理

        Oracle RAC Oracle Real Application Cluster (RAC,实时应用集群)用来在集群环境下实现多机共享数据库,以保证应用的高可用性:同时可以自动实现并行处理 ...

  2. Oracle RAC/Clusterware 多种心跳heartbeat机制介绍 RAC超时机制分析

    ORACLE RAC中最主要存在2种clusterware集群件心跳 &  RAC超时机制分析: 1.Network Heartbeat 网络心跳 每秒发生一次: 10.2.0.4以后网络心跳 ...

  3. Oracle RAC cache fusion原理測试

    Oracle RAC cache fusion是RAC最核心的工作机制.他把全部实例的SGA虚拟成一个大的SGA区,每当不同的实例请求同样的数据块,这个数据块就须要在实例间进行传递. 那究竟什么时候传 ...

  4. Oracle RAC中的投票算法

    RAC集群中有三台机器,A,B,C A,B,C都会有3票,假设这是A的心跳线出现问题,整个RAC集群就划分为两个paritition, 一个是只有A的partition,一个是B,C组成的partit ...

  5. ORACLE RAC中的oc4j和gsd资源以及RAC相关的进程

    1.RAC相比单实例数据库多出的进程: LMS - Gobal Cache Service Process 全局缓存服务进程 LMD - Global Enqueue Service Daemon 全 ...

  6. Oracle RAC中的一台机器重启以后无法接入集群

          前天有个同事说有套AIX RAC的其中一台服务器重启了操作系统以后,集群资源CSSD的资源一直都在START的状态,检查日志输出有如下内容: [    CSSD][1286]clssnmv ...

  7. ORACLE RAC中一个实例不能随crs自动启动的解决

    现象:在两个节点上做CRS的重启,这个实例都不能随CRS的启动而启动.CRS启动后做crs_start -all可以把没启动的资源起来,而且无报错. 分析:去crsd.log中找原因,发现CRS根本就 ...

  8. Oracle rac集群环境中的特殊问题

    备注:本文摘抄于张晓明<大话Oracle RAC:集群 高可用性 备份与恢复> 因为集群环境需要多个计算机协同工作,要达到理想状态,必须要考虑在集群环境下面临的新挑战. 1.并发控制 在集 ...

  9. Oracle RAC的机制与测试方法

    Oracle RAC的机制与测试方法 标签: rac 机制 测试 2016-05-25 09:54 1150人阅读 评论(0) 收藏 举报  分类: oracle(2)  1.RAC原理 Oracle ...

随机推荐

  1. URL重定向及跳转漏洞

    URL跳转漏洞 URL 跳转漏洞是指后台服务器在告知浏览器跳转时,未对客户端传入的重定向地址进行合法性校验,导致用户浏览器跳转到钓鱼页面的一种漏洞. 使用场景    现在 Web 登录很多都接入了QQ ...

  2. 奇异分解(SVD)

    奇异分解 假设C是m×n矩阵,U是m×m矩阵,其中U的列为 的正交特征向量,V为n×n矩阵,其中V的列为 的正交特征向量,再假设r为C矩阵的秩,则存在奇异值分解: 其中和的特征值相同,为 ,且. 是m ...

  3. 1:Javascript的数据类型和相互转换

    第一节:JavaScript的数据类型 他是弱类型 var 但是正是由于其实弱类 所以其后台的数据类型转换也是我们值得思考的 JavaScript的数据类型有两种 一种是原始类型  另外一种是对象类型 ...

  4. java中如何认定一个变量和方法

    对于变量,用变量名就可以认定.对于a ,你不能要求它既是int,又是double.这是错误的: 同理,对于方法,它的方法签名是:方法名+参数     通过签名,已经认定一个方法.你不能要求一个方法有多 ...

  5. Java中的单实例

    前几天刚学完单实例设计模式,今天看代码时发现一行代码很奇怪,getRuntime()函数的返回类型怎么是它本身,忽然想起前几天学的单实例模式,于是找到方法的定义,果然是静态私有变量,获取实例的公有方法 ...

  6. vue组件定义全局方法

    1.在vue实例的data中定义一个对象 2.可以在其他组件定义方法 3.触发方法

  7. Python 创建和使用类

    python创建和使用类的方法如下 # class Dog(): # def __init__(self,name,age): # self.name=name # self.age=age # # ...

  8. leecode第五十三题(最大子序和)

    class Solution { public: int maxSubArray(vector<int>& nums) { int len=nums.size(); )//特殊情况 ...

  9. 学习笔记4-pathon的range()函数和list()函数

    使用python的人都知道range()函数很方便,今天再用到他的时候发现了很多以前看到过但是忘记的细节.这里记录一下range(),复习下list的slide,最后分析一个好玩儿的冒泡程序. 这里记 ...

  10. 定时任务redis锁+自定义lambda优化提取冗余代码

    功能介绍: 我系统中需要跑三个定时任务,由于是多节点部署,为了防止多个节点的定时任务重复执行.所以在定时任务执行时加个锁,抢到锁的节点才能执行定时任务,没有抢到锁的节点就不执行.从而避免了定时任务重复 ...