Java 主节点中的Hazelcast无法与其他VM中的其他节点通信
我的应用程序在两个不同的虚拟机中运行,它们具有相同的配置。当第二个节点在第一个节点之后运行时,不同服务器中的Hazelcast成员加入,但他们无法启动通信 应用程序使用TCP/IP进行查找,并且还配置了网络接口 这是我的配置代码:Java 主节点中的Hazelcast无法与其他VM中的其他节点通信,java,spring-boot,hazelcast,distributed-caching,Java,Spring Boot,Hazelcast,Distributed Caching,我的应用程序在两个不同的虚拟机中运行,它们具有相同的配置。当第二个节点在第一个节点之后运行时,不同服务器中的Hazelcast成员加入,但他们无法启动通信 应用程序使用TCP/IP进行查找,并且还配置了网络接口 这是我的配置代码: @Bean public NetworkConfig networkConfig(final Config hazelCastConfiguration) throws UnknownHostException { final NetworkConfig ne
@Bean
public NetworkConfig networkConfig(final Config hazelCastConfiguration) throws UnknownHostException {
final NetworkConfig network = hazelCastConfiguration.getNetworkConfig();
network.setPort(port);
network.setPortAutoIncrement(true);
final JoinConfig join = network.getJoin();
final MulticastConfig multicast = join.getMulticastConfig();
multicast.setEnabled(false);
final TcpIpConfig tcpIp = join.getTcpIpConfig();
tcpIp.setEnabled(true);
for (final String member : members) {
final InetAddress[] addresses = MoreObjects.firstNonNull(
InetAddress.getAllByName(member),
new InetAddress[0]);
for (final InetAddress addr : addresses) {
final String hostAddress = addr.getHostAddress();
tcpIp.addMember(hostAddress);
log.info("[Hazelcast] New Member: " + hostAddress);
}
}
return network;
}
以及:
因为应用程序运行在不同的服务器上,所以我按如下方式设置了成员和接口:
"HOST1IP" and "HOST2IP"
当我运行应用程序时,我会得到以下日志:
Members {size:2, ver:6} [
Member ["HOSTIP1"]:5702 - 6a356dc6-4b16-49dd-8cb5-a7df62f7c2d2 this
Member ["HOSTIP2"]:5702 - 015b5b34-657f-4b38-8b67-17810777ac2e
]
成员加入,然后:
com.hazelcast.nio.tcp.TcpIpConnection
: ["HOSTIP1"]:5702 [example-app] [3.11.4] Initialized new cluster connection between /"HOSTIP2":53725 and /"HOSTIP2":5701
我希望启动到“HOSTIP2”:5702的连接,但它没有
非常感谢您的任何想法或帮助。其余的日志可能会有所帮助,但值得注意的是,
初始化了/“HOSTIP2”:53725和/“HOSTIP2”:5701之间的新群集连接
引用了端口5701(默认值),但是您的群集列表在端口5702上都有服务器。您解决了这个问题吗?
com.hazelcast.nio.tcp.TcpIpConnection
: ["HOSTIP1"]:5702 [example-app] [3.11.4] Initialized new cluster connection between /"HOSTIP2":53725 and /"HOSTIP2":5701