Configuring a two node hazelcast cluster - avoiding multicast

偶尔善良 提交于 2019-12-31 15:47:06

问题


The context

  • Two nodes of a Hazelcast cluster, each on a discrete subnet so multicast is not suitable nor working for node location.

  • I should like to employ the most minimal XML configuration file, say hazelcast.xml, to configure Hazelcast to use TCP/IP to connect the two nodes. Ideally a directory of the IP addresses of the two nodes.

The question

The Hazelcast docs do a good job of showing how this can be achieved programatically, and how hazelcast.jar/hazelcast-default.xml holds the (considerable) default configuration.

What is unclear is: is any XML configuration I supply overlaid upon the settings within hazelcast-default.xml - or simply used in its stead?


回答1:


I have both my answers, and should like to share them

  1. Just like the programatic API, the XML configuration overlays the defaults found in hazelcast.jar/hazelcast-default.xml, consequently ...

  2. I can establish a very simple two-member cluster with this hazelcast.xml in the classpath

    <hazelcast>
      <network>
        <join>
          <multicast enabled="false"></multicast>
          <tcp-ip enabled="true">
            <member>192.168.100.001</member> <!-- server A -->
            <member>192.168.102.200</member> <!-- server B, on separate subnet -->
          </tcp-ip>
        </join>
      </network>
    
    </hazelcast>
    



回答2:


I'm not familiar with hazelcast.conf files.

Mostly used is XML or Programmatic api. For good examples see:

https://github.com/hazelcast/hazelcast-code-samples/tree/master/network-configuration

Example of programmatic:

public class Main {

    public static void main(String[] args){
        Config config = new Config();
        config.getNetworkConfig().getJoin().getTcpIpConfig().addMember("localhost").setEnabled(true);
        config.getNetworkConfig().getJoin().getMulticastConfig().setEnabled(false);
        HazelcastInstance hz = Hazelcast.newHazelcastInstance(config);
    }
}

-- What is unclear is: is any XML configuration I supply overlaid upon the settings within hazelcast-default.xml - or simply used in its stead?

What do you mean? If you use the programmatic API, the rest is not relevant. If you don't provide an explicit Config object while constructing the HazelcastInstance, a defaulting mechanism is used. And eventually it defaults to hazelcast-default.xml.



来源:https://stackoverflow.com/questions/26345529/configuring-a-two-node-hazelcast-cluster-avoiding-multicast

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!