redis杂记

来源:互联网 发布:苏联知乎 编辑:程序博客网 时间:2024/05/31 15:19

redis:

使用redis出现Cannot get Jedis connection; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Could not get a resource from the pool错误信息

查看Could not get a resource from the pool获取redis链接异常,使用redis命令查询连接数:

1、redis-cli进入redis命令行

2、info clients查看客户端连接信息

3、config get maxclients查询最大支持客户端连接数

21远小于10000不是redis连接数的问题

4、在redis安装目录下查找redis.config配置文件找到日志放置的位置

5、查看redis的日志文件发现无异常

6、google上有人说 when redis-server memery is full,then it's exception will be show.

7、使用info memory查看redis server的内存使用情况


8、网友建议open config
maxmemory-policy volatile-lru
and then set key expire

试了并没有解决

设置方式  

     config set maxmemory-policy volatile-lru

maxmemory-policy 六种方式

     1、volatile-lru:只对设置了过期时间的key进行LRU(默认值) 

     2、allkeys-lru : 删除lru算法的key   

     3、volatile-random:随机删除即将过期key   

     4、allkeys-random:随机删除   

     5、volatile-ttl : 删除即将过期的   

     6、noeviction : 永不过期,返回错误


9、另有网友说在redis.conf中添加maxclients有解决他的问题,注意redis.conf中的参数字母大小写不能错;改完无反应;

10、远程使用telnet连接redis报错:


redis以保护模式运行拒绝远程连接;需要禁用protected-mode

redis.conf中加入daemonize no    protected-mode no之后重新启动

src/redis-server ./redis.conf命令启动使用redis.conf作为指定配置

不知道有没有用,之后同事说他把密码注释了就可以连接了~~~~~~~~~~~~~~~~/(ㄒoㄒ)/~~




0 0
原创粉丝点击