日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

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

發(fā)布時間:2023/12/20 数据库 39 豆豆
生活随笔 收集整理的這篇文章主要介紹了 redis解决(DENIED Redis is running in protected mode because prote) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

早上一個應用日志打印報錯信息:

?

在應用上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……

?

后來就查看配置發(fā)現redis.conf 該行也是注釋的:

# requirepass foobared

?

繼續(xù)排查發(fā)現和一個參數配置有關系:

?

鏈接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進行數據正常處理。程序報錯日志不再顯示

問題解決

?

linux下查看redis是否正常運行


make
make PREFIX=/usr/local/redis install
mkdir /etc/redis/
cp redis.conf /etc/redis/
?
打開redis.conf文件修改daemonize yes即可在后臺運行
vim /etc/redis/redis.conf
?
?
使用配置文件啟動redis服務
./redis-server /etc/redis/redis.conf
?
?
如何查看redis服務正常啟動?
使用ps查看或netstat
?
ps aux | grep redis-server?

-------------------------------------

總結

以上是生活随笔為你收集整理的redis解决(DENIED Redis is running in protected mode because prote)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。