赞
踩
redis在无密码,启动保护模式下,只能通过127.0.0.1访问,否则报以下错误11
- io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information: /10.8.33.128:6379
- 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)
- at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:616)
- at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:563)
- at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:480)
- at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:442)
- at io.netty.util.concurrent.SingleThreadEventExecutor$5.run(SingleThreadEventExecutor.java:884)
- at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
- at java.lang.Thread.run(Thread.java:748)
- Caused by: java.net.ConnectException: Connection refused: no further information
- ... 11 common frames omitted
- 2019-12-02 08:53:53.052 [DEBUG] [lettuce-nioEventLoop-6-1] io.lettuce.core.RedisChannelHandler - close()
- 2019-12-02 08:53:53.052 [DEBUG] [lettuce-nioEventLoop-6-1] io.lettuce.core.protocol.DefaultEndpoint - [unknown, epid=0x1] close()
- 2019-12-02 08:53:53.053 [DEBUG] [lettuce-nioEventLoop-6-1] io.lettuce.core.protocol.CommandHandler - [channel=0x90b73150, [id: 0x77cd9026] (inactive), chid=0x1] channelUnregistered()
- 2019-12-02 08:53:53.054 [ERROR] [Job-Thread-1] o.s.s.support.TaskUtils$LoggingErrorHandler - Unexpected error occurred in scheduled task.
- org.springframework.data.redis.RedisConnectionFailureException: Unable to connect to Redis; nested exception is io.lettuce.core.RedisConnectionException: Unable to connect to 10.8.33.128:6379
- at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:966)
- at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getConnection(LettuceConnectionFactory.java:934)
- at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getSharedConnection(LettuceConnectionFactory.java:786)
- at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory.getConnection(LettuceConnectionFactory.java:300)
- at org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection(RedisConnectionUtils.java:132)
- at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:95)
- at org.springframework.data.redis.core.RedisConnectionUtils.getConnection(RedisConnectionUtils.java:82)
- at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:211)
- at org.springframework.data.redis.core.RedisTemplate.execute(RedisTemplate.java:184)
- at org.springframework.data.redis.core.AbstractOperations.execute(AbstractOperations.java:95)
- at org.springframework.data.redis.core.DefaultValueOperations.get(DefaultValueOperations.java:48)
- at com.bzl.face.common.util.RedisUtil.get(RedisUtil.java:43)
- at com.bzl.face.system.schedule.UdpInactiveTask.inactiveCheck(UdpInactiveTask.java:41)
- at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
- at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
- at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
- at java.lang.reflect.Method.invoke(Method.java:498)
- at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84)
- at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54)
- at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
- at java.util.concurrent.FutureTask.runAndReset$$$capture(FutureTask.java:308)
- at java.util.concurrent.FutureTask.runAndReset(FutureTask.java)
- at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
- at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
- at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
- at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
- at java.lang.Thread.run(Thread.java:748)
- Caused by: io.lettuce.core.RedisConnectionException: Unable to connect to 10.8.33.128:6379
- at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56)
- at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:233)
- at io.lettuce.core.RedisClient.connectStandalone(RedisClient.java:253)
- at io.lettuce.core.RedisClient.connect(RedisClient.java:202)
- at org.springframework.data.redis.connection.lettuce.StandaloneConnectionProvider.getConnection(StandaloneConnectionProvider.java:56)
- at org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory$SharedConnection.getNativeConnection(LettuceConnectionFactory.java:959)
- ... 26 common frames omitted
查redis配置文件,“protected-mode yes”配置项上面的注释可得知以下:
- 1、当redis配置文件中绑定了bind 127.0.0.1时,表示只能通过绑定的地址访问的Redis,默认此项
- 2、当需要绑定多个ip时,用空格隔开
- 3、当不绑定时,表示可以任意ip访问;但此时若保护模式protected-mode yes开启了,就必须设置密码,否则也只能通过127.0.0.1访问
因此
- 1、bind 127.0.0.1 只能127.0.0.1访问
- 2、#bind 127.0.0.1 protected-mode yes #requirepass foobared 只能127.0.0.1访问
-
- 3、#bind 127.0.0.1 protected-mode yes requirepass 123456 可以任意ip访问
- 3、#bind 127.0.0.1 protected-mode no 可以任意ip访问
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。