启用tcp-ip时,Hazelcast为什么期望多播?

时间:2019-04-22 19:20:10

标签: java hazelcast

我正在尝试设置2台计算机的Hazelcast群集,并且不能使用多播。这是我用于配置的xml文件:

<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config http://www.hazelcast.com/schema/config/hazelcast-config-3.9.xsd" xmlns="http://www.hazelcast.com/schema/config" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <network>
        <port auto-increment="true">5701</port>
        <join>
            <multicast enabled="false">
            </multicast>
            <tcp-ip enabled="true">
                <member>10.18.7.4</member>
                <member>10.18.14.63</member>
            </tcp-ip>
        </join>
    </network>
</hazelcast>

我正在像这样实例化Hazelcast:

        Config config = new FileSystemXmlConfig(xmlConfigFile);
        HazelcastInstance hz  = Hazelcast.newHazelcastInstance(config);

当我启动每个节点时,我可以看到建立了连接,然后它关闭了该节点。这是日志文件中的相关行。两台机器的日志相同,只是ip不同。我添加了注释(在->之后),以使其更易于阅读。

WARNING: Name of the hazelcast schema location is incorrect, using default -> Presumable no issue here

INFO: [LOCAL] [dev] [3.12] Interfaces is disabled, trying to pick one address from TCP-IP config addresses: [10.18.14.63, 10.18.7.4]

INFO: [LOCAL] [dev] [3.12] Picked [10.18.14.63]:5702, using socket ServerSocket[addr=/0.0.0.0,localport=5702], bind any local is true

INFO: [10.18.14.63]:5702 [dev] [3.12] Hazelcast 3.12 (20190409 - 915d83a) starting at [10.18.14.63]:5702 -> Great, we're starting Hazelcast on this machine. 

INFO: [10.18.14.63]:5702 [dev] [3.12] Starting 2 partition threads and 3 generic threads (1 dedicated for priority tasks) -> Looking good

INFO: [10.18.14.63]:5702 [dev] [3.12] [10.18.14.63]:5702 is STARTING -> Ok looks like we've started. 

INFO: [10.18.14.63]:5702 [dev] [3.12] Connecting to /10.18.7.4:5702, timeout: 10000, bind-any: true -> Trying to connect to the other machine

INFO: [10.18.14.63]:5702 [dev] [3.12] Connecting to /10.18.7.4:5703, timeout: 10000, bind-any: true -> Still trying to connect to the other machine

INFO: [10.18.14.63]:5702 [dev] [3.12] Initialized new cluster connection between /10.18.14.63:44251 and /10.18.14.63:5701 -> Ok started a cluster connection on this machine. 

INFO: [10.18.14.63]:5702 [dev] [3.12] Initialized new cluster connection between /10.18.14.63:38941 and /10.18.7.4:5701 -> Great, started a connection with the other machine

SEVERE: [10.18.14.63]:5702 [dev] [3.12] Node could not join cluster. A Configuration mismatch was detected: Incompatible joiners! expected: multicast, found: tcp-ip Node is going to shutdown now! -> This is the error I don't understand. 

Apr 22, 2019 6:57:44 PM com.hazelcast.instance.Node
WARNING: [10.18.14.63]:5702 [dev] [3.12] Terminating forcefully...

Apr 22, 2019 6:57:44 PM com.hazelcast.instance.Node
INFO: [10.18.14.63]:5702 [dev] [3.12] Shutting down connection manager...

我的第一个问题是,如果我在xml配置文件中设置了multicast enabled="false",为什么会收到此消息Node could not join cluster. A Configuration mismatch was detected: Incompatible joiners! expected: multicast, found: tcp-ip Node is going to shutdown now!,然后它关闭了?

我的第二个问题是,如何正确配置xml文件以使用tcp-ip而不是多播创建2节点集群?

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您必须确保集群的所有成员都支持相同的发现机制。确保在两个节点上都只启用了tcp joiner。那应该足以解决您的问题。

或者,您可以尝试从两个节点上的xml中删除“多播”部分,而仅保留tcp(我没有尝试过,但是我认为它应该类似于禁用多播部分)。

您可以在此issue中看到,当一个集群节点中发生配置错误时,此错误很常见。

Amit Kumar添加的更新:

我注意到正在运行一些默认的hazelcast配置,即从hazelcast .jar开始加载hazelcast.xml,然后在运行我的配置hazelcast.xml之后再加载。 自定义hazelcast.xml中指示了网络端口“ 5721”,但是仍然在端口“ 5701”和“ 5702”上启动了一个实例。

Members {size:1, ver:1} [
    Member [192.168.1.102]:5701 - ecdb61e1-ac24-45dc-826d-9d807fed5f71 this
]

Members {size:1, ver:1} [
    Member [192.168.1.102]:5721 - 96c55f82-eefd-401f-9aca-a51e288ccb2a this
]