我是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
答案 0 :(得分:7)
配置似乎是正确的,但是在创建新的Hazelcast实例时必须将其传递给factory方法。而不是
HazelcastInstance instance = Hazelcast.newHazelcastInstance();
你应该使用:
HazelcastInstance instance = Hazelcast.newHazelcastInstance(config);