RedHat下隧道模式的负载均衡

首先:隧道模式的负载均衡的工作原理:客户机访问director机,director机将客户端的请求发送到真实服务器,然后真实服务器将请求应回应的结果直接回应给客户机。真实服务器间可以是不通网段--即各服务器之间可以夸网。    这种方式不仅减轻director机的压力,效率高,还能在空间上得到运用。但在中国似乎暂时行不通(因为很少有企业用过...)。一般适用于大中型企业。

实验环境: 两台主机服务器:192.168.0.11   和  192.168.0.12
                     中转机: 192.168.0.13  和  192.168.0.19
                     客户机:192.168.0.10
            (主机名要跟IP保存一致。iptables要清空--iptables -F 。selinux 关闭)

实验步骤:
A.服务器:
    1。192.168.0.11
        # yum install -y httpd
        # service httpd start
        # echo "192.168.0.11" >/var/www/html/index.html
        # route add default gw 192.168.0.13
        # vim /etc/init.d/shutarp
            -------------------------------
            #!/bin/sh
            VIP=192.168.0.19

. /etc/rc.d/init.d/functions

case "$1" in
            start)
                echo "Tunl port starting"
                ifconfig tunl0 $VIP netmask 255.255.255.255 broadcast $VIP up
                /sbin/route add -host $VIP dev tunl0
                echo "1" >/proc/sys/net/ipv4/conf/tunl0/arp_ignore
                echo "2" >/proc/sys/net/ipv4/conf/tunl0/arp_announce
                echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
                echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
                sysctl -p

;;
            stop)
                echo "Tunl port closing"
                ifconfig tunl0 down
                echo 1 > /proc/sys/net/ipv4/ip_forward
                echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
                   ;;
                *)
            echo "Usage: $0 {start|stop}"
            exit 1
        esac
            -------------------------------
        # service shutarp start
    2。192.168.0.12
        # yum install -y httpd
        # service httpd start
        # echo "192.168.0.12" >/var/www/html/index.html
        # route add default gw 192.168.0.13
        # vim /etc/init.d/shutarp
            -------------------------------
            #!/bin/sh
            VIP=192.168.0.19

. /etc/rc.d/init.d/functions

case "$1" in
                start)
                    echo "Tunl port starting"
                    ifconfig tunl0 $VIP netmask 255.255.255.255 broadcast $VIP up
                    /sbin/route add -host $VIP dev tunl0
                    echo "1" >/proc/sys/net/ipv4/conf/tunl0/arp_ignore
                    echo "2" >/proc/sys/net/ipv4/conf/tunl0/arp_announce
                    echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
                    echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
                    sysctl -p

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyddgs.html