简体   繁体   English

HAPROXY 未连接到 REDIS

[英]HAPROXY does't connect to REDIS

I'm trying to have HAPROXY as a proxy server between the clients and Redis server all in my local computer using Docker images so have this following configurations.我正在尝试将 HAPROXY 作为客户端和 Redis 服务器之间的代理服务器,所有这些都在我的本地计算机中使用 Docker 映像,因此具有以下配置。

docker run --name my-redis -p 6379:6379 -d redis

HAPROXY config file: HAPROXY 配置文件:

defaults REDIS
mode tcp
timeout connect 3s
timeout server 3s
timeout client 3s

# Specifies listening socket for accepting client connections using the default 
# REDIS TCP timeout and backend bk_redis TCP health check.
frontend ft_redis
bind *:6379 name redis
default_backend bk_redis

# Specifies the backend Redis proxy server TCP health settings 
# Ensure it only forward incoming connections to reach a master.
backend bk_redis
option tcp-check
tcp-check connect
tcp-check send PING\r\n
tcp-check expect string PONG
tcp-check send info\ replication\r\n
tcp-check expect string role:master
tcp-check send QUIT\r\n
tcp-check expect string OK
server my-redis 127.0.0.1:6379 check inter 1s

then i run the Haproxy image然后我运行 Haproxy 图像

docker run -p 3000:6379 -d --name my-running-haproxy  my-haproxy

after running a log the following message is giving运行日志后,给出以下消息

[NOTICE]   (1) : New worker (9) forked
[NOTICE]   (1) : Loading success.
[WARNING]  (9) : Server bk_redis/my-redis is DOWN, reason: Layer7 timeout, info: " at step 3 of tcp-check (expect string 'PONG')", check duration: 1000ms. 0 active and 0 backup servers left. 2594 sessions active, 0 requeued, 0 remaining in queue.
[ALERT]    (9) : backend 'bk_redis' has no server available!

How can I fix this problem?我该如何解决这个问题?

Redis responds to the PING command with "+PONG". Redis 使用“+PONG”响应 PING 命令。 In the expect statement you can change "PONG" to "+PONG".在期望语句中,您可以将“PONG”更改为“+PONG”。 The same should be made for "+OK". “+OK”也应如此。

To know the different responses you can connect to Redis using telnet and run the commands.要了解不同的响应,您可以使用 telnet 连接到 Redis 并运行命令。

telnet localhost 6379
Trying ::1...
Connected to localhost.
Escape character is '^]'.
PING
+PONG

For more info 欲了解更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM