簡體   English   中英

NOAUTH 需要認證 spring-boot-data-redis+Realease Lettuce+Redis sentinel

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

當我重新啟動 redis 原因
java.util.concurrent.ExecutionException:io.lettuce.core.RedisCommandExecutionException:NOAUTH 需要身份驗證。 為什么這是一個問題使用這樣的版本

@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 利用 Redis URI 的自定義語法。 這是架構:

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

有四種 URI 方案:

  • redis – 獨立的 Redis 服務器
  • redis – 通過 SSL 連接的獨立 Redis 服務器
  • redis-socket – 通過 Unix 域套接字的獨立 Redis 服務器
  • redis-sentinel – 一個 Redis 哨兵服務器

Redis 數據庫實例可以指定為 URL 路徑的一部分或附加參數。 如果兩者都提供,則參數具有更高的優先級。

打印您的 redis uri 連接字符串並檢查您的輸入。

您可以升級生菜版本並嘗試:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM