Kubernetes上的令牌问题Redis集群

时间:2019-07-19 08:45:45

标签: spring-boot kubernetes redis

我在kubernetes上配置了redis-cluster githublink 我看到我的集群工作得很好,没有看到任何错误 首先,您是否在我的配置上看到任何错误? 我还添加了kube config和spring boot config redisson Java客户端

问题出在这里,开发人员说只有一个令牌没有在节点之间正确复制。他可以第一次正确登录系统,然后当他想执行其他操作时令牌无效。 发生了另一个问题,即只有一个令牌。

预先感谢

Kube Side

$ kubectl get pods | grep redis
redis-cluster-0                       1/1     Running            1          10d
redis-cluster-1                       1/1     Running            0          10d
redis-cluster-2                       1/1     Running            1          10d
redis-cluster-3                       1/1     Running            0          10d
redis-cluster-4                       1/1     Running            1          10d
redis-cluster-5                       1/1     Running            1          10d
$ kubectl get pv | grep redis
data-redis-0         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-2                           10d
data-redis-1         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-1                           10d
data-redis-2         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-0                           10d
data-redis-3         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-3                           10d
data-redis-4         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-4                           10d
data-redis-5         3Gi        RWO            Retain           Bound    default/data-redis-redis-cluster-5                           10d
$ kubectl get pvc | grep redis
data-redis-redis-cluster-0   Bound    data-redis-2         3Gi        RWO                           10d
data-redis-redis-cluster-1   Bound    data-redis-1         3Gi        RWO                           10d
data-redis-redis-cluster-2   Bound    data-redis-0         3Gi        RWO                           10d
data-redis-redis-cluster-3   Bound    data-redis-3         3Gi        RWO                           10d
data-redis-redis-cluster-4   Bound    data-redis-4         3Gi        RWO                           10d
data-redis-redis-cluster-5   Bound    data-redis-5         3Gi        RWO                           10d

$ kubectl get svc | grep redis
redis-cluster        ClusterIP   10.233.3.78     <none>        6379/TCP,16379/TCP                                                                 10d

$ redis-cli -h 10.233.3.78 -c

$ > ping
pong

$> CLUSTER INFO
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:7
cluster_my_epoch:7
cluster_stats_messages_ping_sent:846761
cluster_stats_messages_pong_sent:854464
cluster_stats_messages_sent:1701225
cluster_stats_messages_ping_received:854464
cluster_stats_messages_pong_received:846745
cluster_stats_messages_fail_received:3
cluster_stats_messages_received:1701212
> CLUSTER NODES
81b6bb05dd66375fa8b0ff571b5f5cdaf98f8c02 10.117.2.131:6379@16379 slave 98fef8bd00cf00316d49d062b0fd503643ba908e 0 1563520808085 2 connected
341b25780a9cca4079ba4db9de5f5085fe5746c6 10.117.2.215:6379@16379 master - 0 1563520815111 3 connected 10923-16383
734b3f058c21f1aff418d5ba10e06a827892eb4c 10.117.2.199:6379@16379 myself,slave 7562f85fa1200370364e25117748623c28d68804 0 1563520811000 1 connected
7562f85fa1200370364e25117748623c28d68804 10.117.2.8:6379@16379 master - 0 1563520814107 7 connected 0-5460
98fef8bd00cf00316d49d062b0fd503643ba908e 10.117.2.52:6379@16379 master - 0 1563520812000 2 connected 5461-10922
91df2126229098dbbc648118204fc914516d57ca 10.117.2.242:6379@16379 slave 341b25780a9cca4079ba4db9de5f5085fe5746c6 0 1563520813103 6 connected

Spring Boot Redisson方面:


@Configuration
@Import({TokenProvider.class})
public class RedisConfiguration {
    public static final String CACHE_PREFIX = "token";

    private static final int CONNECTION_POOL_SIZE = 4;
    private static final int CONNECTION_MINIMUM_IDLE_SIZE = 2;

    @Value("${redis.server.urls}")
    String[] redisServers;

    @Profile({"!local"})
    @Bean
    RedissonClient redissonClusterdClient() {
        Config config = new Config();

        config.setCodec(new SerializationCodec());

        ClusterServersConfig replicatedConfig = config.useClusterServers()
                .setScanInterval(2000)
                .setMasterConnectionPoolSize(CONNECTION_POOL_SIZE)
                .setMasterConnectionMinimumIdleSize(CONNECTION_MINIMUM_IDLE_SIZE)
                .setSlaveConnectionPoolSize(CONNECTION_POOL_SIZE)
                .setSlaveConnectionMinimumIdleSize(CONNECTION_MINIMUM_IDLE_SIZE);
        for (String redisServer : redisServers) {
            replicatedConfig.addNodeAddress(redisServer);
        }

        return Redisson.create(config);
    }

    @Profile({"local"})
    @Bean
    RedissonClient redissonSingleClient() {
        Config config = new Config();

        config.setCodec(new SerializationCodec());

        SingleServerConfig singleServerConfig = config.useSingleServer();
        for (String redisServer : redisServers) {
            singleServerConfig.setAddress(redisServer);
        }

        return Redisson.create(config);
    }
}

0 个答案:

没有答案