已解决:客户端无法登录Redis服务器报错,解除保护模式

Posted 翔之天空

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了已解决:客户端无法登录Redis服务器报错,解除保护模式相关的知识,希望对你有一定的参考价值。


一:问题如下

在192.168.56.57客户端登录192.168.56.56的redis服务器时,报错如下:
[root@localhost src]# ./redis-cli -h  192.168.56.56  -p  6379 -a  "aabbcc"
192.168.56.56:6379> ping
Error: Connection reset by peer

 
再telnet一下192.168.56.56的redis服务器的6379端口,提示redis服务有保护模式,需要解除
[root@localhost src]# telnet 192.168.56.56  6379
Trying 192.168.56.56...
Connected to 192.168.56.56.
Escape character is '^]'.

-DENIED Redis is running in protected modebecause protected mode is enabled, no bind address was specified, noauthentication password is requested to clients. 
In this mode connections areonly accepted from the loopback interface. If you want to connect from externalcomputers to Redis you may adopt one of the following 
solutions: 1) Justdisable protected mode sending the command 'CONFIG SET protected-mode no' fromthe loopback interface by connecting to Redis from the same host 
the server isrunning, however MAKE SURE Redis is not publicly accessible from internet ifyou do so. Use CONFIG REWRITE to make this change permanent. 
2) Alternativelyyou can just disable the protected mode by editing the Redis configurationfile, and setting the protected mode option to 'no', and then restarting theserver. 
3) If you started the server manually just for testing, restart it withthe '--protected-mode no' option. 
4) Setup a bind address or an authenticationpassword. NOTE: You only need to do one of the above things in order for theserver to start accepting connections from the outside.
Connection closed by foreign host.


二:解决方案

1、修改redis服务器的配置文件
vi redis.conf  

注释以下绑定的主机地址
# bind 127.0.0.1

 
2、修改redis服务器的参数配置

修改redis的守护进程为no ,不启用
127.0.0.1:6379> config set daemonize "no"
OK

修改redis的保护模式为no,不启用
127.0.0.1:6379> config set protected-mode "no"
OK


三:问题解决

再次telnet一下192.168.56.56的redis服务器的6379端口,无问题
[root@localhost Packages]# telnet 192.168.56.56  6379
Trying 192.168.56.56...
Connected to 192.168.56.56.
Escape character is '^]'.


再次在192.168.56.57客户端登录192.168.56.56的redis服务器,无问题
[root@localhost src]# ./redis-cli -h  192.168.56.56 -p 6379 -a "aabbcc"
192.168.56.56:6379> ping
PONG

 

 

 

以上是关于已解决:客户端无法登录Redis服务器报错,解除保护模式的主要内容,如果未能解决你的问题,请参考以下文章

密保邮箱手机怎么登陆

win10家庭版开机出现引用的账户已锁定,且可能无法登录

win7显示引用的帐户当前已锁定,且可能无法登录,怎么解除锁定?

锁定电脑后重登录,出现“引用账户当前已锁定,且可能无法登录”提示。是怎么回事?

Windows安装Redis并添加本地自启动服务并解决客户端dll报错

oracle报错解决