主节点中的Hazelcast无法与其他VM中的另一个节点进行通信

问题描述

我的应用程序在两个不同的VM中运行,并且它们具有相同的配置。当第二个节点在第一个节点之后运行时,位于不同服务器中的Hazelcast成员会加入,但他们无法启动通信。

App使用TCP / IP进行发现,并且还配置了网络接口。

这是我的配置代码

@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;
}

并且:

final InterfacesConfig interfacesConfig = network.getInterfaces();

interfacesConfig.setEnabled(true);

for (final String networkInterface : interfaces) {
    log.info("[Hazelcast] Interface:  " + networkInterface);
    network.getInterfaces().addInterface(networkInterface);
    log.info("[Hazelcast] Interface:  " + network.getInterfaces());
}

由于该应用程序在其他服务器上运行,因此我按如下所示设置成员和接口:

"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,但不会。

任何想法或帮助都非常感谢。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)