redis开启远程登录

转载自:https://blog.csdn.net/csdn_0911/article/details/105096630

===========

 

如果是首次安装,那么就需要改一下redis的配置文件

vim ./data/redis-5.0.2/redis.conf 编辑以下内容:

1、# bind 127.0.0.1 防止远程连接不上
2、daemonize yes #后台运行
3、protected-mode no #关闭保护模式

 

重新启动就好了。

注意: 如果此刻应用服务还是会报错,要记得应用服务也要重启

 

 

报错定位如下(附):

Caused by: io.lettuce.core.RedisException: io.lettuce.core.RedisConnectionException: 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.

根据日志提示,先检查一下网络

telnet ip 6379

超时,果然连接不上了,打开redis服务是不是异常了?

验证方法:ps -ef|grep redis

*/redis-server *:6379 中通过"*"就可以看出此时是允许所有的ip连接登录到这台redis服务上。

我看的时候不存在上面 11034 这个线程。

没有redis服务,重启试一下,时间长了,忘记路径在哪里了,根目录搜一下:find . -name "*redis.*"

可以查到 /data/redis-5.0.2/redis.conf

cd /data/redis-5.0.2/src

./redis-server ../redis.conf #根据配置文件启动

如上图启用成功。

 

posted @ 2023-02-28 10:20  larybird  阅读(224)  评论(0编辑  收藏  举报