Fork me on GitHub

分类 haproxy 中的文章

Haproxy 编译安装配置

编译安装Haproxy 2.4 下载预备 sudo wget -O /usr/local/src/haproxy-2.4.15.tar.gz sudo wget -O /usr/local/src/lua-5.3.5.tar.gz sudo yum install make gcc build-essential libssl-devel zlib1g-devel pcre3 pcre3-devel systemd-devel readline-devel openssl openssl-devel -y 编译安装 lua cd /usr/local/src && tar -zxvf lua-5.3.5.tar.gz cd /usr/local/src/lua-5.3.5 && make linux src/lua -v haproxy cd /usr/local/src && tar -zxvf haproxy-2.4.15.tar.gz cd /usr/local/src/haproxy-2.4.15 make -j `lscpu |awk 'NR==4{print $2}'` ARCH=x86_64 TARGET=linux-glibc USE_PCRE=1 USE_ZLIB=1 USE_SYSTEMD=1 USE_CPU_AFFINITY=1 USE_LUA=1 LUA_INC=/usr/local/src/lua-5.3.5/src/ LUA_LIB=/usr/local/src/lua-5.3.5/src/ PREFIX=/usr/local/haproxy make install PREFIX=/usr/local/haproxy /usr/local/haproxy/sbin/haproxy -v 如果想添加 openssl 支持参考 In order to link OpenSSL statically against HAProxy, first download OpenSSL from then build it with the "no-shared" keyword and install it to a local directory, so your system is not affected : $ export STATICLIBSSL=/tmp/staticlibssl $ ./config --prefix=$STATICLIBSSL no-shared……


Haproxy 算法

blance roundrobin # 轮询,软负载均衡基本都具备这种算法 balance static-rr # 根据权重,不支持慢启动 。建议使用 balance leastconn # 最少连接者先处理,建议使用 balance source # 根据请求源IP,建议使用 balance uri # 根据请求的URI balance url_param,# 根据请求的URl参数’balance url_param' requires an URL parameter name balance hdr(name) # 根据HTTP请求头来锁定每一……