3rwdq 发表于 2015-12-16 09:02:20

Heartbeat V2版本基于ha-gui做高可用

本帖最后由 3rwdq 于 2015-12-16 09:05 编辑

一、Heartbeat介绍

请点击查看详细介绍
Heartbeat V1版本配置请点击
二、环境准备
1、配置主机名及解析,两台主机相同

1
2
3
4
5
6
# 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.iyunv.com node1
192.168.0.11 node2.iyunv.com node2
192.168.0.13 node3.iyunv.com node3




2、配置双机互信
node1:

1
2
ssh-keygen -t rsa -P ''
ssh-copy-id node2




node2同理
3、关闭防火墙和SELinux

1
2
service iptables stop
setenforce 0




4、主机详情

名称IP安装软件
系统
node1.iyunv.comVIP:192.168.0.18
eth0:192.168.0.10
Heartbeat软件套件CentOS 6.5 x64
最小化安装

node2.iyunv.comVIP:192.168.0.18eth0:192.168.0.11Heartbeat软件套件CentOS 6.5 x64最小化安装
三、Heartbeat V2安装

1、安装依赖包

1
2
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进行安装。

1
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、准备主配置文件

1
cp /usr/share/doc/heartbeat-2.1.4/ha.cf /etc/ha.d/




2、配置主文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 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.iyunv.com
node node2.iyunv.com
ping 192.168.0.1
crm on




3、配置认证文件
    认证文件的权限一定要是600才行,chmod 600 authkeys。

1
2
3
4
5
cp /usr/share/doc/heartbeat-2.1.4/authkeys /etc/ha.d/

# cat /etc/ha.d/authkeys
auth 2
2 sha1 HI!sjdhkashdBD568




4、同步配置文件

1
/usr/lib64/heartbeat/ha_propagate    #次命令是heartbeat提供的同步工具




五、Heartbeat的启动与检查
1、分别启动两节点的服务

1
2
service heartbeat start
ssh node2 'service heartbeat start'




2、状态检查

    crm通过mgmtd进程监听在5560/tcp

# crm_mon

    可以看到两节点都是online,如果显示的是OFFLINE,可以尝试重启一下heartbeat。
五、ha_gui图形管理启动

1、图形界面程序安装
安装成功之后可能不能生效,请退出一下XShell重新进入即可。

1
yum install xorg-x11-xauth -y




    如果你还是有各种问题,那可以直接安装桌面系统,肯定没有问题。

1
yum groupinstall Desktop




2、设置管理用户密码


1
2
3
4
5
6
7
# 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、启动图形配置管理

1
# hb_gui







六、配置WEB服务高可用
1、两台设备同时安装httpd


1
yum install httpd -y




    设定好测试页面,我这里不再进行演示。

2、配置VIP





3、配置HTTP服务




4、启动服务



5、检查是否启动成功



6、测试故障






注:因为我使用的不是共享存储,所以数据显示不一样,后面我们可以添加共享存储NFS,也比较简单。

7、添加NFS存储演示
    假设我们的NFS服务器是192.168.0.13 共享目录是/web。






七、小结

    通过图形界面配置起来很简单,我这里只是演示一个方法,知道其中一个资源怎么配置就可以联想到其他的资源如何配置。
    比如配置位置约束、排列约束、顺序约束,比如我们刚才的VIP和HTTP,正常来说我们是应该先启动VIP,然后在启动HTTP,如果加上NFS存储,那就必须先启动VIP,然后挂载文件系统,然后在启动WEB服务。
    根据HTTP+NFS的WEB高可用,我们也可以很简单设置NFS+Mysql的数据库高可用,通过ldirector可以配置lvs的高可用等等,配置方法都是差不多的,我这里不再一一介绍。




页: [1]
查看完整版本: Heartbeat V2版本基于ha-gui做高可用