Corosync+OpenAIS+Pacemaker+Web+DRBD实现高可用群集(6)

6.定义web服务资源

在两个节点上都要进行安装

安装完毕后,可以查看httpd的lsb脚本

[root@node2 corosync]# crm ra list lsb

或者

crm(live)ra# list lsb

查看httpd的参数

crm(live)ra# meta 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

定义httpd的资源

crm(live)configure# primitive webserver lsb:httpd

crm(live)configure# show

node node1.a.com

node node2.a.com

primitive webIP ocf:heartbeat:IPaddr \

params ip="192.168.145.10"

primitive webserver lsb:httpd

property $id="cib-bootstrap-options" \

dc-version="1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f" \

cluster-infrastructure="openais" \

expected-quorum-votes="2" \

stonith-enabled="false"

crm(live)# status

============

Last updated: Mon May  7 20:01:12 2012

Stack: openais

Current DC: node1.a.com - partition with quorum

Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f

2 Nodes configured, 2 expected votes

2 Resources configured.

============

Online: [ node1.a.com node2.a.com ]

webIP (ocf::heartbeat:IPaddr): Started node1.a.com

webserver (lsb:httpd): Started node2.a.com

发现httpd已经启动了,但是在node2节点上

(高级群集服务资源越来越多,会分布在不同的节点上,以尽量负载均衡)

需要约束在同一个节点上,定义成一个组

可以实用  crm(live)configure# help group  查看配置组的帮助 信息

crm(live)configure# help group

The `group` command creates a group of resources.

Usage:

...............

group <name> <rsc> [<rsc>...]

[meta attr_list]

[params attr_list]

attr_list :: [$id=<id>] <attr>=<val> [<attr>=<val>...] | $id-ref=<id>

...............

Example:

...............

group internal_www disk0 fs0 internal_ip apache \

meta target_role=stopped

...............

定义组

crm(live)configure# group web  webIP  webserver

crm(live)configure# show

node node1.a.com

node node2.a.com

primitive webIP ocf:heartbeat:IPaddr \

params ip="192.168.145.10"

primitive webserver lsb:httpd

group web webIP webserver

property $id="cib-bootstrap-options" \

dc-version="1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f" \

cluster-infrastructure="openais" \

expected-quorum-votes="2" \

stonith-enabled="false"

在次查看群集的状态

crm(live)# status

============

Last updated: Mon May  7 20:09:06 2012

Stack: openais

Current DC: node1.a.com - partition with quorum

Version: 1.1.5-1.1.el5-01e86afaaa6d4a8c4836f68df80ababd6ca3902f

2 Nodes configured, 2 expected votes

1 Resources configured.

============

Online: [ node1.a.com node2.a.com ]

Resource Group: web

webIP (ocf::heartbeat:IPaddr): Started node1.a.com

webserver (lsb:httpd): Started node1.a.com

crm(live)#

(现在ip地址和 httpd都已经在node1上了)

lsb之类的服务,一定不能自动启动  chkconfig httpd off

1  测试,在两个节点上做网页

在节点1  和节点2 上分别创建网页

使用群集ip 发现在第一个节点上

2.将节点1 的corosync 服务停止

[root@node1 corosync]# service corosync stop

3. 在节点2上进行观察

[root@node2 corosync]# crm  status

============

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/962352845cb1e752dbe6154c62f8b53f.html