zoukankan      html  css  js  c++  java
  • 如何监听非本地IP

    做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
  • 相关阅读:
    2016521-Java-第八周学习总结
    20165221 第七周学习总结
    20165221—JAVA第六周学习心得
    20165221 JAVA第五周学习心得
    20165221 JAVA第四周学习心得
    结对学习创意照
    20165331 第三周学习总结
    20165331 课下作业
    20165331 第二周学习总结
    20165331 第一周学习总结
  • 原文地址:https://www.cnblogs.com/duanxz/p/4225396.html
Copyright © 2011-2022 走看看