DRM --- RAC object remastering ( Dynamic remastering )

zhouwf0726發表於2019-02-23

系統啟動時,在RAC中,以hash方式確定每個資料塊的master例項。隨著應用的執行,可能某個資料塊更多的被非master例項訪問,如果可以根據訪問頻率,
將資料塊的master動態調整為訪問頻率最高的例項,將會減少例項間通訊,提高應用效能。

1,DRM相關引數
_gc_affinity_time:檢查是否需要remaster的頻率(以分鐘為單位);設定為0禁用該特性(同時停止了相關資訊收集);預設值10分鐘
_gc_affinity_limit: 某個節點至少需要訪問一個物件(比當前master多)多少次才能被DRM;預設值50
_gc_affinity_minimum: 在開始remaster一個物件前,每分鐘至少需要訪問的次數,預設值2400
_gc_undo_affinity:對undo段是否啟用drm,預設值TRUE

2,DRM實現機制
(1)由LCK0程式維護物件統計資訊x$object_affinity_statistics,在滿足_gc_affinity_limit,_gc_affinity_minimum條件後,會被放在一個佇列;
(2)LMD0讀取該佇列,啟動GRD凍結;
(3)LMON與LMS程式完成重構.

x$object_affinity_statistics跟蹤物件訪問次數:
select * from x$object_affinity_statistics where bject=6099472;
ADDR INDX INST_ID OBJECT NODE OPENS
---------------- ---------- ---------- ---------- ---------- ----------
FFFFFFFF7C05BFA8 0 1 6099472 1 7437

3,DRM相關檢視:
(1)v$gcshvmaster_info
SQL> select * from v$gcshvmaster_info;
HV_ID CURRENT_MASTER PREVIOUS_MASTER REMASTER_CNT
1 1 1 32767 0
2 2 0 32767 1
3 3 1 32767 0
4 4 0 32767 1
...
126 126 0 32767 1
127 127 1 32767 0
128 128 25 6 117440517
已選擇128行。

說明:
如果object_id>4294950912,表示undo segment no:
usn=object_id-4294950912,其中:
[ 4294950912 = power(2,32) - power (2,14) = xFFFFC000 ]

(2)v$gcspfmaster_info
SQL> select * from v$gcspfmaster_info;
FILE_ID OBJECT_ID CURRENT_MASTER PREVIOUS_MASTER REMASTER_CNT
---------- ---------- -------------- --------------- ------------
0 1 0 32767 1
0 4 1 32767 0
0 181049 1 32767 1
0 185360 1 32767 0
0 185364 1 32767 0
0 181614 0 1 2
0 181632 1 0 2
0 181679 0 1 3
0 182118 0 32767 1
0 182184 0 32767 1
0 184027 1 32767 1

已選擇11行。

測試:
--物件
SELECT owner, object_name, object_type
FROM dba_objects
WHERE object_id = 181679;
OWNER OBJECT_NAME OBJECT_TYPE
BOCNETYL USERS TABLE

--表BOCNETYL.USERS當前master是1:
select * from v$gcspfmaster_info where object_id=181679;
FILE_ID OBJECT_ID CURRENT_MASTER PREVIOUS_MASTER REMASTER_CNT
0 181679 1 0 2

--在instance0上對錶BOCNETYL.USERS進行全表掃描
select /*+ full(t) */count(*) from users t;


--表BOCNETYL.USERS當前master是0:
select * from v$gcspfmaster_info where object_id=181679;
FILE_ID OBJECT_ID CURRENT_MASTER PREVIOUS_MASTER REMASTER_CNT
0 181679 0 1 3

(3)表X$KJDRMAFNSTATS記錄DRM次數

4,手工DRM
SQL> select object_id,current_master, previous_master ,remaster_cnt from V$GCSPFMASTER_INFO where object_id = 144615
OBJECT_ID CURRENT_MASTER PREVIOUS_MASTER REMASTER_CNT
---------- -------------- --------------- ------------
144615 0 2 0
The object 144615 is currently mastered on node 0.

NODE2> oradebug setmypid
Statement processed.

NODE2> oradebug lkdebug -m pkey 144615
Statement processed.

NODE2> select object_id,current_master, previous_master ,remaster_cnt from V$GCSPFMASTER_INFO where object_id = 144615
OBJECT_ID CURRENT_MASTER PREVIOUS_MASTER REMASTER_CNT
144615 2 0 0

To dissolve remastering of this object on this instance
SQL> oradebug lkdebug -m dpkey 144615

SQL> select object_id,current_master, previous_master ,remaster_cnt from V$GCSPFMASTER_INFO where object_id = 144615;
no rows selected

5,DRM相關等待事件
"gcs drm freeze in enter server",雖然10gR2採用並行方式remaster,仍然可能導致系統出現大量"gc buffer busy"事件.

6,DRM不同版本的變化
(1)10gR1是檔案粒度的remaster;10gR2是物件粒度的remaster;
(2)11g後,affinity被替換為policy,比如:
x$object_affinity_statistics ==> x$object_policy_statistics
_gc_affinity_limit ==> _gc_policy_limit
_gc_affinity_time ==> _gc_policy_time

新增了檢視v$policy_history,其中所有'initiate_affinity'都是DRM事件.
select * from v$policy_history
INST_ID POLICY_EVENT DATA_OBJECT_ID TARGET_INSTANCE_NUMBER EVENT_DATE
---------- -------------------- -------------- ---------------------- --------------------
2 glru_on 0 1 10/15/2010 10:58:28
2 glru_on 0 1 10/15/2010 11:21:32
2 initiate_affinity 74809 1 10/15/2010 13:27:44

7,DRM建議
不建議完全禁止drm,而是提高drm觸發條件,比如增加_gc_affinity_time,_gc_affinity_limit,_gc_affinity_minimum.
在啟用DRM的情況下,可以在不丟失高可用性的前提下,方便的實現應用訪問特定例項(通過優先訪問特定ip,而不是load_balance=yes),減少例項間通訊,提高系統效能。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-720877/,如需轉載,請註明出處,否則將追究法律責任。

相關文章