redis连接错误处理方案分享
今天为了搞压测,定位是不是redis瓶颈。
在我们的服务器10.90.2.101上安装了一个redis,版本(redis-3.2.8.tar.gz),没有做任何配置,直接make & make install后,就启动了。 在IDEA里面,将工程的配置文件内容,redis的IP信息改成10.90.2.101.
spring.redis.hostName=10.90.2.101
启动我们的应用AI程序,后台老是报错,这个错误,是我们全局锁的逻辑里面,开始以为是setNX的使用有问题。
org.springframework.data.redis.RedisConnectionFailureException: Unexpected end of stream.; nested exception is redis.clients.jedis.exceptions.JedisConnectionException: Unexpected end of stream.
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:)
at org.springframework.data.redis.connection.jedis.JedisExceptionConverter.convert(JedisExceptionConverter.java:)
at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:)
at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:)
at org.springframework.data.redis.connection.jedis.JedisConnection.convertJedisAccessException(JedisConnection.java:)
at org.springframework.data.redis.connection.jedis.JedisConnection.close(JedisConnection.java:)
at org.springframework.data.redis.connection.jedis.JedisConnection.<init>(JedisConnecti
分析了一整子,找不出原因,因为,我们这个redis的安装,和另外一个使用很久了的redis没有什么本质差别。
网上查看,有我遇到的这种错误。比较多的说法是下面这个:
config set client-output-buffer-limit "normal 1048576 1048576 60 slave 268435456 67108864 60 pubsub 33554432 8388608 60"
我处理了,但是还是没有用!
为了验证,是不是连接没有建立好,就在setNX的前面,执行一次最简单的Set操作:
stringRedisTemplate.opsForValue().set("Hello","TKONLINE");
最后,在命令行查看是否写入数据:
127.0.0.1:[]> keys *
(empty list or set)
奇怪吧,没有数据!
于是,将redis-cli的指令,指向这台机器的IP,进行再次测试,因为之前也遇到过类似的问题。
[root@localhost home]# redis-cli -h 10.90.2.101 -p
10.90.2.101:> select
(error) 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: ) 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. ) 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. ) If you started the server manually just for testing, restart it with the '--protected-mode no' option. ) 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工作在保护模式,没有绑定IP,无需认证密码。后面还有说,这种模式下,只能支持回环IP地址访问。
有4种解除保护模式的方案:
1) 在回环IP地址连接的情况下,执行 CONFIG SET protected-mode no, 为了永久有效,需要执行 CONFIG REWRITE
2) 修改配置文件,将里面的protected mode option设置为 'no',并重启redis server。推荐使用这种模式!
3) 也可以在启动redis server的时候,指定option。例如 redis-server --protected-mode no
4) 设置一个绑定的IP地址,或者认证密码。
我测试过程中,采用的是第一种:
[root@localhost home]# redis-cli
127.0.0.1:> CONFIG SET protected-mode no
OK
127.0.0.1:> exit
[root@localhost home]# redis-cli -h 10.90.2.101 -p
10.90.2.101:> select
OK
10.90.2.101:[]> keys *
(empty list or set)
10.90.2.101:[]> keys *
) "Hello"
10.90.2.101:[]> CONFIG REWRITE
OK
10.90.2.101:[]>
这样配置之后,再次测试我的AI程序。就没有再报错误!
redis连接错误处理方案分享的更多相关文章
- redis连接错误3种解决方案System Error MISCONF Redis is configured to save RDB snapshots
redis连接错误System Error MISCONF Redis is configured to save RDB snapshots, but XX 情况1解决办法: 由于强制停止red ...
- php多进程单例模式下的 MySQL及Redis连接错误修复
前几天写了个php常驻脚本,主要逻辑如下 //跑完数据后休息60秒 $sleepTime = 60; $maxWorker = 10; while (true) { $htmlModel = new ...
- redis连接错误
连接redis错误:ERR Client sent AUTH, but no password is set 2018-07-04 20:33 by robinli, 4367 阅读, 0 评论, 收 ...
- 解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to...
今天Redis服务器在连接redis数据库时突然报错:MISCONF Redis is configured to save RDB snapshots, but it is currently no ...
- laravel 项目表单中有csrf_token,但一直报错419错误 解决redis连接错误:MISCONF Redis is configured to save RDB snapshots, but it is currently not able to persi
laravel 项目表单中有csrf_token,但一直报错419错误,因为项目中使用到Redis缓存,在强制关闭Redis后出现的问题,查询laravel.log文件查找相关问题 安装redis后在 ...
- windows redis 连接错误Creating Server TCP listening socket 127.0.0.1:637 9: bind: No error
报错信息如下: [10036] 30 Dec 10:23:49.616 # Creating Server TCP listening socket 127.0.0.1:637 9: bind: No ...
- Go语言之从0到1实现一个简单的Redis连接池
Go语言之从0到1实现一个简单的Redis连接池 前言 最近学习了一些Go语言开发相关内容,但是苦于手头没有可以练手的项目,学的时候理解不清楚,学过容易忘. 结合之前组内分享时学到的Redis相关知识 ...
- Swoole Redis 连接池的实现
概述 这是关于 Swoole 入门学习的第九篇文章:Swoole Redis 连接池的实现. 第八篇:Swoole MySQL 连接池的实现 第七篇:Swoole RPC 的实现 第六篇:Swoole ...
- Spring-Boot-操作-Redis,三种方案全解析!
在 Redis 出现之前,我们的缓存框架各种各样,有了 Redis ,缓存方案基本上都统一了,关于 Redis,松哥之前有一个系列教程,尚不了解 Redis 的小伙伴可以参考这个教程: Redis 教 ...
随机推荐
- linux 基础命令使用
Centos中查看系统信息的常用命令 系统日志文件(可以通过cat或tail命令来查看) /var/log/message 系统启动后的信息和错误日志,是Red Hat Linux中最常用的日志之一 ...
- [LeetCode&Python] Problem 690. Employee Importance
You are given a data structure of employee information, which includes the employee's unique id, his ...
- BZOJ4426 :最大生产率(贪心+决策单调性DP)
题意:给出N个人,现在让你分P组,每组的工作效率是最小结束时间-最大开始时间,要求每一组的效率的正数,求最大效率和.N<1000 思路: 把包含至少一个其他的分到A组:否则到B组. A组的要么单 ...
- EasyUI datagrid 数据加载
网上找了好多人的方法发现都有问题发一个可用方便的 主要分三种情况 加载1,loaddata 加载2,datagrid 加载3, url 加载 第一部分,datagrid加载 第二部分,点击 datag ...
- C++数组排序
#include<stdio.h> #include<stdlib.h> #include<windows.h> #define SIZE 5 //数组中元素的数量 ...
- 《DSP using MATLAB》Problem 6.14
代码: %% ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ %% Output In ...
- spring+springMVC,声明式事务失效,原因以及解决办法
http://blog.csdn.net/z69183787/article/details/37819627#comments 一.声明式事务配置: <bean id="transa ...
- 【MAC】常用方法-持续更新
1.Homebrew安装 删除brew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/ma ...
- 【BZOJ1492】【NOI2007】货币兑换
我果然不会斜率优化 原题: 小Y最近在一家金券交易所工作.该金券交易所只发行交易两种金券:A纪念券(以下简称A券)和 B纪念券(以下 简称B券).每个持有金券的顾客都有一个自己的帐户.金券的数目可以是 ...
- CH#46A 磁力块
题意 磁力块 CH Round #46 - 「Adera 8」杯NOI模拟赛 描述 在一片广袤无垠的原野上,散落着N块磁石.每个磁石的性质可以用一个五元组(x,y,m,p,r)描述,其中x,y表示其坐 ...