【问题标题】:Redis Client not connecting to Redis server via HAProxyRedis 客户端未通过 HAProxy 连接到 Redis 服务器
【发布时间】:2018-07-29 11:27:07
【问题描述】:

我在使用 Jedis 作为 Redis 客户端通过 HAProxy 连接到 Redis 服务器时遇到问题。 当 Redis 服务器直接连接到时,一切正常,但通过 HAProxy 无法正常工作。 HAProxy 和 Redis 服务都在其特定端口上运行,HAProxy 在端口 80 上,Redis 服务器在 6379 上。 我们正在 EC2 实例上运行此设置,并且所有必要的端口都已打开。

HAProxy 配置是

frontend http-in
bind *:80
default_backend redis-server

backend redis-server
    stats   enable
    server redis-server1 x.x.x.x:6379 check inter 1000 fall 3 rise 2
    server redis-server2 x.x.x.x:6379 check inter 1000 fall 3 rise 2

Jedis Clinet 代码为:

 try {
    Jedis jedis = new Jedis(hostname, port);
    jedis.set("key", "Redis-Test-Value");
    System.out.println("value from redis node is: " + jedis.get("key"));
} catch (Exception e) {
    System.out.println("exception is " + e);
}

抛出的异常消息是 - redis.clients.jedis.exceptions.JedisConnectionException: Unknown reply: H

有人可以指出我缺少什么并指出正确的方向吗?

【问题讨论】:

    标签: redis haproxy jedis sentinel redis-sentinel


    【解决方案1】:

    前端http-in

    Redis 不是 HTTP 服务器,因此将其作为一个服务器是行不通的。由于这是服务器管理问题,而不是编程问题,请尝试使用列表或 serverfault.com 了解其他问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-25
      • 2021-12-20
      • 2012-06-15
      • 2011-11-05
      • 2016-01-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多