redis遠(yuǎn)程連接不上的解決辦法
問(wèn)題描述:
redis遠(yuǎn)程服務(wù)端運(yùn)行在192.168.3.90計(jì)算機(jī)上,客戶端計(jì)算機(jī)(ip:192.168.3.110)通過(guò)redsi-cli.exe客戶端工具連接時(shí),沒(méi)有反應(yīng),連接不上。
如圖所示:

解決步驟:
步驟一:注釋掉redis.window.conf文件中的bind屬性設(shè)置。
如圖所示:


步驟二:把protected-mode屬性設(shè)置no

重啟redis即可遠(yuǎn)程連接。
如圖所示:



確定啟動(dòng)成功,查看所有keys

清空所有keys

注意事項(xiàng):
不能直接雙擊redis安裝目錄下bin目錄下的redis-server.exe啟動(dòng)redis服務(wù)端,否則會(huì)導(dǎo)致無(wú)法通過(guò)遠(yuǎn)程客戶端進(jìn)行操作。
如果所示,通過(guò)雙擊redis-server.exe命令啟動(dòng)redis后,然后執(zhí)行keys查看所有鍵時(shí)報(bào)錯(cuò),



報(bào)錯(cuò)如下異常:
(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.
原因分析:從啟動(dòng)成功界面分析,這種方式的啟動(dòng)讀取的配置文件可能不是redis.windows.conf文件,故之前設(shè)置的內(nèi)容沒(méi)有生效。
所以啟動(dòng)redis時(shí),通過(guò)進(jìn)入redis安裝目錄下的bin目錄,然后執(zhí)行
redis-server redis.windows.conf
命令啟動(dòng)名。
另外redis-cli客戶端連接redis服務(wù)端命令如下
redis-cli -h 192.168.3.90 -p 6379
- -h 選擇指定服務(wù)端ip
- -p 選擇指定端口。
到此這篇關(guān)于redis遠(yuǎn)程連接不上的解決辦法的文章就介紹到這了,更多相關(guān)redis遠(yuǎn)程連接不上內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
Redis實(shí)現(xiàn)優(yōu)惠券限一單限制詳解
這篇文章主要介紹了Redis解決優(yōu)惠券秒殺應(yīng)用案例,本文先講了搶購(gòu)問(wèn)題,指出其中會(huì)出現(xiàn)的多線程問(wèn)題,提出解決方案采用悲觀鎖和樂(lè)觀鎖兩種方式進(jìn)行實(shí)現(xiàn),然后發(fā)現(xiàn)在搶購(gòu)過(guò)程中容易出現(xiàn)一人多單現(xiàn)象,需要的朋友可以參考下2022-12-12
Redis+Lua腳本實(shí)現(xiàn)計(jì)數(shù)器接口防刷功能(升級(jí)版)
這篇文章主要介紹了Redis+Lua腳本實(shí)現(xiàn)計(jì)數(shù)器接口防刷功能,使用腳本使得set命令和expire命令一同達(dá)到Redis被執(zhí)行且不會(huì)被干擾,在很大程度上保證了原子操作,對(duì)Redis實(shí)現(xiàn)計(jì)數(shù)器接口防刷功能感興趣的朋友一起看看吧2022-02-02
關(guān)于Redis網(wǎng)絡(luò)模型的源碼詳析
這篇文章主要給大家介紹了關(guān)于Redis網(wǎng)絡(luò)模型的源碼,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者使用Redis具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-07-07
Redis學(xué)習(xí)教程之命令的執(zhí)行過(guò)程詳解
這篇文章主要給大家介紹了關(guān)于Redis學(xué)習(xí)教程之命令的執(zhí)行過(guò)程的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。2018-03-03

