首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在主/从配置中配置Redis 3.4及以上版本以解决在保护模式下运行的错误哨兵?

如何在主/从配置中配置Redis 3.4及以上版本以解决在保护模式下运行的错误哨兵?
EN

Stack Overflow用户
提问于 2016-12-19 13:25:24
回答 2查看 12.6K关注 0票数 6

我正在使用Redis 3.2,当从不同的机器连接到哨兵时,我得到以下错误:

代码语言:javascript
复制
Trying X.X.X.X...
Connected to X.X.X.X.
Escape character is '^]'.
-DENIED Redis is running in protected mode because protected mode is enabled, no bind address was specified, no authentication password is requested to clients. In this mode connections are only accepted from the loopback interface. If you want to connect from external computers to Redis you may adopt one of the following solutions: 1) Just disable protected mode sending the command 'CONFIG SET protected-mode no' from the loopback interface by connecting to Redis from the same host the server is running, however MAKE SURE Redis is not publicly accessible from internet if you do so. Use CONFIG REWRITE to make this change permanent. 2) Alternatively you can just disable the protected mode by editing the Redis configuration file, and setting the protected mode option to 'no', and then restarting the server. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) Setup a bind address or an authentication password. NOTE: You only need to do one of the above things in order for the server to start accepting connections from the outside.
Connection closed by foreign host.

能帮我解决这个问题吗?

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2016-12-19 16:02:45

在redis 3.2中,Sentinel默认情况下是无法从本地主机以外的接口访问的。

要么使用' bind‘指令绑定到网络接口列表,要么使用“保护模式否”禁用保护模式,将其添加到此配置文件中。

例如,您可以使用以下内容之一:

代码语言:javascript
复制
bind 127.0.0.1 192.168.1.1

protected-mode no
票数 14
EN

Stack Overflow用户

发布于 2017-11-13 11:29:24

为了进行测试,您可以尝试

代码语言:javascript
复制
redis-server --protected-mode no

这将将Redis保护模式设置为否。

如文件所示,建议采取步骤。

1)只要从运行服务器的同一主机连接到Redis,就可以禁用保护模式,从环回接口发送命令“配置集保护模式no”,但是如果这样做,请确保Redis不能从internet公开访问。使用配置重写使此更改永久化。 2)或者,您可以通过编辑Redis配置文件并将保护模式选项设置为'no',然后重新启动服务器,从而禁用受保护模式。 3)如果只为测试而手动启动服务器,则使用“--保护模式--no”选项重新启动服务器。 4)设置绑定地址或身份验证密码。注意:您只需要做上述一件事,服务器就可以开始接受来自外部的连接。

票数 6
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41223618

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档