LVS Heartbeat Ldirectord在Red Hat9.0下的实现

陆 飞(fluzj@21cn.com、fluhzzj@hotmail.com)
杭州市地方税务局西湖征收管理局
2003年9月


2.6.4. Ldirectord 的安装:

一些文章介绍在ipvs-x.x.x.tar.gz中已包含了Ldirectord,估计该作者并没有进入到相关目录中去仔细查看,该目录中只有一 个README文档,告诉您在哪里能够找到Ldirecrtord的代码。总之我在ipvs-1.0.9.tar.gz中是没有看到Ldirectord 源代码。其实他的源代码是包含在heartbeat-1.0.3.tar.gz中的。所以请到这里下载相关代码:http://www.linux-ha.org/download/

源代码安装:


cd heartbeat-1.0.3
./ConfigureMe configure
make
make install.

rpm安装:


rpm -ivh --nodeps heartbeat-ldirectord-1.0.3-1.i386.rpm

能够通过命令:rpm -q heartbeat-ldirecrord -d 来检查安装的路径。

为了简化安装步骤,我安装的是Ldirectord for Red Hat 9的rpm包,RedHat和Debian版本的从这里下载:http://www.ultramonkey.org/download/heartbeat/

注意:

/usr/share/doc/heartbeat-ldirectord-1.0.3/ldirectord.cf文档是Ldirectord的配置文档的范例。拷贝该文档到/etc/ha.d/目录下,修改其内容,并另存为xxx.cf(例如:www.cf,mail.cf),以便在Heartbeat的配置文档haresources中使用。

范例:www.cf(http服务)


#
# Sample ldirectord configuration file to configure various virtual services.
#
# Ldirectord will connect to each real server once per second and request
# /index.html. If the data returned by the server does not contain the
# string "Test Message" then the test fails and the real server will be
# taken out of the available pool. The real server will be added back into
# the pool once the test succeeds. If all real servers are removed from the
# pool then localhost:80 is added to the pool as a fallback measure.

# Global Directives
checktimeout=3
checkinterval=1
fallback=127.0.0.1:80
autoreload=yes
#logfile="/var/log/ldirectord.log"
#logfile="local0"
quiescent=yes

# A sample virual with a fallback that will override the gobal setting
virtual=192.168.7.110:80
real=192.168.7.11:80 gate
real=192.168.7.12:80 gate
real=192.168.7.13:80 gate
fallback=127.0.0.1:80 gate
service=http
request="/.testpage"
receive="Test Page"
scheduler=rr
#persistent=600
#netmask=255.255.255.255
protocol=tcp

然后您必须在每台真实服务器节点的www的根目录上生成以Test Page为内容的.testpage文档。在每台真实服务器节点的www的根目录上执行命令:echo "Test Page" > .testpage

2.6.5. Heartbeat的安装

源代码安装:



cd heartbeat-1.0.3
./ConfigureMe configure
make
make install.

rpm安装:


rpm -ivh --nodeps heartbeat-1.0.3.i386.rpm

为了适应Red Hat 9,我安装的是heartbeat for Red Hat 9的rpm包heartbeat-1.0.3-1.rh.9.1.i386.rpm RedHat和Debian版本rpm的版本从这里下载:http://www.ultramonkey.org/download/heartbeat/

在安装时可能会碰到依赖性的错误,能够用--nodeps参数进行安装。总之把他提示所需要的rpm包(在dependancies目录下)全部装上。在dependancies目录下其他一些其他rpm包,假如不用相关功能能够不装。

配置 Heartbeat

需要配置的有三个文档:ha.cf haresources(在每个节点必须相同) Authkeys,应该将他们放置在/etc/ha.d目录下。范例配置在/usr/shared/doc/heartbeat-1.0.3目录下,您可 以修改后拷贝到/etc/ha.d目录下。

2.6.5.1. 配置ha.cf

这个配置文档告诉heartbeat 使用的是什么介质和如何配置他们。ha.cf 包含您将到的任何的选项,内容如下:

serial /dev/ttyS0

使用串口heartbeat - 假如您不使用串口heartbeat, 您必须选择其他的介质,比如以太网bcast (ethernet) heartbeat。假如您使用其他串口heartbeat,修改/dev/ttyS0 为其他的串口设备。

watchdog /dev/watchdog

可选项:watchdog功能提供了一种方法能让系统在出现故障无法提供"heartbeat"时,仍然具备最小的功能,能在出现故障1分钟后重启 该机器。这个功能能够帮助服务器在确实停止心跳后能够重新恢复心跳。假如您想使用该特性,您必须在内核中装入"softdog" 内核模块用来生成实际的设备文档。想要达到这个目的, 首先输入 "insmod softdog" 加载模块。然后,输入"grep misc /proc/devices" 注意显示的数字 (should be 10). 然后, 输入"cat /proc/misc | grep watchdog" 注意输出显示出的数字(should be 130)。现在您能够生成设备文档使用如下命令:"mknod /dev/watchdog c 10 130" 。

文章整理:西部数码--专业提供域名注册虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!