DENIED Redis is running in protected mode because protected mode is enabled, no bind address was ...

文章讲述了在ApacheFlink流处理应用中,使用Jedis连接Redis时遇到的protectedmode启用问题,提供了解决方案,包括临时禁用保护模式、编辑配置文件或设置bind地址和密码。
摘要由CSDN通过智能技术生成

Caused by: redis.clients.jedis.exceptions.JedisDataException: 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: 1) 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. 2) 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. 3) If you started the server manually just for testing, restart it with the '--protected-mode no' option. 4) 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.

at redis.clients.jedis.Protocol.processError(Protocol.java:117)

at redis.clients.jedis.Protocol.process(Protocol.java:151)

at redis.clients.jedis.Protocol.read(Protocol.java:205)

at redis.clients.jedis.Connection.readProtocolWithCheckingBroken(Connection.java:297)

at redis.clients.jedis.Connection.getIntegerReply(Connection.java:222)

at redis.clients.jedis.Jedis.hset(Jedis.java:606)

at org.apache.flink.streaming.connectors.redis.common.container.RedisContainer.hset(RedisContainer.java:84)

at org.apache.flink.streaming.connectors.redis.RedisSink.invoke(RedisSink.java:155)

at org.apache.flink.streaming.api.functions.sink.SinkFunction.invoke(SinkFunction.java:50)

at org.apache.flink.streaming.api.operators.StreamSink.processElement(StreamSink.java:54)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:82)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:57)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:29)

at org.apache.flink.streaming.runtime.tasks.BroadcastingOutputCollector.collect(BroadcastingOutputCollector.java:77)

at org.apache.flink.streaming.runtime.tasks.BroadcastingOutputCollector.collect(BroadcastingOutputCollector.java:32)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:56)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:29)

at org.apache.flink.streaming.api.operators.StreamMap.processElement(StreamMap.java:38)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:82)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:57)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:29)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:56)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:29)

at org.apache.flink.streaming.api.operators.StreamFilter.processElement(StreamFilter.java:39)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:82)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:57)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:29)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:56)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:29)

at org.apache.flink.streaming.api.operators.StreamFilter.processElement(StreamFilter.java:39)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:82)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:57)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:29)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:56)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:29)

at org.apache.flink.streaming.api.operators.StreamFilter.processElement(StreamFilter.java:39)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.pushToOperator(CopyingChainingOutput.java:82)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:57)

at org.apache.flink.streaming.runtime.tasks.CopyingChainingOutput.collect(CopyingChainingOutput.java:29)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:56)

at org.apache.flink.streaming.api.operators.CountingOutput.collect(CountingOutput.java:29)

at org.apache.flink.streaming.api.operators.StreamSourceContexts$NonTimestampContext.collect(StreamSourceContexts.java:197)

at org.apache.flink.streaming.api.operators.StreamSourceContexts$NonTimestampContext.collectWithTimestamp(StreamSourceContexts.java:204)

at org.apache.flink.streaming.api.operators.StreamSourceContexts$SwitchingOnClose.collectWithTimestamp(StreamSourceContexts.java:108)

at org.apache.flink.streaming.connectors.kafka.internals.AbstractFetcher.emitRecordsWithTimestamps(AbstractFetcher.java:365)

at org.apache.flink.streaming.connectors.kafka.internals.KafkaFetcher.partitionConsumerRecordsHandler(KafkaFetcher.java:183)

at org.apache.flink.streaming.connectors.kafka.internals.KafkaFetcher.runFetchLoop(KafkaFetcher.java:142)

at org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumerBase.run(FlinkKafkaConsumerBase.java:826)

at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:116)

at org.apache.flink.streaming.api.operators.StreamSource.run(StreamSource.java:73)

at org.apache.flink.streaming.runtime.tasks.SourceStreamTask$LegacySourceFunctionThread.run(SourceStreamTask.java:323)

将文件位置切换为redis文件夹下的src中

进入redis数据库

redis-cli

执行

CONFIG SET protected-mode no

结果

  • 18
    点赞
  • 29
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
### 回答1: Redis 被拒绝连接,因为 Redis 正在运行保护模式。这是因为保护模式被启用,但没有指定绑定地址,并且没有要求客户端身份验证密码。在这种模式下,只有从回环接口接受的连接才会被接受。如果您想连接 Redis,则必须在配置文件中针对 IP 地址/主机名进行正确的配置。 ### 回答2: 这个错误提示意思是Redis运行在保护模式下,因为启用了保护模式,没有指定绑定的地址,也没有要求客户端提供身份验证密码。在这种模式下,只有通过回环接口才能接受连接。如果你想要连接Redis,有几种解决方法。 第一种方法是修改Redis配置文件,使其在启动时绑定一个地址,例如,可以在Redis配置文件中添加以下行: bind 0.0.0.0 这将绑定Redis到所有可用的网络接口上。如果您只希望允许来自本地机器的连接,则可以使用以下配置项: bind 127.0.0.1 这将只允许来自本地机器的连接。 第二种方法是在客户端连接时提供身份验证密码。可以通过在Redis配置文件中设置requirepass选项来启用Redis身份验证。设置此选项后,客户端连接时必须提供密码才能连接。 第三种方法是禁用保护模式。要禁用保护模式,可以在Redis配置文件中将protected-mode选项设置为no。但是,您应该只在受信任的网络上禁用保护模式,因为这会使Redis容易受到攻击。 总之,您可以通过绑定地址,启用身份验证密码或禁用保护模式来解决这个问题。选择哪种方法取决于您的具体需求和安全风险评估。 ### 回答3: 保护模式是 Redis 为了提高安全性而引入的一种措施。当 Redis 运行在保护模式下时,只有来自本地回环接口的连接被允许。如果你需要从其他主机上的客户端连接 Redis 服务,就需要在 Redis 配置文件中指定一个本机网卡的 IP 地址或者主机名。 Redis 默认不启用保护模式,但是如果你的 Redis 实例被设置为使用保护模式,就会出现你所提到的错误信息。这种情况下,可能有以下几种原因: 1.没有指定 bind 地址。Redis 在启动时需要指定一个监听地址来接受客户端的连接。如果没有指定该地址,Redis 就无法正常启动,会提示相应的错误信息。 2.没有设置身份验证密码。如果 Redis 服务没有设置密码,那么可以随便使用任何客户端工具连接,这会带来一定的安全风险。因此,在生产环境中为 Redis 设置访问密码是十分必要的。 如果你想要连接 Redis 服务,可以尝试以下几种解决方法: 1.在 Redis 配置文件中指定 bind 地址,例如设置为 127.0.0.1 或者本机 IP 地址。 2.在 Redis 配置文件中设置身份验证密码。可以使用如下命令在 Redis 中设置密码: $ redis-cli > config set requirepass your_password 3.使用 ssh 或者 VPN 等方式来连接本地 Redis 服务。这样的话,你就不需要在 Redis 配置文件中定义任何外部 IP 或者密码,只需要通过 ssh 或者 VPN 连接到本机上即可访问 Redis 服务了。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值