当我从多个端口启动时,看不到添加到集群的成员。以下只是基本配置。每个似乎都有自己的端口。
@SpringBootApplication
@Configuration
public class HazelcastApplication {
public static void main(String[] args) {
SpringApplication.run(HazelcastApplication.class, args);
}
@Bean(destroyMethod = "shutdown")
public HazelcastInstance createStorageNode() throws Exception {
return Hazelcast.newHazelcastInstance();
}
}
Members [1] {
Member [169.254.137.152]:5702 this
}
Members [1] {
Member [169.254.137.152]:5701 this
}
答案 0 :(得分:1)
运行多播时,运行的计算机上可能有多个网络接口。将上述方法修改为:
@Bean(destroyMethod = "shutdown")
public HazelcastInstance createStorageNode() throws Exception {
Config config = new Config();
JoinConfig joinConfig = config.getNetworkConfig().getJoin();
joinConfig.getMulticastConfig().setEnabled(false);
joinConfig.getTcpIpConfig().setEnabled(true)
.getMembers()
.add("127.0.0.1");
//.add("169.254.137.152"); // or this
Hazelcast.newHazelcastInstance(config);
}