正在获取io.lettuce.core.RedisCommandExecutionException:当我尝试使用SSL连接redis-cluster时发生异常

时间:2019-08-23 09:36:13

标签: redis spring-data-redis lettuce

我创建了redis-cluster,其中三个节点在本地计算机的三个不同端口上运行。我正在使用Spring-Data-Redis并使用Lettuce 5.x连接到集群。

当我尝试插入数据时,我会成功。

现在我已经安装了stunnel以通过SSL连接到Redis。我已经在通道中配置了端口重定向。从我的程序中,我更新了配置以使用SSL和stunnel端口。

当我尝试安装数据时,出现以下例外

  

无法从Redis缓存获取数据,这可能在未配置Redis服务器且它们未运行时发生。嵌套异常是io.lettuce.core.RedisCommandExecutionException:MOVED 16086 127.0.0.1:7002

我还试图在重定向过程中刷新topology(ClusterTopologyRefreshOptions)

@Configuration
public class TestRedis {

    @Primary
    @Bean
    public ClusterTopologyRefreshOptions getClusterTopologyRefreshOptions(){
        ClusterTopologyRefreshOptions topologyRefreshOptions = ClusterTopologyRefreshOptions.builder()
                .adaptiveRefreshTriggersTimeout(Duration.ofSeconds(3))
                .enableAllAdaptiveRefreshTriggers().dynamicRefreshSources(true)
                .build();
        return topologyRefreshOptions;
    }

    @Bean
    @Primary
    public ClusterClientOptions getClusterClientOptions(){
        // redisClusterClient.setOptions(ClusterClientOptions.builder().topologyRefreshOptions(getClusterTopologyRefreshOptions()).build());
        ClusterTopologyRefreshOptions topologyRefreshOptions= getClusterTopologyRefreshOptions();
        return ClusterClientOptions.builder().topologyRefreshOptions(topologyRefreshOptions).validateClusterNodeMembership(true).build();
    }

    @Bean
    @Primary
    public LettuceClientConfigurationBuilderCustomizer getLettuceClientConfigurationBuilderCustomizer(){
        LettuceClientConfigurationBuilderCustomizer clientConfigurationBuilderCustomizer = (LettuceClientConfigurationBuilder clientConfigurationBuilder) -> {
            clientConfigurationBuilder.clientOptions(getClusterClientOptions());
        };
        return clientConfigurationBuilderCustomizer;
    }
}

0 个答案:

没有答案