Hazelcast: connecting to remote cluster

ぐ巨炮叔叔 提交于 2019-12-03 13:34:51

To connect to the remote cluster, make sure the cluster uses the external IP and not 127.0.0.1. In our case we have a single physical system, with multiple nodes, with tcp-ip mode enabled. The hazelcast.xml has the configuration:

        <tcp-ip enabled="true">
            <!-- This should be external IP -->
            <interface>172.x.x.x</interface>
        </tcp-ip>

Can you try:

ClientConfig config = new ClientConfig();
config.getNetworkConfig().addAddress(host + ":" + port);
HazelcastInstance instance = HazelcastClient.newHazelcastClient(config);

If you want to connect to multiple ip's running Hazelcast as cluster add below to your client config and then instantiate client.

    //configure client properties
    ClientConfig config = new ClientConfig();
    String[] addresses = {"172.20.250.118" + ":" + "5701","172.20.250.49" + ":" + "5701"};
    config.getNetworkConfig().addAddress(addresses);

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