两台计算机上的 Hazelcast 实例看不到对方

Hazelcast instances on two computers don't see each other

我是 Hazelcast 的新手,我正在尝试在两台不同的计算机(和 IP)上开发一个包含两个实例的项目。假设这两个是 IP:10.200.1.1 和 10.200.2.2。这两个项目都在 Eclipse Mars/Tomcat 7

上工作

这是我的配置:

Config cfg = new Config();
NetworkConfig network = cfg.getNetworkConfig();

JoinConfig join = network.getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().addMember("10.200.1.1")
    .addMember("10.200.2.2").setEnabled(true);
network.getInterfaces().setEnabled(true)
    .addInterface("10.200.2.2").addInterface("10.200.1.1");
HazelcastInstance instance = Hazelcast.newHazelcastInstance();

我分别看到了这个日志,我确认这两个实例正在运行:

Şub 12, 2015 9:26:01 AM com.hazelcast.config.XmlConfigLocator
INFO: Loading 'hazelcast-default.xml' from classpath.
Şub 12, 2015 9:26:01 AM com.hazelcast.instance.DefaultAddressPicker
INFO: [LOCAL] [dev] [3.4] Prefer IPv4 stack is true.
Şub 12, 2015 9:26:02 AM com.hazelcast.instance.DefaultAddressPicker
INFO: [LOCAL] [dev] [3.4] Picked Address[192.168.56.1]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
Şub 12, 2015 9:26:02 AM com.hazelcast.spi.OperationService
INFO: [192.168.56.1]:5701 [dev] [3.4] Backpressure is disabled
Şub 12, 2015 9:26:02 AM com.hazelcast.spi.impl.BasicOperationScheduler
INFO: [192.168.56.1]:5701 [dev] [3.4] Starting with 4 generic operation threads and 8 partition operation threads.
Şub 12, 2015 9:26:02 AM com.hazelcast.system
INFO: [192.168.56.1]:5701 [dev] [3.4] Hazelcast 3.4 (20141224 - 3dc5214) starting at Address[192.168.56.1]:5701
Şub 12, 2015 9:26:02 AM com.hazelcast.system
INFO: [192.168.56.1]:5701 [dev] [3.4] Copyright (C) 2008-2014 Hazelcast.com
Şub 12, 2015 9:26:02 AM com.hazelcast.instance.Node
INFO: [192.168.56.1]:5701 [dev] [3.4] Creating MulticastJoiner
Şub 12, 2015 9:26:02 AM com.hazelcast.core.LifecycleService
INFO: [192.168.56.1]:5701 [dev] [3.4] Address[192.168.56.1]:5701 is STARTING
Şub 12, 2015 9:26:05 AM com.hazelcast.cluster.impl.MulticastJoiner
INFO: [192.168.56.1]:5701 [dev] [3.4] 


Members [1] {
    Member [192.168.56.1]:5701 this
}

Şub 12, 2015 9:26:05 AM com.hazelcast.core.LifecycleService
INFO: [192.168.56.1]:5701 [dev] [3.4] Address[192.168.56.1]:5701 is STARTED

但他们没有看到对方。没有防火墙问题,我可以用telnet连接每两个端口,我确认没有网络问题。

我需要做什么?

Hazelcast 版本为 3.4

配置似乎是正确的,但是您必须在创建新的 Hazelcast 实例时将其传递给工厂方法。而不是

HazelcastInstance instance = Hazelcast.newHazelcastInstance();

你应该使用:

HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);