【问题标题】:redis behind ha proxy - multiple connection retries and connection closedha代理后面的redis - 多次连接重试和连接关闭
【发布时间】:2016-11-11 22:42:26
【问题描述】:

redis 的 Ha 代理配置显示如下:

frontend redis
  bind *:6379 name port6379
  mode tcp
  timeout client 15s

    #define hosts
    acl redis_3 hdr(host) -i im.test.com

    #figure out which one to use
    use_backend test_redis if redis_3

backend test_redis
  mode tcp
  timeout connect  4s
  timeout server   30s
  #balance leastconn
  option tcplog
  option tcp-check
  tcp-check send PING\r\n
  tcp-check expect string +PONG
  #tcp-check send QUIT\r\n
  #tcp-check expect string +OK
  server node1_redis 10.146.99.164:6379 check inter 1s

HA 代理日志显示多个连接到 redir。在 redir 服务器上,我看到“对等方重置连接”

在浏览器中,我得到一个“重新初始化的会话”。

但是使用 redis-cli -h ping 我得到了正确的 PONG 响应。将浏览器直接定向到端口 6379 上的 redis 服务器,稍后会给出以下内容:

-ERR wrong number of arguments for 'get' command
-ERR unknown command 'Host:'
-ERR unknown command 'User-Agent:'
-ERR unknown command 'Accept:'
-ERR unknown command 'Accept-Language:'
-ERR unknown command 'Accept-Encoding:'
-ERR unknown command 'Cookie:'
-ERR unknown command 'Connection:'
-ERR unknown command 'Upgrade-Insecure-Requests:'

HAproxy stats 显示后端已启动。

谁能帮我解决这个问题?为什么通过 HA 代理连接时出现错误?

【问题讨论】:

  • 在 redis 服务器上使用 redis-cli set hello world 时,当直接使用 curl 连接到 redis 服务器时,我得到了一个连接。但是当我使用 HAproxy 连接时,它会给出错误 (52) Empty reply from server

标签: redis haproxy ubuntu-16.04


【解决方案1】:

解决了!由于某种原因未在 acl 中读取主机名。当我将其更改为默认后端时,它立即起作用。

也许有人可以告诉我为什么这个例子中的主机名不起作用?

但对我来说它现在有效。

一月

【讨论】:

    猜你喜欢
    • 2016-02-18
    • 2022-11-07
    • 1970-01-01
    • 1970-01-01
    • 2022-06-16
    • 1970-01-01
    • 2013-04-27
    • 1970-01-01
    • 2015-10-21
    相关资源
    最近更新 更多