我是靠谱客的博主 传统朋友,最近开发中收集的这篇文章主要介绍lvs+heartbeat+ldirectord(centos5 测试通过),觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

lvs-primary和lvs-backup服务配置
lvs-primary=>192.168.1.99
lvs-backup=>192.168.1.99
real-server1=>192.168.1.97
real-server2=>192.168.1.188


1、/etc/init.d/lvs
#!/bin/sh
# chkconfig: 2345 90 10
# description: Preparing for Load Balancer and Real Server switching
VIP=192.168.1.88
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo "Preparing for Load Balancer"
ifconfig eth0:1 down
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce
;;
stop)
echo "Preparing for Real Server"
ifconfig eth0:1 $VIP netmask 255.255.255.255 broadcast $VIP up
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
;;
*)
echo "Usage: lvs {start|stop}"
exit 1
esac


2、/etc/sysconfig/ipvsadm
-A -t 192.168.1.88:80 -s rr
-a -t 192.168.1.88:80 -r 192.168.1.97:80 -g
-a -t 192.168.1.88:80 -r 192.168.1.188:80 -g


3、/etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
warntime 10
initdead 120
udpport 694
baud 19200
#serial /dev/ttyS0
#mcast eth0 225.0.0.1 694 1 0
auto_failback on
node lvs-primary
node lvs-backup
ping_group 192.168.1.1 192.168.1.51
respawn root /usr/lib/heartbeat/ipfail
apiauth ipfail gid=root uid=root
bcast eth0


4、/etc/ha.d/haresources
lvs-primary lvs IPaddr::192.168.1.88/24/eth0:0 ipvsadm ldirectord

5、/etc/ha.d/ldirectord.cf
checktimeout=3
checkinterval=1
autoreload=yes
quiescent=yes
# Sample for an http virtual service
virtual=192.168.1.88:80
real=192.168.1.97:80 gate
real=192.168.1.188:80 gate
fallback=127.0.0.1:80 gate
service=http
request="test.html"
receive="Test Page"
scheduler=rr
protocol=tcp

6、/etc/sysconfig/network
HOSTNAME=lvs-primary(备份服务器HOSTNAME=lvs-backup)

最后

以上就是传统朋友为你收集整理的lvs+heartbeat+ldirectord(centos5 测试通过)的全部内容,希望文章能够帮你解决lvs+heartbeat+ldirectord(centos5 测试通过)所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(39)

评论列表共有 0 条评论

立即
投稿
返回
顶部