hazelcast在springboot管理中通过dockerswarm运行2个示例

axzmvihb  于 2021-07-09  发布在  Java
关注(0)|答案(1)|浏览(415)

我对springboot admin,hazelcast和docker swarm很陌生。。。我要做的是在DockerSwarm中运行2个springboot管理服务器示例。它只适用于一个示例。我的sba的每一个特点都很好。如果我在swarm中将副本数设置为“2”,并且出现以下情况,则登录页面不起作用(它会显示出来,但我无法登录,控制台中没有错误):

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!

pgpifvop

pgpifvop1#

多播在DockerSwarm的默认覆盖驱动程序中不起作用(至少在这里有说明)。我曾试图让它运行与编织网络插件,但没有运气。在我的例子中,将hazelcast切换到tcp模式并提供我喜欢搜索其他副本的网络就足够了。
类似于:

-Dhz.discovery.method=TCP
 -Dhz.network.interfaces=10.0.251.*
 -Dhz.discovery.tcp.members=10.0.251.*

相关问题