Chinaunix首页 | 论坛 | 博客
  • 博客访问: 958270
  • 博文数量: 99
  • 博客积分: 3306
  • 博客等级: 中校
  • 技术积分: 1238
  • 用 户 组: 普通用户
  • 注册时间: 2009-04-21 10:14
文章分类

全部博文(99)

文章存档

2012年(37)

2011年(56)

2010年(6)

分类: LINUX

2011-12-29 19:10:57

做HA的时候,如果每个机器上同时需要监听多个IP的同一个端口。那么肯定是需要写死监听的IP和端口。
比如在haproxy里面:

  1. frontend free
  2.         bind 10.17.10.4:80
  3.         default_backend test1
  4. frontend free
  5.         bind 10.17.10.5:80
  6.         default_backend test2


backend test1
        mode http
        balance leastconn
        option  httpchk
        cookie SERVERID insert indirect  nocache maxidle 10m maxlife 8h
        option forwardfor header ORIG_CLIENT_IP
        option  httpclose
        server  free174 10.253.4.16:8080 weight 10 rise 3 fall 5 check inter 2000 cookie apm1174
        server  free173 10.253.4.15:8080 weight 10 rise 3 fall 5 check inter 2000 cookie apm1173


backend test2
        mode http
        balance leastconn
        option  httpchk
        cookie SERVERID insert indirect  nocache maxidle 10m maxlife 8h
        option forwardfor header ORIG_CLIENT_IP
        option  httpclose
        server  free174 10.253.3.16:8080 weight 10 rise 3 fall 5 check inter 2000 cookie apm1174
        server  free173 10.253.3.15:8080 weight 10 rise 3 fall 5 check inter 2000 cookie apm1173

主机和备机都要同时先启动好haproxy,但是备机在未获得这个IP前是无法启动haproxy的。这时可以通过修改内核参数来绑定非本地地址

  1. echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind

阅读(2300) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~