ubuntu8.04下安装配置lvs-dr

 一.环境

    lvs-dr

    eth0    192.168.1.50

    eth0:1    192.168.1.55(VIP)

    web1

    eth0    192.168.1.51

    lo:0    192.168.1.55(VIP)

    web2

    eth0    192.168.1.52

    lo:0    192.168.1.55(VIP)

    注:所有真实IP必须在同一网段,VIP可以用其他网段

    二.lvs-dr配置

    1)检查内核是否支持ipvs

    modprobe -l | grep “ipvs”

    2)安装ipvsadm

    apt-get install ipvsadm

    3)启用ip转发

    vi /etc/sysctl.conf

    net.ipv4.ip_forward = 1

    4)配置脚本

    vi bin/lvs-dr.sh

    #!/bin/bash

    #description:start lvs_server

    #set lvs

    /sbin/ipvsadm -C

    /sbin/ipvsadm -A -t 192.168.1.55:80 -s rr

    /sbin/ipvsadm -a -t 192.168.1.55:80 -r 192.168.1.51:80 -g -w 1

    /sbin/ipvsadm -a -t 192.168.1.55:80 -r 192.168.1.52:80 -g -w 1

    /etc/init.d/ipvsadm save

    三.WEB配置

    1)配置脚本

    vi bin/lvs-web.sh

    #!/bin/bash

    #Description : RealServer Start!

    #Write by:hugwww

    #Last Modefiy:2009.1.24

    VIP=192.168.1.55

    /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up

    /sbin/route add -host $VIP dev lo: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

    sysctl -p

    #end

    IPVS已实现了以下十种调度算法:

    * 轮叫调度(Round-Robin Scheduling)

    * 加权轮叫调度(Weighted Round-Robin Scheduling)

    * 最小连接调度(Least-Connection Scheduling)

    * 加权最小连接调度(Weighted Least-Connection Scheduling)

    * 基于局部性的最少链接(Locality-Based Least Connections Scheduling)

    * 带复制的基于局部性最少链接(Locality-Based Least Connections with Replication Scheduling)

    * 目标地址散列调度(Destination Hashing Scheduling)

    * 源地址散列调度(Source Hashing Scheduling)

    * 最短预期延时调度(Shortest Expected Delay Scheduling)

    * 不排队调度(Never Queue Scheduling)

    注:WEB服务器可以是windows 2003,windows 2008,win7,linux,freeBSD,UNIX等

转: http://hi.baidu.com/%C2%E4%D1%A9%B5%C4%C9%F9%D2%F4/blog/item/d3067bf975541e1d6c22eb4d.html

你可能感兴趣的:(ubuntu8.04下安装配置lvs-dr)