Heartbeat Score的計算-+colocation

Steven1981發表於2009-11-26
再次研究COLOCATION,希望其能在<2resource2group4score>的配置環境中起作用,(限制兩個資源跑到一起)。
1,配置:在<2resource2group4score>CIB.XML中,

...

...


加完以後,請用crm_verify -V -x cib.xml 檢查是否有配置錯誤.
[@more@]
2,積分的檢視計算
2.1 積分的檢視
[root@MYSQL4 crm]# 2>&1 /usr/heartbeat/sbin/ptest -LVVVVVVVV|grep -E "dump_node_scores"
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: group_color: group_1 allocation score on mysql4: 0
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: group_color: group_1 allocation score on mysql3: 5
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: group_color: IPaddr_10_2_225_225 allocation score on mysql4: 100
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: group_color: IPaddr_10_2_225_225 allocation score on mysql3: 105
ptest[5808]: 2009/11/25_17:33:10 debug: debug3: dump_node_scores: Pre-allloc: IPaddr_10_2_225_225 allocation score on mysql4: 100
ptest[5808]: 2009/11/25_17:33:10 debug: debug3: dump_node_scores: Pre-allloc: IPaddr_10_2_225_225 allocation score on mysql3: 105
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: group_color: group_mysql allocation score on mysql4: 0
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: group_color: group_mysql allocation score on mysql3: 5
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: group_color: mysql allocation score on mysql4: 100
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: group_color: mysql allocation score on mysql3: 105
ptest[5808]: 2009/11/25_17:33:10 debug: debug3: dump_node_scores: Pre-allloc: mysql allocation score on mysql4: 100
ptest[5808]: 2009/11/25_17:33:10 debug: debug3: dump_node_scores: Pre-allloc: mysql allocation score on mysql3: 105
ptest[5808]: 2009/11/25_17:33:10 debug: debug3: dump_node_scores: Post-coloc: mysql allocation score on mysql4: 100
ptest[5808]: 2009/11/25_17:33:10 debug: debug3: dump_node_scores: Post-coloc: mysql allocation score on mysql3: 105
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: native_color: mysql allocation score on mysql4: 400
ptest[5808]: 2009/11/25_17:33:10 debug: debug2: dump_node_scores: native_color: mysql allocation score on mysql3: 420

IPaddr.SCORE = Pre-allloc: IPaddr_10_2_225_225
Mysql.SCORE = Pre-allloc: mysql
綜合all.SCORE = native_color: mysql 用來判決是否切換
2.2 積分的計算
注:以下所有得出的結論是基於<2resource2group4score> + colocation 的配置環境測試的。
(1個資源組只配置1個資源,簡稱其cib.xml原文見
http://steven1981.itpub.net/post/7967/494030
0)資源要切換不再以單個資源的分數來比較. 而是以該NODE的N個資源SCORE之和,再乘N,我們下面稱它為
NodeX.all.score= (mysqlX.resource1.score+ .... + mysqlX.resourceN.score) *N
1)當HB發生NodeX資源失敗時,會給該NODE
NodeX.resourceN.score += default-resource-failure-stickiness
NodeX.resourceN.score -= default-resource-stickiness
NodeX.resourceN.score += default-resource-stickiness
NodeX.all.score = (NodeX.resource1.score + ...... + NodeX.resourceN.score)* N
然後多個NODE之間比較NodeX.all.score
2)當HB發現NodeX上資源發生切換到"NodeY" 時,會減去之前賦給該NODE的"成功分:default-resource-stickiness",
NodeX.resource[1..N].score -= default-resource-stickiness
NodeY.resource[1..N].score += default-resource-stickiness
NodeX.all.score = NodeX.resource1.score + ...... + NodeX.resourceN.score
NodeY.all.score = NodeY.resource1.score + ...... + NodeY.resourceN.score
3)其他演算法同配置<2resource2group4score>.
3,例子以及測試資料。
例1:

default-resource-stickiness=5 default-resource-failure-stickiness=-15

mysql4.ipaddr.score=100 mysql3.ipaddr.score=100
mysql4.mysql.score=100 mysql3.mysql.score=10
1
SCOREResource StatusAction MEMO
mysql3.ipaddrmysql4.ipaddrmysql3.mysqlmysql4.mysqlmysql3.allmysql4.allmysql3.statusmysql4.statusseqoperation 
105100106100422400 Ipaddr/mysql1Start 
90100106100392400  2mysql3.ipaddr down中間計算,HB認為需要切換
85105101105372420Ipaddr/mysql   這時可以mysql3.HB restart,以置回初值
100105101105402420  3mysql3.HB restart 
           
           
下面不演示也去了。與前面的計算也很類似。
有興趣的同學,可以先把分數計算好,然後再看看HB的結果。

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

相關文章