Redis教程

Redis问题集棉

本文主要是介绍Redis问题集棉,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1. 现象:基本上系统第二天使用时就会出现Redis连不上的问题,再次连接又好了

org.springframework.data.redis.RedisSystemException: Redis exception; nested exception is io.lettuce.core.RedisException: java.io.IOException: Connection reset by peer


	at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:74)


	at org.springframework.data.redis.connection.lettuce.LettuceExceptionConverter.convert(LettuceExceptionConverter.java:41)


	at org.springframework.data.redis.PassThroughExceptionTranslationStrategy.translate(PassThroughExceptionTranslationStrategy.java:44)


	at org.springframework.data.redis.FallbackExceptionTranslationStrategy.translate(FallbackExceptionTranslationStrategy.java:42)


	at org.springframework.data.redis.connection.lettuce.LettuceConnection.convertLettuceAccessException(LettuceConnection.java:272)


	at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.convertLettuceAccessException(LettuceStringCommands.java:800)


	at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.get(LettuceStringCommands.java:70)


	at org.springframework.data.redis.connection.DefaultedRedisConnection.get(DefaultedRedisConnection.java:267)


	at org.springframework.data.redis.connection.DefaultStringRedisConnection.get(DefaultStringRedisConnection.java:406)


	at org.springframework.data.redis.core.DefaultValueOperations$1.inRedis(DefaultValueOperations.java:57)


	at org.springframework.data.redis.core.AbstractOperations$ValueDeserializingRedisCallback.doInRedis(AbstractOperations.java:60)


	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:222)


	at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:189)


	at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:96)


	at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:53)
Caused by: io.lettuce.core.RedisException: java.io.IOException: Connection reset by peer


	at io.lettuce.core.internal.Exceptions.bubble(Exceptions.java:83)


	at io.lettuce.core.internal.Futures.awaitOrCancel(Futures.java:250)


	at io.lettuce.core.FutureSyncInvocationHandler.handleInvocation(FutureSyncInvocationHandler.java:75)


	at io.lettuce.core.internal.AbstractInvocationHandler.invoke(AbstractInvocationHandler.java:80)


	at com.sun.proxy.$Proxy260.get(Unknown Source)


	at org.springframework.data.redis.connection.lettuce.LettuceStringCommands.get(LettuceStringCommands.java:68)


	... 85 common frames omitted


Caused by: java.io.IOException: Connection reset by peer


	at sun.nio.ch.FileDispatcherImpl.read0(Native Method)


	at sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39)


	at sun.nio.ch.IOUtil.readIntoNativeBuffer(IOUtil.java:223)


	at sun.nio.ch.IOUtil.read(IOUtil.java:192)


	at sun.nio.ch.SocketChannelImpl.read(SocketChannelImpl.java:380)


	at io.netty.buffer.PooledByteBuf.setBytes(PooledByteBuf.java:253)


	at io.netty.buffer.AbstractByteBuf.writeBytes(AbstractByteBuf.java:1134)


	at io.netty.channel.socket.nio.NioSocketChannel.doReadBytes(NioSocketChannel.java:350)


	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:151)


	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:719)


	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:655)


	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:581)


	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:493)


	at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:989)


	at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)


	at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)


	... 1 common frames omitted

 原因:docker设置了超过空闲时间就会断开连接,所以从连接池拿到被断开的连接时就会报错。

    解决办法:

 lettuce:
    cluster:
        refresh:
          adaptive: true
          #20秒自动刷新一次
          period: 20

  可参考:https://www.cnblogs.com/shouyaya/p/14607270.html

 

这篇关于Redis问题集棉的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!