Chinaunix首页 | 论坛 | 博客
  • 博客访问: 627015
  • 博文数量: 151
  • 博客积分: 4010
  • 博客等级: 上校
  • 技术积分: 1664
  • 用 户 组: 普通用户
  • 注册时间: 2009-08-13 16:37
文章分类

全部博文(151)

文章存档

2010年(16)

2009年(135)

我的朋友

分类: LINUX

2009-11-23 17:20:07

上次实现了最基础的LVS,可这种最基础的LVS不能满足真正的实际应用,为什么呢,因为他的实用性不高,一但后端RS有当机的情况,LB并不会发现,如果后端有3台RS就说明会有1/3的用户会看到出错的页面,所以此次的总结就是为了解决这个问题

实现方式,使用heartbeat中自带的ldirector程序,该程序可以对后端RS进行健康监控,发现有RS服务不可用,则将这台RSserver从列表中删除

环境和上次一样
LVS架构:

             LB-2.187(vip:2.186)
               |      |
              |        |
              |         |
            RS01        RS02
          (2.188)    (2.189)

实现目的:
1,实现roundrobin方式的投递请求
2,进行RS的健康检查

Libnet的安装
可以去下载libnet.tar.gz安装包
下载后进行解压
按默认安装即可
./configure
make && make install

hearbeat安装
可以去下载heartbeat安装包
安装方法也比较简单
解压后按默认安装即可
我使用的

groupadd haclient
useradd -g haclient hacluster

./ConfigureMe configure
make && make install

mkdir -p /etc/ha.d/conf
cd heartbeat-2.1.3/ldirectord
cp .cf /etc/ha.d/conf

到下载对应linux版本的rpm包进行安装,启动需要这些包的支持
perl-TimeDate-1.16-1.2.el4.rf.noarch.rpm
perl-MailTools-2.02-1.el4.rf.noarch.rpm

配置Ldirector
vi /etc/ha.d/conf/ldirectord设置如下内容

# Global Directives
checktimeout=3
checkinterval=1
#fallback=127.0.0.1:80
autoreload=yes
logfile="/var/log/ldirectord.log"
logfile="local0"
#emailalert="admin@x.y.z"
#emailalertfreq=3600
#emailalertstatus=all
quiescent=yes

# Sample for an http virtual service
virtual=192.168.2.186:80
        real=192.168.2.188:80 ipip
        real=192.168.2.189:80 ipip
        service=http
        request="index.html"
        scheduler=rr
        #persistent=600
        #netmask=255.255.255.255
        protocol=tcp
        checktype=negotiate
        checkport=80
        request="index.html"


然后执行/usr/sbin/ldirectord start启动ldirectord服务,可以执行/usr/sbin/ldirectord status查看ldirectord运行状态

/usr/sbin/ldirectord status ldirectord for /etc/ha.d/conf/ldirectord.cf is running with pid: 1522


接下来进行测试,使用软件仍然是webserver stress tool,模拟500了连接
1,正常测试,两台RS服务器正常

ipvsadm
IP Virtual Server version 1.2.0 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.2.186:http rr
  -> 192.168.2.188:http Tunnel 1 0 250
  -> 192.168.2.189:http Tunnel 1 1 250

ipvsadm显示每个RS投递请求各250
来看下websever显示结果:

URL No. Name Clicks Errors Errors [%] Time Spent [ms] Avg. Click Time [ms]
1
251 0 0.00 2,677 11

没有error

2,将任意一台RS80服务关掉

ipvsadm
IP Virtual Server version 1.2.0 (size=4096)
Prot LocalAddress:Port Scheduler Flags
  -> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.2.186:http rr
  -> 192.168.2.188:http Tunnel 0 0 0
  -> 192.168.2.189:http Tunnel 1 0 500

ipvsadm显示结果,已经将所有的请求投递到2.189这个台服务正常的RS上了
来看下Webserver显示结果:

URL No. Name Clicks Errors Errors [%] Time Spent [ms] Avg. Click Time [ms]
1
250 0 0.00 2,658 11

同样没有出现error

到此,一个能用于健康检查的就配置完毕了
关于ldirectord的用法可以到查看,这是ldirectord的manpage页

阅读(828) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~