看起来保护模式是 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 的输出相当简洁(可能是这样)。