问题点一就是redis的配置文件问题
进入redis的目录
[root@VM-20-13-centos ~]# cd /www/server/redis/
使用vim进入配置文件的修改
[root@VM-20-13-centos redis]# vim redis.conf
使用vim编辑器修改`bin`目录中的redis.conf文件,修改如下三项
################################## 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 这里是告诉我们可以绑定多个ip来连接redis服务端
# 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 翻译一下大概就是注意:如果redis直接暴露在互联网,绑定所有接口是非常危险的,因此我们没有注释下面的绑定指令
# instance to everybody on the internet. So by default we uncomment the
bind 127.0.0.1 这个相当于只绑定在服务端本地,也就是说只能在服务端连接redis,进行操作
# 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 如果你想要开放所有ip接口,注释下面这行
# JUST COMMENT THE FOLLOWING LINE.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#bind 127.0.0.1
就直接注释bind 127.0.0.1,重启一下让配置生效,再进行远程连接就ok了。
其次还有就是 protected-mode保护模式改为no,接着 daemonize 修改为yes保存好设置,重启如果
重启可以连接成功,下面的可以不用看了。
·································································································································
接下来大概率就是防火墙没有打开6379的端口,进入shell工具查看Linux系统虚拟机的IP地址
inte 后面的就是IP地址,这时候打开win+R输入cmd命令,通过telnet命令,测试端口是否畅通。如果连接失败,表示CentOS的6379端口没有开启。
首先输入firewall-cmd --query-port=6379/tcp,如果返回结果为no,那么证明6379端口确实没有开启。
接着输入firewall-cmd --add-port=6379/tcp,将6379端口开启,返回success。
最后然后再执行上一条命令,返回yes,证明端口已经成功开启。
开启端口成功之后再用cmd命令重复上述telnet命令一遍,出现小黑框闪烁一下说明连接没有问题。
最后开启redis desktop manager(可视化工具),auth为redis密码,可以设置,也可以不设置,但是提个醒在云服务器上安装redis最好设置密码,设置密码和绑定ip,二选一即可,否则redis处于保护模式,只能本虚拟机访问