记录配置RedisDesktopManager遇到的问题

一、问题描述

在Connect to Redis Server中,点击Test Connect,显示“Can’t connect to redis-server ”。

二、可能的解决方案

解决防火墙问题

方案:关闭CentOS7防火墙

#关闭防火墙
systemctl stop firewalld.service
#禁止开机自启动
systemctl disable firewalld.service

解决端口号问题

如果已经完全关闭CentOS防火墙,那么可以不看这块儿

方案:在CentOS7开启Redis默认的6379端口

1.查看CentOS7 IP
[root@bogon bin]# ifconfig

在宿主机中,用Telnet命令测试用“ip地址+端口号”测试连通性
例如:

Telnet 192.168.245.245:6379

2.Telnet连接失败

此时需要在CentOS中开启对应的端口号

[root@bogon bin]# firewall-cmd --add-port=6379/tcp

3.Telnet连接成功但显示保护模式

查看显示的结果
在这里插入图片描述
大概意思是:Redis正在以保护模式运行,没有特定的bind地址,没有密码。这个模式连接只能接受回环地址。如果想要连接外部计算机,有这么几种解决方法:

1.命令关闭保护模式
CONFIG SET protected-mode no

这种方法的弊端是不能让操作持久,就是说重启Redis后,这个命令会失效,保护模式还是会开启。如果想让这种改变长期保存的话,下面的方法提到了

2.修改配置文件

用vi编辑器,打开配置文件

vi /opt/redis/az/bin/redis.conf

注:每台设备配置文件所在位置不同,我的“az”文件指的是Redis的正式安装文件所在的位置。

找到protected-mode 选项
把yes 改成 no

重启redis服务

[root@bogon bin]# ./redis-server redis.conf
3.只是用来测试(没多大意义)

重启服务器并在后面加操作

--protected-mode no
4.设置一个bind地址或者设置一个密码

见下文

解决bind地址问题

在Redis配置文件中,找到

################################## NETWORK #####################################

# By default, if no "bind" configuration directive is specified, Redis listens
# for connections from all the network interfaces available on the server.
# It is possible to listen to just one or multiple selected interfaces using
# the "bind" configuration directive, followed by one or more IP addresses.
#
# Examples:
#
# bind 192.168.1.100 10.0.0.1
# bind 127.0.0.1 ::1
#
# ~~~ WARNING ~~~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address (this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running).
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bind 127.0.0.1

注释掉最后一行 127.0.0.1

设置一个密码

1.配置文件修改

打开配置文件
找到requiredpass
去掉注释,将后面字段改成自己所想密码,保存退出。

2.命令修改配置

进入客户端以后
使用

config set requiredpass “密码”

设置密码。

使用

config get requiredpass

查看密码。

使用

auth “密码”

输入密码

使用

./redis-cli -p "端口号" -a "密码"

直接以客户端启动方式登录
因为没有修改配置文件的原因,所以这个修改不持久,重启后失效

配置虚拟机地址

需要在Linux内部设置静态IP,虚拟机软件是Oracle VMVirtualBox。按对应步骤完成,用ping测试不连通。之后,换了另一个虚拟机软件VMware Workstation,按CentOS中显示的ip可以在宿主机中ping指令测试结果为连通。
得出结论:在Redis 连接上,VMware Workstation要比Oracle VMVirtualBox好用!

  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值