Rac 的GESGCS原理.docx
- 文档编号:27942324
- 上传时间:2023-07-06
- 格式:DOCX
- 页数:77
- 大小:625.85KB
Rac 的GESGCS原理.docx
《Rac 的GESGCS原理.docx》由会员分享,可在线阅读,更多相关《Rac 的GESGCS原理.docx(77页珍藏版)》请在冰豆网上搜索。
Rac的GESGCS原理
Rac的GES/GCS原理6(图文解释cachefusion机制1)
CacheFusionExamples
ThefollowingsectioncontainsexamplesofthedifferenttypesofbehaviorsoftheCacheFusion
algorithmforblockreadsandupdates.Eachexamplewillfollowasingleblockasitisrequestedby
variousinstancesforbothsharedandexclusiveaccess.
cachefusion举例
下面的场景将包含各种类型下cachefusion算法针对块的读或跟新。
每个例子将跟踪一个
数据块,看它被不同实例要求来做共享或专用访问的情况。
Example1:
CurrentReadwithNoTransfer
Inthefollowingexamples,thedatabaseclusterconsistsoffourinstances,eachofwhichhasaccess
toadatabaseonshareddisk.Theblockisinitiallyonlyinthedatabaseondisk.ItiscurrentlyatSCN
1318(Figure22-1)
在下面的例子中,数据库群集包含有4个实例,每个实例都有访问共享存储上数据库的权限。
这个数据块最开始只存在于数据库的磁盘上。
它的当前SCN为1318。
Instance2requestsacurrentreadoftheblock(Figure22-2).
Itfirstidentifiestheinstancethatistheresourcemasterfortheblockbyapplyingahashfunction
tothedatabaseblockaddress(DBA)oftheresource.Inthiscase,theresourcemasterinstance
isInstance3.AsInstance2onlyneedstoperformacurrentreadontheblock,itsendsamessageto
Instance3requestingsharedaccesstotheblock.
Instance3checksintheGRDanddiscoversthattheblockisnotcurrentlybeingaccessedby
anyinstances.Therefore,Instance3immediatelygrantssharedaccessontheblocktoInstance2
(Figure22-3).
实例2要求读这个数据块。
首先实例2将寻找这个数据块的资源属主,通过资源属主应用hash函数来找到资源的数据块地址。
在我们的例子中,数据块的资源属主是实例3。
因为实例2仅仅只需要做一个对数据块的当前读,
它首先发送一个消息给实例三,要求对数据块做一个共享访问。
实例三将首先检查GRD,实例三发现这个数据没有被任何实例所访问。
因此,实例三将立即
把数据块的共享访问权限赋予实例二。
Instance2issuesasystemcalltoreadtheblockdirectlyfromthedatabase(Figure22-4).The
blockiscurrentlyatSCN1318.
Theblockisreturnedfromdiskandacurrentversionisstoredinthebuffercache(Figure22-5).
TheSCNisstill1318.
实例2发起一个系统调用,直接从数据库读取数据块。
这个数据块的SCN在1318。
数据块从磁盘返回,而它的当前版本储存在buffercache中,当前的版本SCN也是1318。
Example2:
Read-to-WriteTransfer
ThisexampleshowshowGCSsatisfiesarequestbyaninstancetoreadablockforupdatewhere
thatblockisalreadyheldread-onlybyanotherinstance.
Instance1requestsanexclusivereadontheblock.Initially,Instance1isnotawarethatthe
blockiscurrentlyheldbyInstance2.
Instance2identifiestheinstancethatistheresourcemaster
fortheblockapplyingahashfunctiontothedatabaseblockaddress(DBA)oftheresource.Instance1
sendsamessagetoInstance3requestingexclusiveaccesstotheblock(Figure22-6).
例2:
读-写传输
这个例子解释了GCS机制在下面条件下的工作原理:
一个实例准备从某个数据块读数据以便
跟新,而这个数据块已经被另外的实例以只读模式持有了。
实例1要求对数据块一个只读访问。
最开始,实例1并不知道这个数据块被实例2持有。
实例2
通知资源属主这个数据块正被实例2持有。
实例2通知实例数据块的资源属主采用hash函数来
找到该资源的数据库的数据块地址。
实例1发送一个信息到实例3,希望对数据块进行专有访问。
Instance3checksintheGRDanddiscoversthattheblockiscurrentlyheldbyInstance2for
shared(read)access.Instance3sendsamessagetoInstance2requestingthatitsendtheblockto
Instance1(Figure22-7).
实例3检查GRD,发现这个数据块当前正被实例2持有,以共享读方式访问。
实例3发送消息,要求实例2把数据块发送给实例1。
Instance2sendstheblock,stillSCN1318,toInstance2anddowngradesthesharedlockto
anulllock(Figure22-8)。
实例2将发送这个数据块,时间点仍然是1318,实例2将降级共享锁(S)到空锁(null).
Instance1receivestheblockandsendsamessagetoInstance3toupdatetheresourcestatus
bysettingthelockmodeontheblocktoexclusive(X)(Figure22-9).Instance3updatestheGRD.
Instance1assumesanexclusivelockandupdatestheblockatSCN1320.
实例1收到这个数据块之后,将数据块的锁模式设置为专有模式(x),并发送消息给实例3,
要求实例3来修改资源状态。
实例3修改GRD。
实例1申明对此数据块一个专有锁,并修改数据
块到SCN1320时间点。
NotethatRACisdesignedtominimizethenumberofmessagesthatpassacrosstheinterconnect
network.Therefore,Instance3sendsamessagetoInstance2requestingthatitpasstheblock
toInstance1anddowngradesthesharedlocktoanulllock.However,Instance2doesnotreply
directlybacktoInstance3.Instead,itpassesboththeblockandtheresourcestatustoInstance1,
whichforwardstheupdatedresourcestatusbacktoInstance3.
注意RAC数据库的目的是减少内联网络中信息的传递。
因此,实例三发送信息给实例2,要求实例
2把数据块发送给实例1并降级自己对数据块的锁模式由share变为null。
但是,实例2不会直接
把结果返回给实例三。
实例2会首先把数据块和资源状态信息发送给实例1,实例1再把修改后的
资源状态信息发送给实例3。
Example3:
Write-to-WriteTransfer
ThisexampleshowshowGCSsatisfiesarequestbyaninstancetoreadablockforupdatewhere
thatblockisalreadyheldforupdatebyanotherinstance.
例3:
写-写传输
这个例子将展示GCS如何满足这样的要求,当1个实例读取某个数据块以便跟新,而这个数据块
已经被另外一个instance以update为目的持有了。
Instance4hasalsorequestedanexclusivereadontheblock.Initially,Instance4isnotaware
thattheblockiscurrentlyheldbyInstance1.Instance4identifiesthatInstance3istheresource
masterinstancefortheblock.Instance4sendsamessagetoInstance3requestingexclusiveaccess
totheblock(Figure22-10).
实例4也要求对这个数据块持有只读的排它锁。
最开始,实例4不知道这个数据块已经被实例1
持有了。
实例4将发现实例3是该数据块的资源属主。
实例4将发送一个消息给实例3,要求
对这个数据块进行专有访问。
Instance3checksintheGRDanddiscoversthattheblockiscurrentlyheldbyInstance1for
exclusive(update)access.Instance3sendsamessagetoInstance1requestingthatitsendtheblock
toInstance4(Figure22-11).
实例3将检查GRD,并发现数据块当前正被实例1以专有(修改)模式持有。
实例三发送消息给实例
1,要求它发送数据块给实例4
Instance1sendstheblock,stillSCN1320,toInstance4anddowngradestheexclusivelockto
anulllock(Figure22-12).。
实例1将发送这个数据块(时间点仍然是1320)给实例4,并把专有锁降级为空锁。
Instance4receivestheblockandsendsamessagetoInstance3toupdatetheresourcestatus,
againsettingthelockmodeontheblocktoexclusive(Figure22-13).Instance3updatestheGRD.
Instance4assumesanexclusivelockandupdatestheblockatSCN1323.
实例4将接受这个数据块,并发送消息给实例3来跟新资源状态,再次把这个数据块上的锁
设置为专有模式。
实例3跟新GRD。
实例4宣称获得了专有锁,并在SCN1323的时间点
修改这个数据块。
NotethatInstance1willretainapastimage(PI)copyoftheblockatSCN1320untilthecurrent
versionoftheblock(SCN1323)iswrittentodiskbyInstance4.
注意实例1将保留这个数据块在SCN1320的过去镜像(PI),直到该数据块的当前版本(scn1323)
被实例4写回到磁盘。
Example4:
Write-to-ReadTransfer
Thebehaviorofthewrite-to-readtransferisdeterminedbythe_FAIRNESS_THRESHOLDparameter,
whichwasintroducedinOracle8.1.5anddefaultsto4.Priortotheintroductionofthisparameter,
whenInstanceAheldablockinexclusivemodeandInstanceBrequestedaread-onlycopyofthat
block,InstanceAwoulddowngradeitsexclusivelocktoasharedlockandsendtheblocktoInstanceB,whichwouldalsosetasharedlockontheblock.
例子4:
读写传输
读写传输的表现要根据_FAIRNESS_THREASHOLD参数,这个参数从ORACLE8.1.5出现,而且
默认取值为4。
在引进这个参数之前,当实例A对这个数据块以排他模式持有,而实例B要求
这个数据块的只读拷贝,此时实例1将降级排他锁为共享锁模式--并把数据块发送给实例B,
而实例B将对数据块加一个共享锁。
However,ifInstanceAisperformingfrequentupdatesontheblock,itwillneedtoreacquiretheblockandsetanexclusivelockagain.Ifthisprocessisrepeatedfrequently,thenInstanceAwillbecontinuallyinterrupted,asithastodowngradetheexclusivelocktoasharedlockandwaituntilInstanceBhasfinishedreadingtheblockbeforeitcanconvertthesharedlockbackintoanexclusivelock.
然而,如果实例A在频繁的对这个数据块做跟新操作,它将需要重新获取这个数据块,并
再次设置专有共享锁,所以他必须降级转有锁到共享模式,等待实例B,直到实例B完成了
对数据块的读操作,再把数据共享锁转换回转有锁模式。
The_FAIRNESS_THRESHOLDparametermodifiesthisbehavior.Whenthisparameterisset,
InstanceAwillnolongerdowngradetheexclusivelock.Instead,itsendsanulllocktoInstanceB,
andthenitcancontinueprocessing.However,ifinstanceBrequeststheblock_FAIRNESS_THRESHOLD
times,bydefault4,thenInstanceAwillreverttotheoriginalbehavior—itwilldowngradethe
exclusivelocktoasharedlockandshiptheblocktoInstanceB,whichwillalsosetasharedlockon
theblock.
而_FAIRNESS_THREASHOLD参数修改这个现象,当这个参数被设置之后,还是上面的例子,
实例将不再降级本地的专有锁。
取而代之,它将发送一个空锁给实例B,然后实例A将继续做
处理操作。
然而,如果实例B要求这个数据块的次数达到了_FAIRNESS_THREAHOLD次数之后,
默认是4次,实例A将改变原来的做法---它将降级专有锁到共享模式,然后把数据块传输到实例
B,实例B也会对这个数据块设置一个共享锁。
Thisbehaviorisexplainedinthefollowingexample.
Instance2requestsacurrentreadontheblock.Instance2isnotawarethattheblockiscurrently
heldbyInstance4.Instance2identifiesthatInstance3istheresourcemasterinstancefortheblock
andsendsamessagetoInstance3requestingsharedaccesstotheblock(Figure22-14).
这个表现是以下面的例子来解释的:
实例2需要对这个数据块做一个当前读。
实例2并不知道这个数据块被实例4锁持有。
实例2发现实例
3是数据块的资源属主,于是发送消息给实例3,要求对这个数据块做一个共享访问。
Instance3checksintheGRDanddiscoversthattheblockiscurrentlyheldbyInstance4for
exclusive(update)access.Instance3sendsamessagetoInstance4requestingthatitsendtheblock
toInstance2insharedmode(Figure22-15).
实例三检查GRD,发现数据块正在被实例4以专有锁持有。
实例3发送一个消息给实例4,要求
实例4以共享模式传输数据块给实例2。
Instance4sendstheblocktoInstance2(Figure22-16).Becausetheblockhasbeenrequested
lessthan_FAIRNESS_THRESHOLDtimes,Instance4retainstheexclusivelock,andInstance2receives
anulllock.
实例4将传输这个数据块给实例2,。
因为这个数据快被要求的次数少于_FAIRNESS_THRESHOLD
的次数,实例4将保留exclusive锁模式,而实例2将收到一个空锁。
Instance2receivestheblockandsendsamessagetoInstance3toupdatetheresourcestatus
(Figure22-17).Instance3updatestheGRD.Instance2assumesanulllockontheblockandreadsit.
Instance4canupdatetheblockforwhichitcontinuestoholdanexclusiveprocess.
实例2收到了这个数据块,并发送信息到实例3来更新资源状态。
实例3将跟新GRD。
实例2
对这个数据块申明一个空锁并读取它。
同时,实例4能够跟新这个数据块,因为它还持有这
个数据块的专有锁。
Theprecedingprocesscanberepeatedthenumberoftimesspecifiedbythe
_FAIRNESS_THRESHOLDparameter.Bydefault,thevalueofthisparameteris4.
Instance2hasnowflushedtheblockfromitsbuffercacheandneedstoreaditagain.Itsends
areadrequesttotheresourcemaster,whichisInstance3(Figure22-18).
上面的过程可以重复多次,具体次数由参数_FAIRNESS_THRESHOLD决定。
这个参数的默认值是4。
实例2现在已经把数据块从buffercache清除了,又需要
再读取这个数据块。
它这时又把要求发送给资源属主,属主是实例3
Instance3(theresourcemaster)sendsamessagetoInstance4requestingthatitsendacopy
oftheblocktoInstance2(Figure22-19).Instance4notestha
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Rac 的GESGCS原理 GESGCS 原理