免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 5530 | 回复: 4
打印 上一主题 下一主题

lvs 配置多个虚拟IP [复制链接]

论坛徽章:
1
处女座
日期:2014-01-14 13:59:48
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2013-09-11 20:08 |只看该作者 |倒序浏览
keepalived.conf配置如下:
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 101
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
    xxx.xxx.87.209
        }
}

virtual_server xxx.xxx.87.209 80 {
    delay_loop 6
    lb_algo lc
    lb_kind DR
    nat_mask 255.255.255.255
    persistence_timeout 0
    protocol TCP


    real_server xxx.xxx.87.213 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

    real_server xxx.xxx.87.211 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

}


vrrp_instance VI_2 {
    state MASTER
    interface eth0
    virtual_router_id 52
    priority 101
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
    xxx.xxx.89.26
        }
}


virtual_server xxx.xxx.89.26 80 {
    delay_loop 6
    lb_algo lc
    lb_kind DR
    nat_mask 255.255.255.255
    persistence_timeout 0
    protocol TCP


    real_server xxx.xxx.89.51 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

    real_server xxx.xxx.89.52 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }




}

realserver.sh如下:
#!/bin/bash
VIP=xxx.xxx.87.209
VIP_2=xxx.xxx.89.26
case "$1" in
start )
/sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/ifconfig lo:1 ${VIP_2} broadcast ${VIP_2} netmask 255.255.255.255 up
/sbin/route add -host $VIP dev lo:0
/sbin/route add -host ${VIP_2} dev lo:1
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
echo "realserver start"
;;
stop )/sbin/ifconfig lo:0 down
/sbin/ifconfig lo:1 down
/sbin/route del -host $VIP
/sbin/route del -host ${VIP_2}
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
echo "realserver stop"
;;
* )
echo "argment is wrong"
exit 1
esac
exit 0

MASER上有一块网卡绑定的IP为:xxx.xxx.87.212
现在是telnet xxx.xxx.87.209 80 是通的,不过telnet xxx.xxx.89.26 80 就是不通,不知道为什么,请大家指点。

论坛徽章:
1
处女座
日期:2014-01-14 13:59:48
2 [报告]
发表于 2013-09-11 20:23 |只看该作者
自己先回一下。

论坛徽章:
1
处女座
日期:2014-01-14 13:59:48
3 [报告]
发表于 2013-09-12 09:18 |只看该作者
哎!也没有人回

论坛徽章:
0
4 [报告]
发表于 2013-10-14 11:30 |只看该作者
我想应该是realserver上的两个对应的vip必须分开写。
参考链接:http://blog.chinaunix.net/uid-23916356-id-3506943.html

论坛徽章:
1
IT运维版块每日发帖之星
日期:2015-12-27 06:20:00
5 [报告]
发表于 2013-11-20 19:43 |只看该作者
keepalived.conf配置如下:
! Configuration File for keepalived

global_defs {
   notification_email {
     acassen@firewall.loc
     failover@firewall.loc
     sysadmin@firewall.loc
   }
   notification_email_from Alexandre.Cassen@firewall.loc
   smtp_server 127.0.0.1
   smtp_connect_timeout 30
   router_id LVS_DEVEL
}

vrrp_instance VI_1 {
    state MASTER
    interface eth0
    virtual_router_id 51
    priority 101
    advert_int 1
    authentication {
        auth_type PASS
        auth_pass 1111
    }
    virtual_ipaddress {
    xxx.xxx.87.209
    xxx.xxx.89.26
        }
}

virtual_server xxx.xxx.87.209 80 {
    delay_loop 6
    lb_algo lc
    lb_kind DR
    nat_mask 255.255.255.255
    persistence_timeout 0
    protocol TCP


    real_server xxx.xxx.87.213 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

    real_server xxx.xxx.87.211 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

}

virtual_server xxx.xxx.89.26 80 {
    delay_loop 6
    lb_algo lc
    lb_kind DR
    nat_mask 255.255.255.255
    persistence_timeout 0
    protocol TCP


    real_server xxx.xxx.89.51 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }

    real_server xxx.xxx.89.52 80 {
        weight 1
        TCP_CHECK {
            connect_timeout 3
            nb_get_retry 3
            delay_before_retry 3
            connect_port 80
        }
    }
}

这样配置keepalived试一下。


   
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP