首頁 > 軟體

redis遠端連線不上的解決辦法

2022-05-13 21:50:23

問題描述:

redis遠端伺服器端執行在192.168.3.90計算機上,使用者端計算機(ip:192.168.3.110)通過redsi-cli.exe使用者端工具連線時,沒有反應,連線不上。

如圖所示:

解決步驟:

步驟一:註釋掉redis.window.conf檔案中的bind屬性設定。

如圖所示:

步驟二:把protected-mode屬性設定no

重啟redis即可遠端連線。

如圖所示:

確定啟動成功,檢視所有keys

清空所有keys

注意事項:

不能直接雙擊redis安裝目錄下bin目錄下的redis-server.exe啟動redis伺服器端,否則會導致無法通過遠端使用者端進行操作。

如果所示,通過雙擊redis-server.exe命令啟動redis後,然後執行keys檢視所有鍵時報錯,

報錯如下異常:

(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 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.

原因分析:從啟動成功介面分析,這種方式的啟動讀取的組態檔可能不是redis.windows.conf檔案,故之前設定的內容沒有生效。

所以啟動redis時,通過進入redis安裝目錄下的bin目錄,然後執行

redis-server redis.windows.conf

命令啟動名。

另外redis-cli使用者端連線redis伺服器端命令如下

redis-cli -h 192.168.3.90 -p 6379
  • -h 選擇指定伺服器端ip
  • -p 選擇指定埠。

到此這篇關於redis遠端連線不上的解決辦法的文章就介紹到這了,更多相關redis遠端連線不上內容請搜尋it145.com以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援it145.com!


IT145.com E-mail:sddin#qq.com