can't connect to redis-server

阿里云服务器上安装了redis,然后用RedisDesktopManager 来连接远程服务器上的redis服务,一直报这个错误,但是我在服务器都可以使用命令进行操作,证明reids服务是正常的,

首先,来分析下原因,

 

1.阿里云服务器,当设计到端口的时候,一定要配置安全组,进行开放端口,

     解决:

       阿里云配置下6379端口的安全组就好了

2.linux中防火墙开放端口,这边也要开放下6379端口

       解决:

        执行这行命令就可以了, firewall-cmd --zone=public --add-port=3306/tcp --permanent 

改完了之后,发现还是联不上,于是怀疑是不是访问网络的问题,然后我cmd用telnet一下我服务器的ip和端口

报了一串错误

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.

看的我头有点大,然后百度了一下,发现还要修改下redis的配置文件,redis.conf

1.把 bind 127.0.0.1 注释掉

 

2.protected-mode yes    把yes改为no

 

当我以为这些东西配置完成了之后,就可了,重启redis服务,再次连接的时候,结果还是报了这个错误,Too young, Too simple

脑壳疼,啊~   西八。。。。。。。

3.又查了下资料,发现这样的一个坑爹的设定

     由于我之前启动redis-server并没有指定配置文件,而Linux上的redis比较操蛋的一点就是如果你不指定配置文件去启动,那么你做的修改就没有用,会读取默认配置  ,,我原本以为redis.conf就是他默认的配置,但是改完发现居然并不是,必须要指定你修改了之后的配置文件启动才可以。

 



 

于是再次进入src目录下,执行了这行命令,指定了启动的配置文件

     ./redis-server ../redis.conf

然后再次连接,,,终于可以连接了~  

 

 

顺便记录下reids的相关命令

ps aux | grep redis              查看redis是否启动成功

netstat -tlun                        查看主机的6379端口是否在使用(监听)

./redis-cli                   打开redis的客户端    

quit                            退出redis的客户端

pkill redis-server                  关闭redis服务器

./redis-cli shutdown            也可以通过这条命令关闭redis服务器

 

 

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值