当我启用 tcp-ip 时,为什么 Hazelcast 需要多播?

Pau*_*aul 7 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>
Run Code Online (Sandbox Code Playgroud)

我正在实例化 Hazelcast:

        Config config = new FileSystemXmlConfig(xmlConfigFile);
        HazelcastInstance hz  = Hazelcast.newHazelcastInstance(config);
Run Code Online (Sandbox Code Playgroud)

当我启动每个节点时,我可以看到连接已建立,然后关闭节点。这是日志文件中的相关行。两台机器的日志都是一样的,只是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...
Run Code Online (Sandbox Code Playgroud)

我的第一个问题是,如果我multicast enabled="false"在 xml 配置文件中设置,为什么我会收到此消息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 节点集群?

感谢您的帮助。

Ari*_*era 0

You must make sure that all members of the cluster support the same discovery mechanisms. Make sure you only have tcp joiner enabled on both nodes. That should be enough to solve your problem.

\n

Alternatively, you can try removing the \xe2\x80\x9cmulticast\xe2\x80\x9d section from the xml on both nodes and leaving the tcp only (I have not tried this but I think it should be similar to disabling the multicast section).

\n

You can read in this issue that this error is common when there is a configuration error in one of the cluster nodes.

\n

Update added by Amit Kumar:

\n

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

\n
Members {size:1, ver:1} [\n    Member [192.168.1.102]:5701 - ecdb61e1-ac24-45dc-826d-9d807fed5f71 this\n]\n\nMembers {size:1, ver:1} [\n    Member [192.168.1.102]:5721 - 96c55f82-eefd-401f-9aca-a51e288ccb2a this\n]\n
Run Code Online (Sandbox Code Playgroud)\n