redis碰到的问题

SpringBoot整合redis 连接报错:

Unable to connect to Redis; nested exception is org.springframework.data.redis.connection.PoolException: Could not get a resource from the pool; nested exception is io.lettuce.core.RedisConnectionException

解决方法:给访问redis设置密码
redis设置密码

重启redis后密码失效:

原因可能有两个:

1、只是单纯的通过命令行设置了密码,这种设置方式是临时的,当服务器重启后,密码会失效。

config set requirepass yourPassword
解决方案:在redis的配置文件中直接配置密码

配置文件中有一行是这样的

#requirepass foobared 

如何快速找到内容位置? /关键字 回车 n 就可以下一个
去掉注释,并且把foobared改为自己的密码

如:

requirepass mypwd
2、如果你已经按照上面的方法在配置文件中设置了密码,但启动后仍旧无效,说明你肯定没有指定配置文件运行。服务端也会报出如下警告:

Warning: no config file specified, using the default config.

#windows下正确redis的的启动方式:
redis-server.exe redis.windows.conf 

#linux下正确redis的启动方式 redis-server 后面加上路径
redis-server redis.conf 

在指定了配置文件后,再启动就可以读取到设置的密码了。

终端中redis启动报错

WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
overcommit_memory 解决
给 /etc/sysctl.conf 配置文件中 添加 vm.overcommit_memory=1
并且

$ sysctl vm.overcommit_memory=1
vm.overcommit_memory = 1

再次查看配置,已经修改成1了
$ cat /proc/sys/vm/overcommit_memory 
1
posted @   没有烦恼的猫猫  阅读(836)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~
点击右上角即可分享
微信分享提示