2

我对 SpringBoot Admin、HazelCast 和 Docker Swarm 很陌生……我想做的是在 Docker Swarm 中运行 2 个 SpringBoot Admin Server 实例。它适用于一个实例。我的 SBA 的所有功能都运行良好。如果我将副本数设置为“2”,并在 swarm 中使用以下内容,则登录页面不起作用(它显示但我无法登录,控制台中没有错误):

mode: replicated
      replicas: 2
      update_config:
        parallelism: 1
        delay: 60s
        failure_action: rollback
        order: start-first
        monitor: 60s
      rollback_config:
        parallelism: 1
        delay: 60s
        failure_action: pause
        order: start-first
        monitor: 60s
      restart_policy:
        condition: any
        delay: 60s
        max_attempts: 3
        window: 3600s

我当前的 HazelCast 配置如下(在 SpringBoot Admin doc 中指定):

@Bean
    public Config hazelcast() {
        // This map is used to store the events.
        // It should be configured to reliably hold all the data,
        // Spring Boot Admin will compact the events, if there are too many
        MapConfig eventStoreMap = new MapConfig(DEFAULT_NAME_EVENT_STORE_MAP).setInMemoryFormat(InMemoryFormat.OBJECT)
                .setBackupCount(1).setEvictionPolicy(EvictionPolicy.NONE)
                .setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

        // This map is used to deduplicate the notifications.
        // If data in this map gets lost it should not be a big issue as it will atmost
        // lead to
        // the same notification to be sent by multiple instances
        MapConfig sentNotificationsMap = new MapConfig(DEFAULT_NAME_SENT_NOTIFICATIONS_MAP)
                .setInMemoryFormat(InMemoryFormat.OBJECT).setBackupCount(1).setEvictionPolicy(EvictionPolicy.LRU)
                .setMergePolicyConfig(new MergePolicyConfig(PutIfAbsentMapMergePolicy.class.getName(), 100));

        Config config = new Config();
        config.addMapConfig(eventStoreMap);
        config.addMapConfig(sentNotificationsMap);
        config.setProperty("hazelcast.jmx", "true");

        // WARNING: This setups a local cluster, you change it to fit your needs.
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(true);
        TcpIpConfig tcpIpConfig = config.getNetworkConfig().getJoin().getTcpIpConfig();
        tcpIpConfig.setEnabled(true);

//        NetworkConfig network = config.getNetworkConfig();
//        InterfacesConfig interfaceConfig = network.getInterfaces();
//        interfaceConfig.setEnabled( true )
//                .addInterface( "192.168.1.3" );
//        tcpIpConfig.setMembers(singletonList("127.0.0.1"));
        return config;

    }
```

I guess these inputs are not enough for you to properly help, but since I don't really weel understand the way HazelCast is workging, I don't really know what is useful or not. So please don't hesitate to ask me for what is needed to help! :)

Do you guys have any idea of what I'm doing wrong?

Many thanks!

4

1 回答 1

0

多播在默认覆盖驱动程序中的 Docker Swarm 中不起作用(至少在此处说明)。我试图让它与 weave 网络插件一起运行,但没有运气。就我而言,将 Hazelcast 切换到 TCP 模式并提供我喜欢的网络来搜索其他副本就足够了。

像这样的东西:

 -Dhz.discovery.method=TCP
 -Dhz.network.interfaces=10.0.251.*
 -Dhz.discovery.tcp.members=10.0.251.*
于 2020-08-24T19:37:26.713 回答