redis.conf 註釋掉了bind 127.0.0.1和 protected-mode 仍報錯 ,啓動時 $ redis-server redis.conf

(error) DENIED Redis is running in protected mode because protected mode is enabled

  • Redis protected-mode 是3.2 之後加入的新特性,在Redis.conf的註釋中,我們可以瞭解到,他的具體作用和啓用條件

鏈接redis 時只能通過本地localhost (127.0.0.1)這個來鏈接,而不能用網絡ip(192.168..)這個鏈接,問題然如果用網絡ip 鏈接會報以下的錯誤:

(error) 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 lookback 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 --portected-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.
  • 1

是說處於保護模式,只能本地鏈接,我們需要修改配置文件../redis.conf
1)打開配置文件把下面對應的註釋掉

# bind 127.0.0.1 
  • 1

2)Redis默認不是以守護進程的方式運行,可以通過該配置項修改,使用yes啓用守護進程,設置爲no

daemonize no
  • 1

3)保護模式

protected-mode no 
  • 1

4)最後關鍵的是:
沒反應應該是你啓動服務端的時候沒有帶上配置文件。你可以./redis-server redis.conf
你配置好了,但要重新啓動redis,如果還是報一樣的錯誤,很可能是沒有啓動到配置文件,所以需要真正的和配置文件啓動需要:
在redis.conf文件的當前目錄下:

$ redis-server redis.conf
  • 1

如果還是所某個端口已在使用,那麼可能是有 後臺程序在佔用該端口,需要kill 掉該程序,重新帶上配置文件。./redis-server redis.conf啓動。
將含有”redis”關鍵詞的進程殺死:

$ ps -ef | <span class="hljs-keyword">grep</span> redis | awk ‘{<span class="hljs-keyword">print</span> <span class="hljs-variable">$2}’ | xargs kill -9
  • 1

我的問題就是這個步驟解決的,祝好。

        <link rel="stylesheet" href="https://csdnimg.cn/release/phoenix/template/css/markdown_views-ea0013b516.css">
            </div>

轉載至 https://blog.csdn.net/Agly_Clarlie/article/details/52251746

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章