我有简单的micronuat应用程序,现在我正试图连接到Redis独立集群与下面的配置
应用程序.yml
redis:
uri: redis://redis.dev.com
port: 6379
username: db_cache
password: password
io-thread-pool-size: 10
computation-thread-pool-size: 10
cache:
expiration-after-write-policy: 1h
pool:
enabled: true
min-idle: 5
max-total: 15
max-idle: 10
版本
micronautRedisLettuce = "5.3.2"
micronautVersion = "3.8.1"
应用程序即将启动,但当我访问健康端点时,我得到了503
响应,其中包含以下错误消息,其中包含一些协议问题
io.micronaut.management.health.indicator.HealthResult - {} - Health indicator [redis(Primary)] reported exception: io.lettuce.core.RedisConnectionException: Unable to connect to dbaasprod-re-sppst-dc-107793.dev.target.com/<unresolved>:6379
io.lettuce.core.RedisConnectionException: Unable to connect to dbaasprod-re-sppst-dc-107793.dev.target.com/<unresolved>:6379
at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:78) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.RedisConnectionException.create(RedisConnectionException.java:56) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.AbstractRedisClient.getConnection(AbstractRedisClient.java:350) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.RedisClient.connect(RedisClient.java:216) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.RedisClient.connect(RedisClient.java:201) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.micronaut.configuration.lettuce.health.RedisHealthIndicator.healthResultForClient(RedisHealthIndicator.java:107) ~[micronaut-redis-lettuce-5.3.2.jar:5.3.2]
at io.micronaut.configuration.lettuce.health.RedisHealthIndicator.lambda$getResult$0(RedisHealthIndicator.java:99) ~[micronaut-redis-lettuce-5.3.2.jar:5.3.2]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:386) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:272) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:230) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:371) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:165) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:87) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.Flux.subscribe(Flux.java:8660) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxConcatArray$ConcatArraySubscriber.onComplete(FluxConcatArray.java:258) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxConcatArray.subscribe(FluxConcatArray.java:78) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.Flux.subscribe(Flux.java:8660) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onNext(FluxFlatMap.java:426) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxIterable$IterableSubscription.slowPath(FluxIterable.java:272) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxIterable$IterableSubscription.request(FluxIterable.java:230) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxFlatMap$FlatMapMain.onSubscribe(FluxFlatMap.java:371) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:165) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.FluxIterable.subscribe(FluxIterable.java:87) ~[reactor-core-3.5.0.jar:3.5.0]
at reactor.core.publisher.Mono.subscribe(Mono.java:4444) ~[reactor-core-3.5.0.jar:3.5.0]
at io.micronaut.management.health.monitor.HealthMonitorTask.monitor(HealthMonitorTask.java:98) ~[micronaut-management-3.8.1.jar:3.8.1]
at io.micronaut.management.health.monitor.$HealthMonitorTask$Definition$Exec.dispatch(Unknown Source) ~[micronaut-management-3.8.1.jar:3.8.1]
at io.micronaut.context.AbstractExecutableMethodsDefinition$DispatchedExecutableMethod.invoke(AbstractExecutableMethodsDefinition.java:378) ~[micronaut-inject-3.8.1.jar:3.8.1]
at io.micronaut.inject.DelegatingExecutableMethod.invoke(DelegatingExecutableMethod.java:76) ~[micronaut-inject-3.8.1.jar:3.8.1]
at io.micronaut.scheduling.processor.ScheduledMethodProcessor.lambda$process$5(ScheduledMethodProcessor.java:127) ~[micronaut-context-3.8.1.jar:3.8.1]
at io.micrometer.core.instrument.composite.CompositeTimer.record(CompositeTimer.java:141) ~[micrometer-core-1.10.2.jar:1.10.2]
at io.micrometer.core.instrument.Timer.lambda$wrap$0(Timer.java:196) ~[micrometer-core-1.10.2.jar:1.10.2]
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539) ~[?:?]
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305) ~[?:?]
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136) ~[?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635) ~[?:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Caused by: io.lettuce.core.RedisCommandExecutionException: NOAUTH HELLO must be called with the client already authenticated, otherwise the HELLO AUTH <user> <pass> option can be used to authenticate the client and select the RESP protocol version at the same time
at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:147) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.internal.ExceptionFactory.createExecutionException(ExceptionFactory.java:116) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.protocol.AsyncCommand.completeResult(AsyncCommand.java:120) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.protocol.AsyncCommand.complete(AsyncCommand.java:111) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.protocol.CommandWrapper.complete(CommandWrapper.java:63) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.protocol.CommandHandler.complete(CommandHandler.java:747) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.protocol.CommandHandler.decode(CommandHandler.java:682) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]
at io.lettuce.core.protocol.CommandHandler.channelRead(CommandHandler.java:599) ~[lettuce-core-6.2.1.RELEASE.jar:6.2.1.RELEASE]```
1条答案
按热度按时间drnojrws1#
在RedisURI中,需要根据集群类型指定不同的url
URI语法
Redis URI可能包含身份验证细节,这些细节会有效地导致用户名带密码,仅密码或无身份验证。连接通过使用RedisCredentials提供的信息进行身份验证。凭据在连接时从RedisCredentialsProvider获得。当在URI上静态配置用户名/密码时,StaticCredentialsProvider会保存配置的信息。
说明
在我的情况下,因为它是一个独立的服务器,我修改了URL格式,包括密码和它的工作。
对于某些群集,
username
可能是必需的,然后您可以按以下格式指定