1

我在阿里云上部署了 3 台不同的服务器,每台服务器运行 2 个 redis 实例,端口分别为 6379 和 6380。

我试图用这 6 个节点构建一个 redis 集群。(Redis 版本 3.2.0)。但它失败并说“对不起,无法连接到节点 10.161.94.215:6379”(10.161.94.215 是我的第一台服务器的局域网 IP 地址。)

虽然很明显服务器运行得很好,我可以通过 redis-cli 得到它。

宝石已安装。

Requirepass 被禁止,不需要身份验证。

没有ip绑定

也没有保护模式。

错误图片

关于集群的所有配置选项都设置得很好。

这有什么问题?

4

4 回答 4

0

我想我现在知道为什么了。

使用本地主机的 IP。

src/redis-trib.rb create 127.0.0.1:6379 127.0.0.1:6380 h2:p1 h2:p2 h3:p1 h3:p2
于 2016-05-15T05:43:25.610 回答
0

我认为您正在从不同的子网创建集群。那可能是个问题。

于 2016-06-09T10:59:00.497 回答
0

看起来保护模式是 redis 3.2 中的一项新安全功能。简短的版本是,如果您没有明确绑定到 IP 地址,它将只允许访问 localhost。

如果您只想在单个主机上创建集群,这可能没问题。如果您使用多个主机来创建集群,您需要关闭保护模式或显式绑定到 IP 地址。

从 redis.conf 文件:

# Protected mode is a layer of security protection, in order to avoid    that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.

# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.
protected-mode yes

如果您尝试使用环回接口以外的其他东西连接到它,有关于如何更正此问题的说明:

拒绝 Redis 在保护模式下运行,因为启用了保护模式,没有指定绑定地址,也没有向客户端请求身份验证密码。在此模式下,仅接受来自环回接口的连接。如果您想从外部计算机连接到 Redis,您可以采用以下解决方案之一: 1) 只需禁用保护模式,通过从服务器的同一主机连接到 Redis 从环回接口发送命令 'CONFIG SET protected-mode no'正在运行,但是如果这样做,请确保 Redis 不能从 Internet 公开访问。使用 CONFIG REWRITE 使此更改永久生效。2) 或者,您可以通过编辑 Redis 配置文件并将保护模式选项设置为“否”来禁用保护模式,然后重新启动服务器。3) 如果您手动启动服务器只是为了测试,请使用“--protected-mode no”选项重新启动它。4) 设置绑定地址或认证密码。注意:您只需执行上述操作之一,服务器即可开始接受来自外部的连接。

redis-trib.rb 的输出相当简洁(可能是这样)。

于 2016-07-21T17:08:29.513 回答
0

须藤纳米/etc/redis/6379.conf

Replace #bind 127.0.0.1 or bind 127.0.0.1 with bind 0.0.0.0   

sudo service redis_6379 restart

允许在任何地方访问redis。

于 2016-12-04T10:46:36.950 回答