wget https://fossies.org/linux/misc/haproxy-1.8.14.tar.gz
tar zxvf haproxy-1.8.14.tar.gz
cd haproxy-1.8.14
make TARGET=linux31
make install PREFIX=/data/haproxy
mkdir /data/haproxy/{conf,logs}
cp examples/option-http_proxy.cfg /data/haproxy/conf/haproxy.cfg
vi /data/haproxy/conf/haproxy.cfg
global
daemon
nbproc 1
pidfile /data/haproxy/conf/haproxy.pid
defaults
mode tcp
retries 2
option redispatch
option abortonclose
balance roundrobin
maxconn 102400
timeout connect 5000ms
timeout client 30000ms
timeout server 30000ms
#timeout check 2000
log 127.0.0.1 local0 info
listen test1
bind 0.0.0.0:9999
mode tcp
server s1 yourip:yourport check weight 1 inter 2000 rise 2 fall 3
#server s2
listen admin_stats
bind 0.0.0.0:1688
mode http
log 127.0.0.1 local0 err
stats refresh 30s
stats uri /haproxy-status
stats realm welcome login\ Haproxy
stats auth admin:admin
stats hide-version
stats admin if TRUE
保存退出,
./haproxy -f ../conf/haproxy.cfg
本文详细介绍如何使用wget下载HAProxy源码包,通过tar命令解压并进入目录,利用make命令进行编译安装,设置运行参数,配置haproxy.cfg文件实现负载均衡功能,包括监听端口、模式选择、重试次数、超时设置等。
1529

被折叠的 条评论
为什么被折叠?



