redis解決(DENIED Redis is running in protected mode because prote)

來源:互聯網
上載者:User

標籤:address   running   because   localhost   specified   


早上一個應用日誌列印報錯資訊:

650) this.width=650;" src="http://s3.51cto.com/wyfs02/M02/8A/E5/wKiom1g-cNXwSl0FAAAlafexExk279.png" title="redis.png" alt="wKiom1g-cNXwSl0FAAAlafexExk279.png" />


在應用上telnet連接埠和ping都沒有問題,為什麼還擷取不到值呢。

先安裝一個redis用戶端進行測試:yum -y install redis

redis-cli -h 192.168.32.12 -p 6887

然後就報錯了:

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


後來就查看配置發現redis.conf 該行也是注釋的:

# requirepass foobared


繼續排查發現和一個參數配置有關係:


連結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.
是說處於保護模式,只能本地連結,我們需要修改設定檔../redis.conf

1)開啟設定檔把下面對應的注釋掉
# bind 127.0.0.1

2)Redis預設不是以守護進程的方式運行,可以通過該配置項修改,使用yes啟用守護進程,設定為no
daemonize no

3)保護模式
protected-mode no

報錯處理:

一、

在對應配置conf檔案中去掉注釋,把yes改為no

#protected-mode yes
protected-mode no


重啟redis(注意有資料時謹慎啟)

kill -9 進程號

redis-cli -h 192.168.32.12 -p 6887 shutdown


二、添加認證,設定密碼

# requirepass foobared

requirepass redis123456


驗證

再次用Java程式建立串連池,沒有報錯,且可以對redis server進行資料正常處理。程式報錯日誌不再顯示

問題解決


本文出自 “7835882” 部落格,請務必保留此出處http://crfsz.blog.51cto.com/7835882/1878137

redis解決(DENIED Redis is running in protected mode because prote)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.