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 教 ...
随机推荐
- python day08作业
- PAT 乙级 1066. 图像过滤(15)
图像过滤是把图像中不重要的像素都染成背景色,使得重要部分被凸显出来.现给定一幅黑白图像,要求你将灰度值位于某指定区间内的所有像素颜色都用一种指定的颜色替换. 输入格式: 输入在第一行给出一幅图像的分辨 ...
- OSPF路由协议(二)
实验要求:使用OSPF路由协议,使每个路由器都能收集到所有网段 拓扑如下: 配置如下: R1enableconfigure terminalinterface l0ip address 192.168 ...
- 找出n个自然数(1,2,3,……,n)中取r个数的组合
<?php /** * 对于$n和$r比较小, 可以用这种方法(当n=5, r=3时) */ function permutation1($n, $r) { for($i=1; $i<=$ ...
- gcc/g++ 使用 tricks
0. 优化级别 -O0,不进行优化的编译后的文件大小反而更小,小于 -O2 的: 1. -std 指定 C 语言标准 -ansi -ansi == -std=c90 -std=c99:(std:sta ...
- MySQL内置功能
视图 # 创建视图 create view course2teacher as select * from course inner join teacher on course.teacher_id ...
- Pytorch使用多GPU
在caffe中训练的时候如果使用多GPU则直接在运行程序的时候指定GPU的index即可,但是在Pytorch中则需要在声明模型之后,对声明的模型进行初始化,如: cnn = DataParallel ...
- scrapt中的数据提取,采用js2xml库
这个一个爬去美团的例子,应为数据都是在script中,小心封ip,尽量少运行. 先导入库几个库 import requests from bs4 import BeautifulSoup from l ...
- Arcgis API for JS——打印控件乱码
在通过Arcgis API for JS编写打印控件进行地图下载时,总发现地图字体乱码,如下图: 解决方法: 在装有ArcGIS Server,要调用服务的电脑或服务器上找到下图文件夹
- lesson5rnns-fastai
32min 如何确定embedding个数即嵌入矩阵容量?:不确定:与文本的字数关系不大,关键是语言的复杂度和需要解决的问题类型 embedding的效果要比one hot编码的效果好