简体   繁体   English

NOAUTH 需要认证 spring-boot-data-redis+Realease Lettuce+Redis sentinel

[英]NOAUTH Authentication required spring-boot-data-redis+Realease Lettuce+Redis sentinel

when I restart redis cause当我重新启动 redis 原因
java.util.concurrent.ExecutionException: io.lettuce.core.RedisCommandExecutionException: NOAUTH Authentication required. java.util.concurrent.ExecutionException:io.lettuce.core.RedisCommandExecutionException:NOAUTH 需要身份验证。 Why is this a problem use version like this为什么这是一个问题使用这样的版本

@Configuration
public class RedisConfig {

    @Autowired
    private RedisProperties redisProperties;

    @Bean(destroyMethod = "close")
    public StatefulRedisConnection<String, Object> StatefulRedisConnection() {
        RedisURI redisUri = RedisURI.builder().withPassword(redisProperties.getPassword())
                .withSentinel(redisProperties.getSentinel().getNodes().get(0).split(":")[0],
                        Integer.valueOf(redisProperties.getSentinel().getNodes().get(0).split(":")[1]))
                .withSentinelMasterId(redisProperties.getSentinel().getMaster())
                .withDatabase(redisProperties.getDatabase()).build();
        RedisClient redisClient = RedisClient.create(redisUri);
        return redisClient.connect(new SerializedObjectCodec());
    }
}
public class CacheImpl implements Cache {
    @Autowired
    private StatefulRedisConnection connect;

    public Boolean addCourseInfosCache() {
        RedisAsyncCommands<String, Object> commands = connect.async();
        // disable auto-flushing
        commands.setAutoFlushCommands(false);
        List<RedisFuture<?>> futures = Lists.newArrayList();
        commands.flushCommands();
    }
}

Lettuce leverages a custom syntax for Redis URIs. Lettuce 利用 Redis URI 的自定义语法。 This is the schema:这是架构:

redis :// [password@] host [: port] [/ database]
  [? [timeout=timeout[d|h|m|s|ms|us|ns]]
  [&_database=database_]]

There are four URI schemes:有四种 URI 方案:

  • redis – a standalone Redis server redis – 独立的 Redis 服务器
  • rediss – a standalone Redis server via an SSL connection redis – 通过 SSL 连接的独立 Redis 服务器
  • redis-socket – a standalone Redis server via a Unix domain socket redis-socket – 通过 Unix 域套接字的独立 Redis 服务器
  • redis-sentinel – a Redis Sentinel server redis-sentinel – 一个 Redis 哨兵服务器

The Redis database instance can be specified as part of the URL path or as an additional parameter. Redis 数据库实例可以指定为 URL 路径的一部分或附加参数。 If both are supplied, the parameter has higher precedence.如果两者都提供,则参数具有更高的优先级。

Print your redis uri connection string and check with your inputs.打印您的 redis uri 连接字符串并检查您的输入。

You can upgrade Lettuce version and try:您可以升级生菜版本并尝试:

RedisURI redisUri = RedisURI.Builder.sentinel("sentinelhost1", "mymaster").withPassword("abc").build();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM