首页 > 编程知识 正文

redis安装配置 windows,linux修改redis配置文件

时间:2023-05-06 04:07:23 阅读:240250 作者:4139

项目运行报错,大概意思是因为redis安全模式的原因,无法连接redis。根据网上提供的解决方法,需要更改redis配置文件,windows对应的配置文件是redis.windows.conf

根据网上意见注释掉bind 127.0.0.1和修改protected-mode为no后,重启redis服务,发现还是连不上redis服务:

org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: java.net.SocketException: Connection reset by peer org.springframework.data.redis.RedisConnectionFailureException: java.net.SocketException: Broken pipe; org.springframework.data.redis.RedisConnectionFailureException: Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisDataException: 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端口后依旧提示安全模式原因无法连接redis,想来想去应该是没有加载配置文件,于是上网查了一下redis配置文件的重启方式,命令行使用以下代码启动:

redis-server redis.windows.conf

启动后发现项目恢复正常,头大,走了不少弯路

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。