隐藏页面特效

解决使用jedis连接是报DENIED Redis is running in protected mode错误

1
2
3
4
5
6
7
<div id="mCSB_1" class="mCustomScrollBox mCS-minimal-dark mCSB_vertical_horizontal mCSB_outside" style="max-height: none;" tabindex="0"><div id="mCSB_1_container" class="mCSB_container mCS_y_hidden mCS_no_scrollbar_y" style="position: relative; top: 0px; left: 0px; width: 2209px;" dir="ltr"><code-pre class="code-pre" id="pre-6Xkmfx"><code-line class="line-numbers-rows"></code-line>DENIED Redis <span class="hljs-keyword">is</span> running <span class="hljs-keyword">in</span> <span class="hljs-keyword">protected</span> mode because <span class="hljs-keyword">protected</span> mode <span class="hljs-keyword">is</span> enabled, no bind address was specified, no authentication password <span class="hljs-keyword">is</span> requested <span class="hljs-keyword">to</span> clients. <span class="hljs-keyword">In</span> this mode connections are only accepted <span class="hljs-keyword">from</span> the loopback <span class="hljs-keyword">interface</span>. <span class="hljs-keyword">If</span> you want <span class="hljs-keyword">to</span> connect <span class="hljs-keyword">from</span> <span class="hljs-keyword">external</span> computers <span class="hljs-keyword">to</span> Redis you may adopt one <span class="hljs-keyword">of</span> the following solutions:
<code-line class="line-numbers-rows"></code-line> <span class="hljs-number">1</span>) Just disable <span class="hljs-keyword">protected</span> mode sending the command <span class="hljs-string">'CONFIG SET protected-mode no'</span> <span class="hljs-keyword">from</span> the loopback <span class="hljs-keyword">interface</span> <span class="hljs-keyword">by</span> connecting <span class="hljs-keyword">to</span> Redis <span class="hljs-keyword">from</span> the same host the server <span class="hljs-keyword">is</span> running, however MAKE SURE Redis <span class="hljs-keyword">is</span> <span class="hljs-keyword">not</span> publicly accessible <span class="hljs-keyword">from</span> internet <span class="hljs-keyword">if</span> you <span class="hljs-keyword">do</span> so. Use CONFIG REWRITE <span class="hljs-keyword">to</span> make this change permanent.
<code-line class="line-numbers-rows"></code-line><span class="hljs-number">2</span>) Alternatively you can just disable the <span class="hljs-keyword">protected</span> mode <span class="hljs-keyword">by</span> editing the Redis configuration file, <span class="hljs-keyword">and</span> setting the <span class="hljs-keyword">protected</span> mode option <span class="hljs-keyword">to</span> <span class="hljs-string">'no'</span>, <span class="hljs-keyword">and</span> <span class="hljs-keyword">then</span> restarting the server.
<code-line class="line-numbers-rows"></code-line><span class="hljs-number">3</span>) <span class="hljs-keyword">If</span> you started the server manually just <span class="hljs-keyword">for</span> testing, restart it <span class="hljs-keyword">with</span> the <span class="hljs-string">'--protected-mode no'</span> option.
<code-line class="line-numbers-rows"></code-line><span class="hljs-number">4</span>) Setup a bind address <span class="hljs-keyword">or</span> an authentication password. NOTE: You only need <span class="hljs-keyword">to</span> <span class="hljs-keyword">do</span> one <span class="hljs-keyword">of</span> the above things <span class="hljs-keyword">in</span> <span class="hljs-keyword">order</span> <span class="hljs-keyword">for</span> the server <span class="hljs-keyword">to</span> start accepting connections <span class="hljs-keyword">from</span> the outside.
<code-line class="line-numbers-rows"></code-line>
</code-pre></div></div><div id="mCSB_1_scrollbar_vertical" class="mCSB_scrollTools mCSB_1_scrollbar mCS-minimal-dark mCSB_scrollTools_vertical" style="display: none;"><div class="mCSB_draggerContainer"><div id="mCSB_1_dragger_vertical" class="mCSB_dragger" style="position: absolute; min-height: 0px; height: 0px; top: 0px;"><div class="mCSB_dragger_bar" style="line-height: 0px;"></div></div><div class="mCSB_draggerRail"></div></div></div><div id="mCSB_1_scrollbar_horizontal" class="mCSB_scrollTools mCSB_1_scrollbar mCS-minimal-dark mCSB_scrollTools_horizontal" style="display: block;"><div class="mCSB_draggerContainer"><div id="mCSB_1_dragger_horizontal" class="mCSB_dragger" style="position: absolute; min-width: 0px; display: block; width: 723px; max-width: 1254px; left: 0px;"><div class="mCSB_dragger_bar"></div></div><div class="mCSB_draggerRail"></div></div></div>

  

1. 错误原因:由于redis的保护模式开启了,并且没有绑定ip地址,没有密码认证

2. 解决方案
方案一:

1) 使用 设置CONFIG SET protected-mode no

步骤:

1. 在redis本机上打开redis-cli工具,并连接

2. 在其中输入CONFIG SET protected-mode no即可

缺点:

该种方式只是短暂性有效,如果redisServer重新启动后还是不能正常链接

方案二:

1)编辑redis配置文件,将保护模式关闭

步骤:

由于我是直接使用redis-server 命令启动的,所以说其服务是按照其默认设置进行启动,修改/usr/local/etc/redis.conf

如果没有请从下载的redis中复制一个redis.conf到这里,

将bind 后面绑定的ip后面加入你本机外网的ip

1
2
3
<div id="mCSB_2" class="mCustomScrollBox mCS-minimal-dark mCSB_vertical_horizontal mCSB_outside" style="max-height: none;" tabindex="0"><div id="mCSB_2_container" class="mCSB_container mCS_y_hidden mCS_no_scrollbar_y mCS_x_hidden mCS_no_scrollbar_x" style="position: relative; top: 0px; left: 0px; width: 100%;" dir="ltr"><code-pre class="code-pre" id="pre-wQxeyT"><code-line class="line-numbers-rows"></code-line>bind <span class="hljs-number">127.0</span><span class="hljs-number">.0</span><span class="hljs-number">.1</span> <span class="hljs-number">192.168</span><span class="hljs-number">.21</span><span class="hljs-number">.4</span>
<code-line class="line-numbers-rows"></code-line>
</code-pre></div></div><div id="mCSB_2_scrollbar_vertical" class="mCSB_scrollTools mCSB_2_scrollbar mCS-minimal-dark mCSB_scrollTools_vertical" style="display: none;"><div class="mCSB_draggerContainer"><div id="mCSB_2_dragger_vertical" class="mCSB_dragger" style="position: absolute; min-height: 0px; height: 0px; top: 0px;"><div class="mCSB_dragger_bar" style="line-height: 0px;"></div></div><div class="mCSB_draggerRail"></div></div></div><div id="mCSB_2_scrollbar_horizontal" class="mCSB_scrollTools mCSB_2_scrollbar mCS-minimal-dark mCSB_scrollTools_horizontal" style="display: none;"><div class="mCSB_draggerContainer"><div id="mCSB_2_dragger_horizontal" class="mCSB_dragger" style="position: absolute; min-width: 0px; width: 0px; left: 0px;"><div class="mCSB_dragger_bar"></div></div><div class="mCSB_draggerRail"></div></div></div>

  

然后保存,再使用redis-server /usr/local/etc/redis.conf启动

问题:

  1.redis-cli不能直接使用,必须输入绑定的ip+d端口号才能正常使用

  2.不安全

2). 将redis.conf中安全模式关闭

将该保护模式改为no

再试

缺点:1.保护模式关闭后不安全

3)设置密码访问模式

在redis.conf中加入一行密码设置

1
2
<div id="mCSB_3" class="mCustomScrollBox mCS-minimal-dark mCSB_vertical_horizontal mCSB_outside" style="max-height: none;" tabindex="0"><div id="mCSB_3_container" class="mCSB_container mCS_y_hidden mCS_no_scrollbar_y mCS_x_hidden mCS_no_scrollbar_x" style="position: relative; top: 0px; left: 0px; width: 100%;" dir="ltr"><code-pre class="code-pre" id="pre-afZYrK"><code-line class="line-numbers-rows"></code-line><span class="hljs-built_in">require</span> 你的密码
</code-pre></div></div><div id="mCSB_3_scrollbar_vertical" class="mCSB_scrollTools mCSB_3_scrollbar mCS-minimal-dark mCSB_scrollTools_vertical" style="display: none;"><div class="mCSB_draggerContainer"><div id="mCSB_3_dragger_vertical" class="mCSB_dragger" style="position: absolute; min-height: 0px; height: 0px; top: 0px;"><div class="mCSB_dragger_bar" style="line-height: 0px;"></div></div><div class="mCSB_draggerRail"></div></div></div><div id="mCSB_3_scrollbar_horizontal" class="mCSB_scrollTools mCSB_3_scrollbar mCS-minimal-dark mCSB_scrollTools_horizontal" style="display: none;"><div class="mCSB_draggerContainer"><div id="mCSB_3_dragger_horizontal" class="mCSB_dragger" style="position: absolute; min-width: 0px; width: 0px; left: 0px;"><div class="mCSB_dragger_bar"></div></div><div class="mCSB_draggerRail"></div></div></div>

 保存,再重新启动redis客户端

以上四种方式解决该错误都可以,但是根据上面的优缺点,

 

选择第四种方式最佳,安全性最高 


__EOF__

本文作者lonecloud
本文链接https://www.cnblogs.com/lonecloud/p/9084761.html
关于博主:评论和私信会在第一时间回复。或者直接私信我。
版权声明:本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
声援博主:如果您觉得文章对您有帮助,可以点击文章右下角推荐一下。您的鼓励是博主的最大动力!
posted @   lonecloud  阅读(23079)  评论(0编辑  收藏  举报
编辑推荐:
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
我的博客即将同步至 OSCHINA 社区,这是我的 OSCHINA ID:lonecloud,邀请大家一同入驻:https://www.oschina.net/sharing-plan/apply
点击右上角即可分享
微信分享提示