java Hazelcast会自动添加成员然后删除它

nxagd54h  于 2023-03-21  发布在  Java
关注(0)|答案(2)|浏览(141)

在我的应用程序中,我使用的是Hazelcast 3.7.8版本,我有2台机器设置为成员。一旦部署,这2个成员将加入集群,但也会自动添加第三个成员,几秒钟后它会被删除。
我的配置:

@Bean("hazelcastInstanceTest")
public HazelcastInstance hazelcastInstance() {
    Config config = new Config();
    config.getNetworkConfig().addOutboundPort(0);
    config.getGroupConfig().setName(name).setPassword(password);

    JoinConfig joinConfig = config.getNetworkConfig().getJoin();

    joinConfig.getMulticastConfig()
            .setEnabled(false);

    List<String> members = Arrays.asList("MEMBER1:5701","MEMBER2:5701");
    joinConfig.getTcpIpConfig()
            .setMembers(members)
            .setEnabled(true);

    return Hazelcast.newHazelcastInstance(config);
}

从第一个虚拟机记录日志(在第二个虚拟机上,输出相同):

SocketAcceptorThread: [MEMBER1]:5701 [test] [3.7.8] Accepting socket connection from /MEMBER3:45566
TcpIpConnectionManager: [MEMBER1]:5701 [test] [3.7.8] Established socket connection between /MEMBER1:5701 and /MEMBER3:45566
ClusterService: [MEMBER1]:5701 [test] [3.7.8]

Members [3] {
        Member [MEMBER2]:5701 - member2_uuid
        Member [MEMBER1]:5701 - member1_uuid this
        Member [MEMBER3]:5701 - member3_uuid
}

TcpIpConnection: [MEMBER1]:5701 [test] [3.7.8] Connection[id=3, /MEMBER1:5701->/MEMBER3:45566, endpoint=[MEMBER3]:5701, alive=false, type=MEMBER] closed. Reason: Removing member [MEMBER3]:5701, uuid: member3_uuid, requested by: [MEMBER3]:5701
ClusterService: [MEMBER1]:5701 [test] [3.7.8] Removing Member [MEMBER3]:5701 - member3_uuid
ClusterService: [MEMBER1]:5701 [test] [3.7.8]

Members [2] {
        Member [MEMBER2]:5701 - member2_uuid
        Member [MEMBER1]:5701 - member1_uuid this
}

TransactionManagerService: [MEMBER1]:5701 [test] [3.7.8] Committing/rolling-back alive transactions of Member [MEMBER3]:5701 - member3_uuid, UUID: member3_uuid

这个日志序列每分钟都在重复。我不明白 * MEMBER 3 * 最终是如何被添加到成员列表中的?我如何阻止它加入?
我试着改变端口,但它是一样的。不幸的是,我不能改变版本-这是一个复杂的过程,在这个公司。谢谢你的帮助!

vmpqdwk3

vmpqdwk31#

您在日志中看到的是Hazelcast集群中的最小成员数为3的事实的结果。由于您只配置了2个成员,Hazelcast为您添加了1个虚拟成员。但由于它显然不是活动的-将立即被删除。Hazelcast将尝试每分钟,如果它回来...
解决方案:配置至少3个成员或停止使用集群。

ttp71kqs

ttp71kqs2#

实际上这是我的组配置,密码是一个空字符串。为密码添加了一些字符,现在没有其他示例尝试加入集群。config.getGroupConfig().setName(name).setPassword(password);

相关问题