0:这是默认选项。资源放置在系统中的最适合位置。这意味着当负载能力“较好”或较差的节点变得可用时才转移资源。此选项的作用基本等同于自动故障回复,只是资源可能会转移到非之前活动的节点上;
大于0:资源更愿意留在当前位置,但是如果有更合适的节点可用时会移动。值越高表示资源越愿意留在当前位置;
小于0:资源更愿意移离当前位置。绝对值越高表示资源越愿意离开当前位置;
INFINITY:如果不是因节点不适合运行资源(节点关机、节点待机、达到migration-threshold 或配置更改)而强制资源转移,资源总是留在当前位置。此选项的作用几乎等同于完全禁用自动故障回复;
-INFINITY:资源总是移离当前位置;
我们这里可以通过以下方式为资源指定默认黏性值:
# crm configure rsc_defaults resource-stickiness=100
这是我们把node1节点设为非活动节点:
# crm node standby
查看状态:
# crm status
============
Last updated: Mon Apr 16 02:48:02 2012
Stack: openais
Current DC: node2.linuxidc.com - partition with quorum
Version: 1.0.11-1554a83db0d3c3e546cfd3aaff6af1184f79ee87
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Node node1.linuxidc.com: standby
Online: [ node2.linuxidc.com ]
WebIP (ocf::heartbeat:IPaddr): Started node2.linuxidc.com
然后我们再让node1节点上线,则资源并不会应用到node1上,这就是粘性值的功能:
# crm status
============
Last updated: Mon Apr 16 02:48:10 2012
Stack: openais
Current DC: node2.linuxidc.com - partition with quorum
Version: 1.0.11-1554a83db0d3c3e546cfd3aaff6af1184f79ee87
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node1.linuxidc.com node2.linuxidc.com ]
WebIP (ocf::heartbeat:IPaddr): Started node2.linuxidc.com
9、结合上面已经配置好的IP地址资源,将此集群配置成为一个active/passive模型的web(httpd)服务集群
为了将此集群启用为web(httpd)服务器集群,我们得先在各节点上安装httpd,并配置其能在本地各自提供一个测试页面。
Node1:
# yum -y install httpd
# echo "Node1.linuxidc.com" > /var/www/html/index.html
Node2:
# yum -y install httpd
# echo "Node2.linuxidc.com" > /var/www/html/index.html
而后在各节点手动启动httpd服务,并确认其可以正常提供服务。接着使用下面的命令停止httpd服务,并确保其不会自动启动(在两个节点各执行一遍):
# /etc/init.d/httpd stop
# chkconfig httpd off
接下来我们将此httpd服务添加为集群资源。将httpd添加为集群资源有两处资源代理可用:lsb和ocf:heartbeat,为了简单起见,我们这里使用lsb类型:
首先可以使用如下命令查看lsb类型的httpd资源的语法格式:
# crm ra info lsb:httpd
lsb:httpd
Apache is a World Wide Web server. It is used to serve \
HTML files and CGI.
Operations' defaults (advisory minimum):
start timeout=15
stop timeout=15
status timeout=15
restart timeout=15
force-reload timeout=15
monitor interval=15 timeout=15 start-delay=15
接下来新建资源WebSite:
# crm configure primitive WebSite lsb:httpd
查看配置文件中生成的定义:
# crm configure show
node node1.linuxidc.com
node node2.linuxidc.com
primitive WebIP ocf:heartbeat:IPaddr \
params ip="172.16.100.1"
primitive WebSite lsb:httpd
property $id="cib-bootstrap-options" \
dc-version="1.0.11-1554a83db0d3c3e546cfd3aaff6af1184f79ee87" \
cluster-infrastructure="openais" \
expected-quorum-votes="2" \
stonith-enabled="false" \
no-quorum-policy="ignore"
查看资源的启用状态:
# crm status
============
Last updated: Tue Jun 14 19:57:31 2011
Stack: openais
Current DC: node2.linuxidc.com - partition with quorum
Version: 1.0.11-1554a83db0d3c3e546cfd3aaff6af1184f79ee87
2 Nodes configured, 2 expected votes
2 Resources configured.
============
Online: [ node1.linuxidc.com node2.linuxidc.com ]
WebIP (ocf::heartbeat:IPaddr): Started node1.linuxidc.com
WebSite (lsb:httpd): Started node2.linuxidc.com
从上面的信息中可以看出WebIP和WebSite有可能会分别运行于两个节点上,这对于通过此IP提供Web服务的应用来说是不成立的,即此两者资源必须同时运行在某节点上。
