今天为了搞压测,定位是不是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连接错误处理方案分享的更多相关文章

  1. 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 ...

  2. php多进程单例模式下的 MySQL及Redis连接错误修复

    前几天写了个php常驻脚本,主要逻辑如下 //跑完数据后休息60秒 $sleepTime = 60; $maxWorker = 10; while (true) { $htmlModel = new ...

  3. redis连接错误

    连接redis错误:ERR Client sent AUTH, but no password is set 2018-07-04 20:33 by robinli, 4367 阅读, 0 评论, 收 ...

  4. 解决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 ...

  5. 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后在 ...

  6. 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 ...

  7. Go语言之从0到1实现一个简单的Redis连接池

    Go语言之从0到1实现一个简单的Redis连接池 前言 最近学习了一些Go语言开发相关内容,但是苦于手头没有可以练手的项目,学的时候理解不清楚,学过容易忘. 结合之前组内分享时学到的Redis相关知识 ...

  8. Swoole Redis 连接池的实现

    概述 这是关于 Swoole 入门学习的第九篇文章:Swoole Redis 连接池的实现. 第八篇:Swoole MySQL 连接池的实现 第七篇:Swoole RPC 的实现 第六篇:Swoole ...

  9. Spring-Boot-操作-Redis,三种方案全解析!

    在 Redis 出现之前,我们的缓存框架各种各样,有了 Redis ,缓存方案基本上都统一了,关于 Redis,松哥之前有一个系列教程,尚不了解 Redis 的小伙伴可以参考这个教程: Redis 教 ...

随机推荐

  1. pycharm 利用virtualenv为每个项目配置venv

    1.在某个位置安装一个虚拟环境 2.项目运行是配置virtualenv生成的环境 3.重启terminal 安装依赖: exp => pip install django

  2. 【webdriver自动化】整理API框架(主要是关键字,具体例子在本地)

    1. 获取网页源码 pageSource = self.driver.page_source print pageSource.encode("gbk","ignore& ...

  3. phantomjs 抓取、截图中文网站乱码的问题的解决

    用phantomjs抓取html乱码的解决方案: phantomjs --output-encoding=gbk test.js http://webscan.360.cn/index/checkwe ...

  4. Spring cron表达式详解

    一个cron表达式有6个必选的元素和一个可选的元素,各个元素之间是以空格分隔的,从左至右,这些元素的含义如下表所示: 代表含义 是否必须 允许的取值范围 允许的特殊符号 秒 是 0-59 , - * ...

  5. TP thinkphp 权限管理 权限认证 功能

    (如有打扰,请忽略)阿里云ECS大羊群,2U4G低至1.4折,限实名新用户,需要的点吧https://promotion.aliyun.com/ntms/act/vm/aliyun-group/tea ...

  6. (15)javaScript入门

    什么是javaScript HTML用来做页面的架构,CSS用来做页面样式的布局 javaScript就是用来完成页面用户交互的,JS写的就是叫脚本 js就是弱语言类型,不同类型的时候可以相互转换 j ...

  7. C++学习(十七)(C语言部分)之 指针

    复习 数组定义格式 类型 数组名[数组大小]数组名+下标 int arr[2][3]={{1,2,3},{4,5,6}}; int arr[][3]={1,2,3,4,5,6};//二维数组定义的时候 ...

  8. hdu2328 Corporate Identity 扩展KMP

    Beside other services, ACM helps companies to clearly state their “corporate identity”, which includ ...

  9. jsp中的include静态包含与动态包含,

    d动态包含与静态包含的最大区别是 静态包含:<%@ include file = "文件名.jsp"%>,在<body>的标签外定义.在没有编译的时候,两个 ...

  10. (惊艳)hashmap的理解(映射)

    第一: hashmap在内存中是长这样的,数组+链表的形式 // HashMap采用链表法解决冲突,每一个Entry本质上是一个单向链表 transient Entry[] table; 第二:  p ...