Redis Desktop Manager连接redis发生crash

Redis Desktop Manager连接redis发生crash

环境说明

redis操作系统: Ubuntu 18.04.1 LTS
redis版本: redis 5.0.2
本地操作系统:windows10

redis IP:10.11.91.36
redis port:6379

问题重现

在windows系统安装了Redis Desktop Manager,配置如下图:
在这里插入图片描述
连接后报错:

在这里插入图片描述

问题分析

判断是网络配置问题,在windows端使用telnet命令查看网络情况:

C:\Users\aladdin>telnet 10.11.91.36 6379

-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 follow
ing solutions: 1) Just disable protected mode sending the command 'CONFIG SET pr
otected-mode no' from the loopback interface by connecting to Redis from the sam
e 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 con
figuration file, and setting the protected mode option to 'no', and then restart
ing 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 authenti
cation 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处于protected mode,导致无法连接

问题解决

在redis机器上查看protected mode配置:

root@sbc-VirtualBox:/etc/redis# redis-cli -p 6379 config get protected-mode
1) "protected-mode"
2) "yes"

确认开启了protected mode,修改配置:

root@sbc-VirtualBox:/etc/redis# redis-cli -p 6379 config set protected-mode no
OK
root@sbc-VirtualBox:/etc/redis# redis-cli -p 6379 config get protected-mode
1) "protected-mode"
2) "no"

再次在windows端尝试用Redis Desktop Manager连接redis:

在这里插入图片描述
连接成功!

事后分析

protected mode功能是redis3.2以后添加的,默认为开启状态,其官方解释如下:

# Protected mode is a layer of security protection, in order to avoid that
# Redis instances left open on the internet are accessed and exploited.
#
# When protected mode is on and if:
#
# 1) The server is not binding explicitly to a set of addresses using the
#    "bind" directive.
# 2) No password is configured.
#
# The server only accepts connections from clients connecting from the
# IPv4 and IPv6 loopback addresses 127.0.0.1 and ::1, and from Unix domain
# sockets.
#
# By default protected mode is enabled. You should disable it only if
# you are sure you want clients from other hosts to connect to Redis
# even if no authentication is configured, nor a specific set of interfaces
# are explicitly listed using the "bind" directive.

开启protected mode则必须配置password,并且将允许连接的ip及端口在bind中明确列出

猜你喜欢

转载自blog.csdn.net/sunbocong/article/details/85259190