LVS与heartbeat的组合on rhel5
2010-09-19 14:18:43| 分类: 双机/集群 | 标签: |字号大中小 订阅
服务器:2台, 都具有双网卡,一块用于连接到网络,一块用于双机互连。
心跳线:特殊的串口线,用于串口信息的检测。
网线:交叉网线,用于双机互连的。支持heartbeat的UDP协议通讯。
建议先安装以上除heartbeat、libnet之外的其他软件包,然后安装heartbeat、libnet.
heartbeat的配置有以下三个文件,它们是:
ha.cf 主要配置文件
haresources 资源配置文件
authkeys 关于认证信息
checkinterval=1 #检查时间间隔1s
autoreload=yes #配置文件改变时自动加载配置文件
logfile="/var/log/ldirectord.log" #定义日志文件
quiescent=yes
virtual=192.168.1.70:80 #虚拟IP
real=192.168.1.50:80 gate #realserver server5
real=192.168.1.71:80 gate #realserver server7
fallback=127.0.0.1:80 #所有服务器发生故障时访问该服务器
service=http #服务名称
scheduler=rr #我这里使用的直连路由调度算法
protocol=tcp
checktype=negotiate
logfile /var/log/ha-log #同上
logfacility local0 #默认
keepalive 2 #设定heartbeat之间的时间间隔为2秒.
deadtime 30 #在30秒后宣布节点死亡。
warntime 10 #在日志中发出“late heartbeat“警告之前等待的时间,单位为秒。
initdead 120 #在某些配置下,重启后网络需要一些时间才能正常工作。这个单独的”deadtime”选项可以处理这种情况。它的取值至少应该为通常deadtime的两倍。
udpport 694 # 使用端口694进行bcast和ucast通信。这是默认的,并且在IANA官方注册的端口号。
bcast eth1 # Linux 表示在eth1接口上使用广播heartbeat(将eth1替换为eth0,eth2),或者您使用的任何接口。
mcast eth0 225.0.0.1 694 1 0 #默认即可
ucast eth0 192.168.1.30 #改为你eth0的地址。
auto_failback on #该选项是必须配置的。值为on or off
node server3.rhel5.net #负载均衡服务器名,必须与uname -n的输出一致。
node server4.rhel5.net #同上
ping 10.0.0.1
respawn hacluster /usr/lib/heartbeat/ipfail
apiauth ipfail gid=haclient uid=hacluster
3 md5 test
net.ipv4.conf.eth0.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
net.ipv4.conf.eth0.arp_announce = 2
inet addr:192.168.1.30 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe8e:5205/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:113693 errors:0 dropped:0 overruns:0 frame:0
TX packets:137301 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:12951968 (12.3 MiB) TX bytes:11335533 (10.8 MiB)
Interrupt:169 Base address:0x2000
inet addr:192.168.1.70 Bcast:192.168.1.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:169 Base address:0x2000
inet addr:10.0.0.2 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::20c:29ff:fe8e:520f/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:3680 errors:0 dropped:0 overruns:0 frame:0
TX packets:3853 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:720033 (703.1 KiB) TX bytes:748019 (730.4 KiB)
Interrupt:193 Base address:0x2080
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3982 errors:0 dropped:0 overruns:0 frame:0
TX packets:3982 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:1010816 (987.1 KiB) TX bytes:1010816 (987.1 KiB)
eth0 Link encap:Ethernet HWaddr 00:0C:29:FF:1A:AB
inet addr:192.168.1.40 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:feff:1aab/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2983 errors:0 dropped:0 overruns:0 frame:0
TX packets:4766 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:617725 (603.2 KiB) TX bytes:1118790 (1.0 MiB)
Interrupt:169 Base address:0x2000
inet addr:10.0.0.1 Bcast:10.255.255.255 Mask:255.0.0.0
inet6 addr: fe80::20c:29ff:feff:1ab5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4135 errors:0 dropped:0 overruns:0 frame:0
TX packets:4070 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:813997 (794.9 KiB) TX bytes:790753 (772.2 KiB)
Interrupt:193 Base address:0x2080
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:3374 errors:0 dropped:0 overruns:0 frame:0
TX packets:3374 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:431408 (421.2 KiB) TX bytes:431408 (421.2 KiB)
master running
(ipvs_syncmaster pid: 9132)
[root@server3 ~]# /etc/ha.d/resource.d/LVSSyncDaemonSwap backup status
backup stopped
(ipvs_syncmaster pid: 9132)
master stopped
(ipvs_syncbackup pid: 5830)
backup running
(ipvs_syncbackup pid: 5830)
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 192.168.1.70:80 rr
-> 192.168.1.50:80 Route 1 0 0
-> 192.168.1.71:80 Route 1 0 0
echo "1">/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2">/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1">/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2">/proc/sys/net/ipv4/conf/all/arp_announce
ifconfig lo:0 192.168.1.70 broadcast 192.168.1.70 netmask 255.255.255.255 up
route add -host 192.168.1.70 dev lo:0
sysctl -p
inet addr:192.168.1.70 Mask:255.255.255.255
UP LOOPBACK RUNNING MTU:16436 Metric:1
IPVS connection entries
pro expire state source virtual destination
TCP 01:52 FIN_WAIT 192.168.1.156:4204 192.168.1.70:80 192.168.1.71:80
TCP 01:53 FIN_WAIT 192.168.1.156:4207 192.168.1.70:80 192.168.1.71:80
TCP 01:51 FIN_WAIT 192.168.1.156:4203 192.168.1.70:80 192.168.1.50:80
TCP 01:53 FIN_WAIT 192.168.1.156:4208 192.168.1.70:80 192.168.1.50:80
TCP 01:50 FIN_WAIT 192.168.1.156:4202 192.168.1.70:80 192.168.1.71:80
TCP 01:53 FIN_WAIT 192.168.1.156:4205 192.168.1.70:80 192.168.1.50:80