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 教 ...
随机推荐
- 本周java 学习进度报告
本周java 学习进度报告 本周对我的感触很深,因为这是我初学java 语言的第一周,我认识到java 和c语言是有很多的不同之处和相同之处.我这几天几乎是在研究java 基础入门知识,而并没有太多的 ...
- Proxy --概述篇
概述: Proxy 用于修改某些操作的默认行为,等同于在语言层面做出修改,所以属于一种“元编程”(meta programming),即对编程语言进行编程. Proxy 可以理解成,在目标对象之前架设 ...
- [link] 构建负载均衡服务器之一 负载均衡与集群详解
一.什么是负载均衡 首先我们先介绍一下什么是负载均衡: 负载平衡(Load balancing)是一种计算机网络技术,用来在多个计算机(计算机集群).网络连接.CPU.磁盘驱动器或其他资源中分配负载, ...
- java数组排序(插入排序、冒泡排序、选择排序)与递归 代码示例
import java.util.Scanner; public class OrderBy { public static void main(String[] args) { // Scanner ...
- str 类型
1.capitalize():首字母大写 2.center(size,fillwith): 3.count(sub,start,end):计算子序列的个数 4.decode() 5.encode() ...
- Anaconda 的基本使用
Anaconda常用的Python版本管理工具和Python包管理软件,conda是Anaconda中的具体管理工具,下载地址为: https://www.anaconda.com/distribut ...
- Python之路,第十六篇:Python入门与基础16
python3 bytes 和 bytearrary bytes 二进制文件的读写: 什么是二进制文件读: 文件中以字节(byte)为单位存储,不以换行符(\n)为单位分隔内容的文件: f = o ...
- 九度OJ1451题-信封错装
题目1451:不容易系列之一 时间限制:1 秒 内存限制:128 兆 特殊判题:否 提交:2004 解决:1210 题目描述: 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了!做好“ ...
- templates的语法
1.变量 1.作用:将后端的数据传递到模板进行显示 2.允许作为变量的数据类型 字符串,整数,列表,元组,字典,函数,对象 3.变量的语法 变量传递给前端必须要封装到字典中才能传递给模板 1.使用 l ...
- 使用NATS替换NSQ为后台服务解耦
简介 满世界的后台都在向微服务架构发展,我对微服务的理解是将一个复杂的业务分拆为多个服务,由多个服务协作完成一个服务:在后台微服务架构时需要考虑高可用.一致性等问题,也要考虑在实现上.编码上的复杂程度 ...