Heartbeat V2版本基于ha
一、Heartbeat介绍请点击查看详细介绍
Heartbeat V1版本配置请点击
二、环境准备
1、配置主机名及解析,两台主机相同
# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.10 node1.wzlinux.com node1
192.168.0.11 node2.wzlinux.com node2
192.168.0.13 node3.wzlinux.com node3 2、配置双机互信
node1:
ssh-keygen -t rsa -P ''
ssh-copy-id node2 node2同理
3、关闭防火墙和SELinux
service iptables stop
setenforce 0 4、主机详情
名称IP安装软件
系统node1.wzlinux.com VIP:192.168.0.18
eth0:192.168.0.10
Heartbeat软件套件 CentOS 6.5 x64
最小化安装
node2.wzlinux.comVIP:192.168.0.18
eth0:192.168.0.11
Heartbeat软件套件CentOS 6.5 x64
最小化安装
三、Heartbeat V2安装
1、安装依赖包
yum install perl-TimeDate net-snmp-libs libnet PyXML
yum install libtool-ltdl-devel gettext pygtk2-libglade 2、安装heartbeat组件
大家可以去网上下载相关的rpm软件包,也可以从我的附件里面下载,因为CentOS 6.5的原因,我们这里不能进行yum安装,因为会冲突,所以这里使用rpm进行安装。
rpm -ivh heartbeat-2.1.4-12.el6.x86_64.rpm heartbeat-pils-2.1.4-12.el6.x86_64.rpm heartbeat-gui-2.1.4-12.el6.x86_64.rpm heartbeat-stonith-2.1.4-12.el6.x86_64.rpm 四、Heartbeat的配置
我这里的配置都是比较简单的,没有仔细说明每个参数的意义,如果需要查看详细介绍请点击上面的V1版本的设置,如果没有特殊说明,所有的操作都是在Node1上面执行的。
1、准备主配置文件
cp /usr/share/doc/heartbeat-2.1.4/ha.cf /etc/ha.d/ 2、配置主文件
# cat /etc/ha.d/ha.cf
logfile /var/log/ha-log
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
baud 19200
mcast eth0 225.0.100.1 694 1 0
auto_failback on
node node1.wzlinux.com
node node2.wzlinux.com
ping 192.168.0.1
crm on 3、配置认证文件
认证文件的权限一定要是600才行,chmod 600 authkeys。
cp /usr/share/doc/heartbeat-2.1.4/authkeys /etc/ha.d/
# cat /etc/ha.d/authkeys
auth 2
2 sha1 HI!sjdhkashdBD568 4、同步配置文件
/usr/lib64/heartbeat/ha_propagate #次命令是heartbeat提供的同步工具 五、Heartbeat的启动与检查
1、分别启动两节点的服务
service heartbeat start
ssh node2 'service heartbeat start' 2、状态检查
crm通过mgmtd进程监听在5560/tcp
http://s1.运维网.com/wyfs02/M00/77/DA/wKioL1ZvxKmD2vVEAACFiGmik9E536.jpg
# crm_mon
http://s5.运维网.com/wyfs02/M00/77/DB/wKiom1ZvvhWjRsu_AAB4_2uQ2Lc168.jpg
可以看到两节点都是online,如果显示的是OFFLINE,可以尝试重启一下heartbeat。
五、ha_gui图形管理启动
1、图形界面程序安装
安装成功之后可能不能生效,请退出一下XShell重新进入即可。
yum install xorg-x11-xauth -y 如果你还是有各种问题,那可以直接安装桌面系统,肯定没有问题。
yum groupinstall Desktop 2、设置管理用户密码
# passwd hacluster
Changing password for user hacluster.
New password:
BAD PASSWORD: it is too simplistic/systematic
BAD PASSWORD: is too simple
Retype new password:
passwd: all authentication tokens updated successfully. 3、启动图形配置管理
# hb_guihttp://s5.运维网.com/wyfs02/M02/77/DB/wKioL1Zv0GahdVVRAACN9qqtdDg324.jpg
http://s3.运维网.com/wyfs02/M02/77/DC/wKiom1Zv0F_w1VQ6AADBP2DkhaQ781.jpg
六、配置WEB服务高可用
1、两台设备同时安装httpd
yum install httpd -y 设定好测试页面,我这里不再进行演示。
2、配置VIP
http://s5.运维网.com/wyfs02/M00/77/DB/wKioL1Zv1QShrnYtAACjXX3dCL0039.jpg
http://s4.运维网.com/wyfs02/M01/77/DB/wKioL1Zv1QTSDiijAACct18Jyjs411.jpg
http://s4.运维网.com/wyfs02/M00/77/DC/wKiom1Zv1P3jxm75AACo1sP50t8973.jpg
http://s5.运维网.com/wyfs02/M01/77/DB/wKioL1Zv1QbSrlwmAAEmAvYABZo461.jpg
3、配置HTTP服务
http://s1.运维网.com/wyfs02/M01/77/DC/wKiom1Zv1P_BRJzPAADcYtuYOwI382.jpg
http://s1.运维网.com/wyfs02/M02/77/DB/wKioL1Zv1Qfju_odAADOHavKTWw413.jpg
http://s5.运维网.com/wyfs02/M02/77/DC/wKiom1Zv1QDSjZqRAAEQ4ocbBXg459.jpg
4、启动服务
http://s2.运维网.com/wyfs02/M02/77/DC/wKiom1Zv1QGAlJgCAADmoSIp7Xc277.jpg
http://s2.运维网.com/wyfs02/M00/77/DB/wKioL1Zv1Qmg584UAADhPdJdTac776.jpg
http://s3.运维网.com/wyfs02/M01/77/DC/wKioL1Zv2uyxaxyFAAC9VngKvo0415.jpg
5、检查是否启动成功
http://s5.运维网.com/wyfs02/M02/77/DB/wKioL1Zv1QrT9nIcAAEbLg0VMnI446.jpg
http://s3.运维网.com/wyfs02/M00/77/DB/wKioL1Zv1bvDSkiRAAA1Xo25kyA975.jpg
6、测试故障
http://s1.运维网.com/wyfs02/M01/77/DB/wKioL1Zv1nPCnOkaAADOOwHhTwM224.jpg
http://s2.运维网.com/wyfs02/M01/77/DC/wKiom1Zv1m3Asg13AADDd2SY25g257.jpg
http://s2.运维网.com/wyfs02/M02/77/DB/wKioL1Zv1nXx_ze7AAD-SYJF6-4892.jpg
http://s2.运维网.com/wyfs02/M02/77/DC/wKiom1Zv1m7TPJrNAAA1yrYiGRg357.jpg
注:因为我使用的不是共享存储,所以数据显示不一样,后面我们可以添加共享存储NFS,也比较简单。
7、添加NFS存储演示
假设我们的NFS服务器是192.168.0.13 共享目录是/web。
http://s1.运维网.com/wyfs02/M02/77/DD/wKiom1Zv2RKBDpq7AADolWTXSwI914.jpg
http://s1.运维网.com/wyfs02/M00/77/DC/wKioL1Zv2RrQ_YkpAADV1qnLttM390.jpg
http://s4.运维网.com/wyfs02/M00/77/DD/wKiom1Zv2RSigEX8AADjweM2mZc644.jpg
http://s4.运维网.com/wyfs02/M01/77/DC/wKioL1Zv2RzCU_E2AADrwwaQ8wA274.jpg
七、小结
通过图形界面配置起来很简单,我这里只是演示一个方法,知道其中一个资源怎么配置就可以联想到其他的资源如何配置。
比如配置位置约束、排列约束、顺序约束,比如我们刚才的VIP和HTTP,正常来说我们是应该先启动VIP,然后在启动HTTP,如果加上NFS存储,那就必须先启动VIP,然后挂载文件系统,然后在启动WEB服务。
根据HTTP+NFS的WEB高可用,我们也可以很简单设置NFS+Mysql的数据库高可用,通过ldirector可以配置lvs的高可用等等,配置方法都是差不多的,我这里不再一一介绍。
附件:http://down.运维网.com/data/2367182
页:
[1]