论坛首页 综合技术论坛

lvs+heartbeat+ldirectord(centos5 测试通过)

浏览 6821 次
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
作者 正文
   发表时间:2007-12-27  
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)
论坛首页 综合技术版

跳转论坛:
Global site tag (gtag.js) - Google Analytics