連接Redis集羣報 Unable to connect to 127.0.0.1:7008
錯誤現象
application.yaml中配置如下
spring:
cache:
type: redis
redis:
time-to-live: 60000
redis:
cluster:
max-redirects: 3
nodes:
- 10.10.4.248:7001
- 10.10.4.248:7002
- 10.10.4.248:7003
- 10.10.4.248:7004
- 10.10.4.248:7005
- 10.10.4.248:7006
- 10.10.4.248:7007
- 10.10.4.248:7008
- 10.10.4.248:7009
使用時出現如下描述
[2019-09-16 16:55:25.122] [lettuce-nioEventLoop-4-2] [WARN ] [DESKTOP-MNOLKS2/192.168.107.1] [] [i.l.core.cluster.topology.ClusterTopologyRefresh] [] [] [] [
Unable to connect to 127.0.0.1:7008
java.util.concurrent.CompletionException: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /127.0.0.1:7008
at java.util.concurrent.CompletableFuture.encodeThrowable(CompletableFuture.java:292)
at java.util.concurrent.CompletableFuture.completeThrowable(CompletableFuture.java:308)
at java.util.concurrent.CompletableFuture.uniApply(CompletableFuture.java:593)
at java.util.concurrent.CompletableFuture$UniApply.tryFire(CompletableFuture.java:577)
at java.util.concurrent.CompletableFuture.postComplete(CompletableFuture.java:474)
at java.util.concurrent.CompletableFuture.completeExceptionally(CompletableFuture.java:1977)
at io.lettuce.core.AbstractRedisClient.lambda$initializeChannelAsync0$4(AbstractRedisClient.java:329)
at io.netty.util.concurrent.DefaultPromise.notifyListener0(DefaultPromise.java:511)
at io.netty.util.concurrent.DefaultPromise.notifyListeners0(DefaultPromise.java:504)
at io.netty.util.concurrent.DefaultPromise.notifyListenersNow(DefaultPromise.java:483)
at io.netty.util.concurrent.DefaultPromise.notifyListeners(DefaultPromise.java:424)
at io.netty.util.concurrent.DefaultPromise.tryFailure(DefaultPromise.java:121)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.fulfillConnectPromise(AbstractNioChannel.java:327)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:343)
at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:665)
at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:612)
at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:529)
at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:491)
at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:905)
at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
at java.lang.Thread.run(Thread.java:748)
Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /127.0.0.1:7008
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:717)
at io.netty.channel.socket.nio.NioSocketChannel.doFinishConnect(NioSocketChannel.java:327)
at io.netty.channel.nio.AbstractNioChannel$AbstractNioUnsafe.finishConnect(AbstractNioChannel.java:340)
... 7 common frames omitted
Caused by: java.net.ConnectException: Connection refused: no further information
... 11 common frames omitted
錯誤原因
集羣配置錯誤,創建集羣時應該使用客戶端可以訪問到的IP地址(而不是使用127.0.0.1),示例
redis-trib.rb create --replicas 1 10.10.4.248:7001 10.10.4.248:7002 10.10.4.248:7003 10.10.4.248:7004 10.10.4.248:7005 10.10.4.248:7006