【问题标题】:Hazelcast cluster issues with two nodes两个节点的 Hazelcast 集群问题
【发布时间】:2015-07-15 21:21:50
【问题描述】:

首先,我为这篇冗长的帖子道歉。我正在使用 Hazelcast 3.4.4 并测试由 2 个 webapp 节点组成的集群......一个运行在我的本地 Windows 机器(10.10.222.239)上,另一个运行在 linux vm(10.10.222.145)的另一个机器上。 hazelcast 配置如下:

<hz:hazelcast id="instance">
    <hz:config>
        <hz:spring-aware />
        <hz:group name="cluster1" password="cluster1" />
        <hz:network port="5701" port-auto-increment="true">
            <hz:join>
                <hz:multicast enabled="false"/>
                <hz:tcp-ip enabled="true">
                    <hz:members>10.10.222.239, 10.10.222.145</hz:members>
                </hz:tcp-ip>
            </hz:join>
        </hz:network>
        ....
    </hz:config>
</hz:hazelcast>

当我启动我的 windows webapp 节点(linux 节点关闭)时,日志会输出我希望看到的内容。也就是只有一个节点,有的尝试连接linux节点:

Members [1] {
    Member [10.10.222.239]:5701 this
}
...
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5702. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5702]
Jul 15, 2015 4:53:22 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5701. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5701]
Jul 15, 2015 4:53:22 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5703. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5703]

当我启动 linux 节点时,一切似乎都运行良好。如 windows 节点日志所示,两者相互连接:

NFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Accepting socket connection from /10.10.222.145:52127
Jul 15, 2015 4:55:09 PM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Established socket connection between /10.10.222.239:5701 and /10.10.222.145:52127
Jul 15, 2015 4:55:16 PM com.hazelcast.cluster.ClusterService
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] 

Members [2] {
    Member [10.10.222.239]:5701 this
    Member [10.10.222.145]:5701
}

启动和停止 linux 节点会产生预期的行为;它加入和退出集群。

我的问题是先启动linux节点,然后再启动windows节点;事情的行为方式不同。 windows节点启动后,两者似乎没有看到对方。日志表明两者都是独立的。

// linux 
Members [1] {
        Member [10.10.222.145]:5701 this
}
// windows
Members [1] {
    Member [10.10.222.239]:5701 this
}

在 linux 节点日志中,尝试连接到另一个节点但失败了,我猜这是预料之中的,因为 Windows 节点最初是关闭的。但出乎意料的是,windows one 显示与 linux 节点的连接尝试失败:

INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5701. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5701]
Jul 15, 2015 5:08:31 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5702. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5702]
Jul 15, 2015 5:08:31 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5703. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5703]

4 分钟后,windows 节点显示如下:

Jul 15, 2015 5:12:37 PM com.hazelcast.nio.tcp.SocketAcceptor
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Accepting socket connection from /10.10.222.145:52800
Jul 15, 2015 5:12:37 PM com.hazelcast.nio.tcp.TcpIpConnectionManager
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Established socket connection between /10.10.222.239:5701 and /10.10.222.145:52800
Jul 15, 2015 5:13:13 PM com.hazelcast.cluster.impl.TcpIpJoiner
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.239]:5701 is merging to Address[10.10.222.145]:5701, because : node.getThisAddress().hashCode() > joinRequest.address.hashCode() , this node member count: 1
Jul 15, 2015 5:13:13 PM com.hazelcast.cluster.impl.TcpIpJoiner
WARNING: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.239]:5701 is merging [tcp/ip] to Address[10.10.222.145]:5701
Jul 15, 2015 5:13:13 PM com.hazelcast.cluster.impl.operations.PrepareMergeOperation
WARNING: [10.10.222.239]:5701 [cluster1] [3.4.4] Preparing to merge... Waiting for merge instruction...
Jul 15, 2015 5:13:13 PM com.hazelcast.cluster.impl.operations.MergeClustersOperation
WARNING: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.239]:5701 is merging to Address[10.10.222.145]:5701, because: instructed by master Address[10.10.222.239]:5701
Jul 15, 2015 5:13:13 PM com.hazelcast.core.LifecycleService
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.239]:5701 is MERGING
Jul 15, 2015 5:13:13 PM com.hazelcast.nio.tcp.TcpIpConnection
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Connection [Address[10.10.222.145]:5701] lost. Reason: Socket explicitly closed
Jul 15, 2015 5:13:14 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Connecting to /10.10.222.145:5701, timeout: 0, bind-any: true
Jul 15, 2015 5:13:31 PM com.hazelcast.cluster.impl.TcpIpJoiner
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.145]:5702 is added to the blacklist.
Jul 15, 2015 5:13:34 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Connecting to /10.10.222.145:5702, timeout: 0, bind-any: true
Jul 15, 2015 5:13:34 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Connecting to /10.10.222.239:5702, timeout: 0, bind-any: true
Jul 15, 2015 5:13:34 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Connecting to /10.10.222.239:5703, timeout: 0, bind-any: true
Jul 15, 2015 5:13:34 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Connecting to /10.10.222.145:5703, timeout: 0, bind-any: true
Jul 15, 2015 5:13:35 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5701. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5701]
Jul 15, 2015 5:13:35 PM com.hazelcast.cluster.impl.TcpIpJoiner
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.145]:5701 is added to the blacklist.
Jul 15, 2015 5:13:35 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.239:5703. Reason: SocketException[Connection refused: connect to address /10.10.222.239:5703]
Jul 15, 2015 5:13:35 PM com.hazelcast.cluster.impl.TcpIpJoiner
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.239]:5703 is added to the blacklist.
Jul 15, 2015 5:13:35 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.239:5702. Reason: SocketException[Connection refused: connect to address /10.10.222.239:5702]
Jul 15, 2015 5:13:35 PM com.hazelcast.cluster.impl.TcpIpJoiner
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.239]:5702 is added to the blacklist.
Jul 15, 2015 5:13:39 PM com.hazelcast.cluster.impl.TcpIpJoiner
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] 


Members [1] {
    Member [10.10.222.239]:5701 this
}

Jul 15, 2015 5:13:39 PM com.hazelcast.core.LifecycleService
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Address[10.10.222.239]:5701 is MERGED
Jul 15, 2015 5:13:55 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5702. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5702]
Jul 15, 2015 5:13:55 PM com.hazelcast.nio.tcp.SocketConnector
INFO: [10.10.222.239]:5701 [cluster1] [3.4.4] Could not connect to: /10.10.222.145:5703. Reason: SocketException[Connection timed out: connect to address /10.10.222.145:5703]

似乎有人尝试合并集群节点,但失败了。我不太明白为什么事情的行为会因谁先启动而有所不同。是否存在我不知道的配置错误或暗示的某些行为?

【问题讨论】:

    标签: cluster-computing nodes hazelcast


    【解决方案1】:

    原来是 Linux 机器上的防火墙问题。我关闭了 iptables 服务进行测试,然后一切正常。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-12
      相关资源
      最近更新 更多