原文:http://www.weiruoyu.cn/?p=700

来源:http://88fly.blog.163.com/blog/static/122680390201101042825766/

http://book.51cto.com/art/200807/82012.htm (ldirectord单独讲)

参考上面的先做实验。

安装所需要的软件
yum install ipvsadm
yum install heartbeat (这个需要安装两遍,我在centos5.6上测试的)
yum install heartbeat-ldirectord

chkconfig --add heartbeat

复制配置文件到/etc/ha.d

cp -rf/usr/share/doc/heartbeat-2.1.3/ha.cf /etc/ha.d
cp
-rf /usr/share/doc/heartbeat-2.1.3/authkeys /etc/ha.d
cp
-rf/usr/share/doc/heartbeat-2.1.3/haresources /etc/ha.d
cp
-rf/usr/share/doc/heartbeat-ldirectord-2.1.3/ldirectord.cf /etc/ha.d



错误解决:

1.

[root@localhost ~]# /etc/init.d/ipvsadm start
Clearing the current IPVS table:[确定]
Applying IPVS configuration: /etc/init.d/ipvsadm: line 62: /etc/sysconfig/ipvsadm: 没有那个文件或目录
注:遇到这个错误。运行service ipvsadm save。之后再执行service ipvsadm start
2.

ApplyingIPVS configuration: /sbin/ipvsadm-restore: line 25: echo: write error:Permission denied

或运行 service ipvsadm save 后没有把虚拟服务表内容保存到 /etc/sysconfig/ipvsadm

问题原因:开启了selinux

解决方法:关闭selinux , /etc/sysconfig/selinux SELINUX=enforcing 改为 SELINUX=disabled ,并重启系统

安装:heartbeat (centos5.X)

yum -y install heartbeat

安装 ldirectord

yum -y install heartbeat-ldirectord

(这个命令不太确定)

位置有些略微变化:/usr/share/doc/heartbeat-ldirectord-2.1.3/ldirectord.cf


报错:

1。[root@localhost ~]# service ldirectord start
/etc/init.d/ldirectord: line 33: /etc/ha.d/shellfuncs: 没有那个文件或目录

解决办法:

默认启动不了ldirectord,需要修改/etc/rc.d/init.d/ldirectord

注释掉该行: . /etc/ha.d/shellfuncs

参考:http://starsliao.blog.163.com/blog/static/8904820115151175061/


以上是做:Ldirectord 和lvs的结合,但是参考这篇文章做得这个Ldirectord没有发挥效应。

2.下面这个错误折磨了我2天,很郁闷

其实是不会搜,搜索 heartbeat ERROR: Current node not in configuration! 这个就可以。

[root@localhost ha.d]# service heartbeat start
logd is already running
Starting High-Availability services:
2011/11/04_16:23:50 INFO: Resource is stopped
[失败]
heartbeat: udpport setting must precede media statementsheartbeat: baudrate setting must precede media statementsheartbeat[6633]: 2011/11/04_16:23:50 info: Version 2 support: false
heartbeat[6633]: 2011/11/04_16:23:50 ERROR: Current node [localhost.localdomain] not in configuration!
heartbeat[6633]: 2011/11/04_16:23:50 info: By default, cluster nodes are named by `uname -n` and must be declared with a 'node' directive in the ha.cf file.
heartbeat[6633]: 2011/11/04_16:23:50 info: See also: http://linux-ha.org/ha.cf/NodeDirective
heartbeat[6633]: 2011/11/04_16:23:50 WARN: Logging daemon is disabled --enabling logging daemon is recommended
heartbeat[6633]: 2011/11/04_16:23:50 ERROR: Configuration error, heartbeat not started.

其实这个错误是很容易解决的,我没有仔细去看错误报告,报告说的很清楚

By default, cluster nodes are named by `uname -n` and must be declared with a 'node' directive in the ha.cf file.

不会英文也能看个大概。

错误原因是node的名称不对,用‘uname -n’查看主机也就是node使用的名字

vi /etc/ha.d/ha.cf

把node对应的主机修改成主节点(主节点也就是做负载均衡的主机名称,叫法不一样而已)

node localhost.localdomain

感谢这篇文章:http://blog.chinaunix.net/space.php?uid=305417&do=blog&id=2133641


3.下面是关于防火墙的,以后会用到。

五】 HA服务的启动、关闭以及测试
=================================================
启动HA: service heartbeat start
关闭HA; service heartbeat stop
启动的时候总是有这个提示:
[root@VM ~]# /etc/init.d/heartbeat start
logd is already running
Starting High-Availability services:
2010/01/22_06:23:31 INFO: Resource is stopped
不知道是不是就应该这样。
如果修改了配置文件,/etc/init.d/reload.。
不过出了如下的报错信息
[root@VM ~]# /etc/init.d/heartbeat reload
Reloading High-Availability services:
heartbeat: udpport setting must precede media statementsheartbeat: baudrate setting must precede media statementsheartbeat[3978]: 2010/01/22_06:55:49 info: Version 2 support: false
heartbeat[3978]: 2010/01/22_06:55:49 WARN: Logging daemon is disabled --enabling logging daemon is recommended
heartbeat[3978]: 2010/01/22_06:55:49 info: Signalling heartbeat pid 2890 to reread config files
[确定]

【六】 防火墙设置
====================================================
heartbeat 默认使用udp 694端口进行心跳监测。 如果系统有使用iptables 做防火墙,应记住把这个端口打开。
#vi /etc/sysconfig/iptables
加入以下内容
-A RH-Firewall-1-INPUT -p udp -m udp --dport 694 -d 10.0.0.201 -j ACCEPT
意思是udp 694端口对 对方的心跳网卡地址 10.0.0.201 开放。
#service iptables restart
重新加载iptables。

=================================================================

CentOS5.5下Heartbeat+LVS(VS/DR)+Ldirectord分步骤实验

http://cyent.blog.51cto.com/905592/507594



http://kk5234.blog.51cto.com/1006247/562621




http://88fly.blog.163.com/blog/static/122680390201101042825766/

博客专题:https://blog.51cto.com/zt/11

下面是我收集关于这方面的实验,不过看的多了,发现每个人跟每个人都不太一样,不过通过阅读他们发现了好多共同点

http://cyent.blog.51cto.com/905592/507594

http://shenjianzhousx.blog.51cto.com/1627247/440506

http://linux008.blog.51cto.com/2837805/538369

http://xjsunjie.blog.51cto.com/999372/670706