使用HAProxy,我尝试(TCP)负载均衡Rserve(在TCP套接字中侦听调用R脚本的服务)在2个节点的端口6311上运行。
以下是我的配置文件。当我运行HAProxy时,它的状态没有任何问题。但是当我连接到平衡节点时,低于错误。配置有什么问题?
Handshake failed: expected 32 bytes header, got -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
答案 0 :(得分:16)
经过一个星期的解决方案来解决负载均衡R后,(完全免费/开源软件堆栈)解决方案有效。
如果有更多人提到这一点,我会发布一个关于安装到配置的详细博客。
能够通过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
关键是使用以下命令为HAproxy启用远程连接(大多数情况下没有明确的文档)
/usr/sbin/setsebool -P haproxy_connect_any 1
还要确保在Rserve中启用远程连接,并在Rserve配置文件中使用“enable remote”参数。