Heartbeat+Apache的HA测试报告

1        简要说明

本文档主要目的是在Redhat6.5Linux上测试heartbeat3.0.4-2和Apache的高可用。系统配置信息如下:

 

主机

备机

IP

192.168.2.101

192.168.2.102

机器名

lvs1

lvs2

VIP

192.168.2.100

操作系统

Red Hat Enterprise Linux Server release 6.5 (Santiago)

Red Hat Enterprise Linux Server release 6.5 (Santiago)

heartbeat版本

heartbeat-3.0.4-2.el6.x86_64

heartbeat-3.0.4-2.el6.x86_64

2        软件安装

heartbeat对应的包不是系统自带的包,需要独立下载,可以去http://rpmfind.net/linux/rpm2html/search.php这个网站查找,我们需要以下几个包:

heartbeat-3.0.4-2.el6.x86_64.rpm、heartbeat-libs-3.0.4-2.el6.x86_64.rpm、heartbeat-devel-3.0.4-2.el6.x86_64.rpm

另外,需要提前准备好两个节点的hosts文件:

[root@lvs1 heartbeat-3.0.4]#cat /etc/hosts

127.0.0.1   localhost

192.168.2.101 lvs1

192.168.2.102 lvs2

192.168.2.100 lvs-vip

由于软件的安装还依赖其他的一些系统包,建议配置一个本地的yum源,我的配置文件如下:

[root@lvs1 soft]# cat/etc/yum.repos.d/local.repo

[Server]

name=Server

baseurl=file:///mnt/Server

enabled=1

gpgcheck=0

 

[HighAvailability]

name=HighAvailability

baseurl=file:///mnt/HighAvailability

enabled=1

gpgcheck=0

 

[LoadBalancer]

name=LoadBalancer

baseurl=file:///mnt/LoadBalancer

enabled=1

gpgcheck=0

这些准备工作都做好了,就是软件的安装,我的rpm包存放在/soft目录下,安装命令如下:

[root@lvs1 /]# cd /soft

[root@lvs1 soft]# yum localinstall*.rpm -y

......此处省略一些输出

 

Installed:

  heartbeat.x86_64 0:3.0.4-2.el6   heartbeat-devel.x86_64 0:3.0.4-2.el6   heartbeat-libs.x86_64 0:3.0.4-2.el6 

 

Dependency Installed:

  PyXML.x86_64 0:0.8.4-19.el6                             cluster-glue.x86_640:1.0.5-6.el6                   

  cluster-glue-libs.x86_64 0:1.0.5-6.el6                  perl-TimeDate.noarch1:1.16-11.1.el6                

  resource-agents.x86_64 0:3.9.2-40.el6                 

 

Complete!

安装完成后,在/etc/init.d/就会有heartbeat启动脚本。

3        配置heartbeat

heartbeat主要有三个配置文件:authkeys、ha.cf、haresources。可以从/usr/share/doc/heartbeat-3.0.4目录拷贝这三个文件的模板。编辑后的lvs1和lvs2的配置文除ha.cf不同外,其他两个文件相同:

cd/usr/share/doc/heartbeat-3.0.4

cp ha.cf authkeys haresources/etc/ha.d/

cd /etc/ha.d

[root@lvs1 ha.d]# grep -v"#" ha.cf

logfile /var/log/ha-log

logfacility     local0

keepalive 2

deadtime 30

warntime 10

initdead 120

udpport 694

ucast eth0 192.168.2.102

auto_failback on

node    lvs1

node    lvs2

ping 192.168.2.111

respawn hacluster/usr/lib64/heartbeat/ipfail

 

 

[root@lvs2 ha.d]# grep -v"#" ha.cf

logfile /var/log/ha-log

logfacility     local0

keepalive 2

deadtime 30

warntime 10

initdead 120

udpport 694

ucast eth0 192.168.2.101

auto_failback on

node    lvs1

node    lvs2

ping 192.168.2.111

respawn hacluster /usr/lib64/heartbeat/ipfail

 

[root@lvs1 ha.d]# grep -v"#" haresources

lvs1 IPaddr::192.168.2.100httpd

 

[root@lvs2 ha.d]# grep -v"#" haresources

lvs1 IPaddr::192.168.2.100httpd

 

[root@lvs1 ha.d]# chmod 600authkeys <---权限要求是600

[root@lvs1 ha.d]# grep -v"#" authkeys

auth 1

1 crc

4        配置apache

由于只是测试,apache的配置非常简单,只需要修改Listen参数即可:

vi /etc/httpd/conf/httpd.conf

Listen 192.168.2.100:80

5        测试

为了测试分别为lvs1和lvs2写了一个index.html页面,将对应的文件放到/var/www/html目录下。对应内容如下:

[root@lvs1 ha.d]# cat /var/www/html/index.html

<html>

<head>lvs1</head>

<body>

welcome from lvs1 by cdshrewd

</body>

</html>

 

[root@lvs2 ha.d]# cat/var/www/html/index.html

<html>

<head>lvs2</head>

<body>

welcome from lvs2 by cdshrewd

</body>

</html>

测试步骤:

1.        主节点正常

启动两个节点的heartbeat,/etc/init.d/heartbeatstart


打开浏览器访问:http://192.168.2.100/index.html

2.        主节点heartbeat关闭

在lvs1上关闭heartbeat,/etc/init.d/heartbeatstop


再次访问http://192.168.2.100/index.html

说明资源已经切到备节点。

3.        恢复主节点

在lvs1上重新启动heartbeat,/etc/init.d/heartbeatstart

再次访问http://192.168.2.100/index.html

说明自动回切已生效。至此,heartbeat和apache的HA测试结束。

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

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值