39_01Linux集群系列之十一--高可用集群之heartbeat_v2_基于crm进行资源管理

CIB: Cluster Information Base
xml格式,为了能够简单使用CIB,提供了haresources2clib.py脚本

当在ha.cf中添加了crm respawn选项的时候,默认的haresources配置信息就不会再被使用,但是可以执行
/usr/lib64/heartbeat/haresources2cib.py脚本使其保留在/var/lib/heartbeat/crm/目录下;

但是haresources2cli.py的执行需要依赖同目录下的ha_propagate脚本,执行这个脚本会自动进行同步到其他节点上;

当VIP挂了,备用节点抢过来VIP上线,但是在路由器中保存的是原来VIP的mac地址,那么备用节点需要进行arp欺骗:
/usr/lib64/heartbeat/send_arp实现mac地址伪装,进行arp欺骗;

换另一种方式:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
yum install pacemaker corosync 
#vim /etc/ha.d/ha.cf
mcast eth0 225.0.100.19 694 1 0
crm respawn    此时没有任何资源
ln -s /usr/libexec/pacemaker/cib /usr/lib64/heartbeat/cib
ln -s /usr/libexec/pacemaker/stonith /usr/lib64/heartbeat/stonithd
ln -s /usr/libexec/pacemaker/attrd /usr/lib64/heartbeat/attrd
ln -s /usr/libexec/pacemaker/crmd /usr/lib64/heartbeat/crmd

#/usr/lib64/heartbeat/ha_propagate   会自动进行同步
#service heartbeat start
#ssh node2 "service heartbeat start"
#tail /var/log/message
    可以看到详细信息
    
#netstat -ntlp | grep mgmtd
    监听在5560端口

cibadmin
cibclient
crmmon:可用于监测这些节点状态,每15秒刷新一次
crmadmin
crm_resource:用来做资源配置
crm_verify:校验/usr/lib64/heartbeat/cib.xml文件是否有语法错误的;
crm_standby:指定让哪个节点转为备节点
crm_sh:crm的命令行工具
使用方法:

1
2
3
4
5
6
7
> #crm_sh 
> crm# help
> Usage:crm (nodes|config|resources)
> crm#nodes
> crm nodes# help
> Usage: nodes(status|list)
> crm nodes#list

如何使用GUI方式进行管理
1、tail /etc/passwd
默认生成hacluster用户,没有密码

#passwd hacluster ,密码随便

#tail /var/log/message 查看谁是DC:假设是node2:192.168.1.103
当然连接到hb_gui上也可以进行查看

#hb_gui &
会出现:
Server(:port) 192.168.1.103
User Name: hacluster
Password: hacluster

添加资源
Resources–> + –> native –>Resource ID:webip–>Type–>IPaddr(2)–> Parameters–>ip 192.168.1.101–>Add Parameters –>nic eth0–>cidr_netmask 24
最后Patameters类似:
Name Value
ip 192.168.1.103
nic eth0
cidr_netmask 16

点击webip–>右键–>start
如果出现错误,webip–>右键–>Migrate Resource–>To node:node1.test.com
–>Force:True
如果仍然错误,webip–>右键–>Clear Migrate Constraints即可;

添加资源–>httpd–>这里使用LSB的httpd脚本–>add即可;

如果用到组:应该先添加组:
Resources– >+–>group–>Resoure ID: webip–>Type–>IPaddr(2)–> Parameters–>ip 192.168.1.101–>Add Parameters –>nic eth0–>cidr_netmask 24
添加资源–>group–>httpd–>这里使用LSB的httpd脚本–>add即可;

将node2.test.com running(dc)右键转为standby将会转移到node1.test.com,刷新网页,将会发生改变

添加nfs文件系统
先停下上面哪个组

#mount -t nfs 192.168.1.105:/web/htdocs /var/www/html
然后
add –>native–>Filesystem–>Resource ID:webstore device 192.168.1.105:/web/htdocs
directory /var/www/html
fstype nfs

应该注意,最后的Resources的排列顺序应该是webip–>webstore–>httpd,这个顺序和resources那种方式定义的顺序是一样的;

如果出现错误,更多是状态信息导致的,可以重新添加;;

通过资源约束使三个独立运行的节点联系到一起
1、定义资源约束
Colocations–>OK–>ID httpd_with_filesystem–>from httpd –>to webstore–>Score INFINITY(正无穷,永远在一起)–>OK

Colocations–>OK–>ID webstore_with_webip–>from webstore –>to webip–>Score INFINITY(正无穷,永远在一起)–>OK
2、定义启动顺序
Orders–>ID webstore_before_httpd–>from httpd –> To webstore
配置好后可看Description
Orders–>ID webip_before–>from httpd –> To webip

设置粘性Default Resource Stickiness,可使默认DC转移到设置的主机上,只要大于0即可;

如果想让某个资源运行到另外一个节点上,那么可以设定位置约束
Locations->add new items item type :localtion –>ID webip_on_node1 Resource:webip–>OK
点击webip_on_node1–>右面–Score : INFIINTY(设定为永远)
Add Expression –>uname eq node1.test.com –Apply
会发现所有资源运行在node1.test.com上;

练习说明:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
yum install pacemaker heartbeat 
#vim /etc/ha.d/ha.cf
mcast eth0 225.0.100.19 694 1 0
crm respawn    || pacemaker respawn
#service heartbeat start
会报错,tail /var/log/messages出现/usr/lib64/heart目录下的一些文件没有执行:
这个是bug,做下面即可;
#ln -s /usr/libexec/pacemaker/cib /usr/lib64/heartbeat/cib
#ln -s /usr/libexec/pacemaker/stonith /usr/lib64/heartbeat/stonithd
#ln -s /usr/libexec/pacemaker/attrd /usr/lib64/heartbeat/attrd
#ln -s /usr/libexec/pacemaker/crmd /usr/lib64/heartbeat/crmd
启动起来了,但是执行crm_mon又失败,没搜出来解决办法。。
[root@node2 ha.d]# crm_mon -1
Could not establish cib_ro connection: Connection refused (111)

Connection to cluster failed: Transport endpoint is not connected

貌似在centos6.5+这个有BUG的…,所以以后做的时候,建议使用heartbeat自带的haresources进行管理;
我在看pacemaker的文档时,都不再涉及heartbeat+pacemaker这种方式,而是使用了corosync+pacemaker这种,所以,建议使用后者;;

更详细可直接参考这篇文章:http://www.linuxidc.com/Linux/2013-08/89167p3.htmhttp://www.cnblogs.com/chinacloud/archive/2010/11/18/1881056.htmlhttp://wolfword.blog.51cto.com/4892126/1210647http://wenku.baidu.com/link?url=71Xs0ZrJ6HehYNlPRfDziVImX4JvP0hM30ZTM9LxBzU0fJw7nnWrqbNE8gaFInnL50byi7-oOX3tR5qNpqJQlYO3nP-5EffJn87tAuPVUSahttp://blog.csdn.net/flcandclf/article/details/14520501http://www.tuicool.com/articles/jM7jiuhttp://www.21ops.com/linux/15178.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值