使用 haproxy 进行 TCP 负载均衡

2016-12-21  本文已影响1571人  sbtiny

Ubutun 安装

#ubuntu 14.04LTS 
add-apt-repository ppa:vbernat/haproxy-1.7
apt-get update
apt-get dist-upgrade
apt-get install haproxy

mac 安装

brew install haproxy
#运行 `haproxy -f  /usr/local/Cellar/haproxy/1.6.6/haproxy.cfg  -d`

配置文件

global
    log 127.0.0.1 local0 notice
    maxconn 2000
    user haproxy
    group haproxy

defaults
    log     global
    mode    http
    option  httplog
    option  dontlognull
    retries 3
    option redispatch
    timeout connect  5000
    timeout client  10000

frontend localnodes
    bind *:4000
    mode tcp
    default_backend nodes
    timeout client          1m

backend nodes
    mode tcp
    balance leastconn
    server web01 127.0.0.1:4001 check
    server web02 127.0.0.1:4002 check
    timeout connect        10s
    timeout server          1m
上一篇 下一篇

猜你喜欢

热点阅读