RedHat下直接路由模式的负载均衡(2)

. /etc/rc.d/init.d/functions
   
                case "$1" in
                            start)
                            echo "start LVS of DS"
                            /sbin/ifconfig eth0:0 $VIP broadcast $VIP netmask                                     255.255.255.0 up
                            /sbin/route add -host $VIP dev eth0:0
                            /sbin/ipvsadm -C
                            /sbin/ipvsadm -A -t $VIP:80 -s rr
                            /sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -g
                            /sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -g
                            /sbin/ipvsadm
                                   ;;
                                stop)
                            echo "close LVS Directorserver"
                            /sbin/ipvsadm -C
                                ;;
                        *)
                    echo "Usage: $0 {start|stop}"
                    exit 1
                esac
                ---------------------------------
        # service lvsDR start   (执行脚本)

# vim /bin/shutarp
            -------------------------------
            #!/bin/bash
            VIP=192.168.0.19
            /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
            -------------------------------
        # shutarp

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

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