HAProxy负载平衡TCP流量
使用HAProxy,我正在尝试(TCP)负载平衡Rserve(在TCP套接字中侦听用于调用R脚本的服务),该服务在2个节点的6311端口上运行 下面是我的配置文件。当我运行HAProxy时,它的stating没有任何问题。但当我连接到平衡节点时,会出现以下错误。配置有问题吗HAProxy负载平衡TCP流量,tcp,load-balancing,haproxy,rserve,Tcp,Load Balancing,Haproxy,Rserve,使用HAProxy,我正在尝试(TCP)负载平衡Rserve(在TCP套接字中侦听用于调用R脚本的服务),该服务在2个节点的6311端口上运行 下面是我的配置文件。当我运行HAProxy时,它的stating没有任何问题。但当我连接到平衡节点时,会出现以下错误。配置有问题吗 握手失败:应为32字节头,得到-1 #--------------------------------------------------------------------- # Global settings #----
握手失败:应为32字节头,得到-1
#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
log 127.0.0.1 local2
chroot /var/lib/haproxy
pidfile /var/run/haproxy.pid
maxconn 4000
user haproxy
group haproxy
daemon
# turn on stats unix socket
stats socket /var/lib/haproxy/stats
#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
mode tcp
log global
option httplog
option dontlognull
option http-server-close
#option forwardfor except 127.0.0.0/8
option redispatch
retries 3
timeout http-request 10s
timeout queue 1m
timeout connect 10s
timeout client 1m
timeout server 1m
timeout http-keep-alive 10s
timeout check 10s
maxconn 3000
listen haproxy_rserve
bind *:81
mode tcp
option tcplog
timeout client 10800s
timeout server 10800s
balance leastconn
server rserve1 rserveHostName1:6311
server rserve2 rserveHostName2:6311
listen stats proxyHostName:8080
mode http
stats enable
stats realm Haproxy\ Statistics
stats uri /haproxy_stats
stats hide-version
stats auth admin:password
尝试了以下前端后端的平衡方式以及。同样的结果
frontend haproxy_rserve
bind *:81
mode tcp
option tcplog
timeout client 10800s
default_backend rserve
backend rserve
mode tcp
option tcplog
balance leastconn
timeout server 10800s
server rserve1 rserveHostName1:6311
server rserve2 rserveHostName2:6311
在为负载平衡解决方案苦苦挣扎了一周之后,below(完整的免费/开源软件栈)解决方案成功了 如果有更多的人提到这一点,我将发布一篇关于安装到配置的详细博客 能够使用下面的配置通过HAProxy TCP负载平衡器对来自Rserve的R脚本请求进行负载平衡。与问题中的配置部分非常相似,但前端和后端是分开的
#Load balancer stats page access at hostname:8080/haproxy_stats
listen stats <load_balancer_hostname>:8080
mode http
log global
stats enable
stats realm Haproxy\ Statistics
stats uri /haproxy_stats
stats hide-version
stats auth admin:admin@rserve
frontend rserve_frontend
bind *:81
mode tcp
option tcplog
timeout client 1m
default_backend rserve_backend
backend rserve_backend
mode tcp
option tcplog
option log-health-checks
option redispatch
log global
balance roundrobin
timeout connect 10s
timeout server 1m
server rserve1 <rserve hostname1>:6311 check
server rserve2 <rserve hostname2>:6311 check
server rserve2 <rserve hostname3>:6311 check
另外,请确保使用Rserve配置文件中的“enable remote”参数在Rserve中启用远程连接。hi-这非常有趣。为什么不使用nginx?因为我们大多数人都使用nginx,所以在那里看到解决方案是非常酷的。请注意,nginx支持tcp(使用流和/或代理协议)@Sandeep没有不使用nginx的具体原因。发现haproxy是反向代理的独家产品,几十年来一直做得很好,我不需要nginx提供的任何东西(比如web服务器)。对我们可以使用它的反向代理部分。“但是刚刚解决了haproxy的问题。”Sandeep这里是TCP负载平衡的nginx实现示例@Sandeep我们目前将nginx用于tcp反向代理,但希望切换到HAProxy,因为除非您升级到nginx+,否则nginx只有被动健康检查。当HAProxy免费提供时,我们并不热衷于每年支付2.5k的费用。@MichaelHobbs除了目前的研究外,还没有使用它的经验,但它(HAProxy)在负载平衡能力方面确实看起来非常有前景。内置的统计页面确实非常好。
/usr/sbin/setsebool -P haproxy_connect_any 1