2

我是内存数据网格和 Hazelcast 的新手。我在官方网站上尝试演示应用程序。

https://training.hazelcast.com/demo-getting-started-with-hazelcast-imdg/277088/scorm/f2u8hre5zf9p

它提到在多次运行应用程序时,它应该将成员添加到同一个集群。

但是,在第二次运行该程序时,似乎没有将新成员添加到同一个集群中。

想看看我的设置有没有问题,谢谢。

环境:
Eclipse IDE
JDK 13
hazelcast 3.12.2

第一次运行:

Oct 07, 2019 8:35:55 PM com.hazelcast.instance.HazelcastInstanceFactory
WARNING: Hazelcast is starting in a Java modular environment (Java 9 and newer) but without proper access to required Java packages. Use additional Java arguments to provide Hazelcast access to Java internal API. The internal API access is used to get the best performance results. Arguments to be used:
 --add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
Oct 07, 2019 8:35:55 PM com.hazelcast.instance.AddressPicker
INFO: [LOCAL] [dev] [3.12.2] Prefer IPv4 stack is true, prefer IPv6 addresses is false
Oct 07, 2019 8:35:55 PM com.hazelcast.instance.AddressPicker
INFO: [LOCAL] [dev] [3.12.2] Picked [192.168.0.211]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
Oct 07, 2019 8:35:56 PM com.hazelcast.system
INFO: [192.168.0.211]:5701 [dev] [3.12.2] Hazelcast 3.12.2 (20190802 - e34b163) starting at [192.168.0.211]:5701
Oct 07, 2019 8:35:56 PM com.hazelcast.system
INFO: [192.168.0.211]:5701 [dev] [3.12.2] Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved.
Oct 07, 2019 8:35:56 PM com.hazelcast.spi.impl.operationservice.impl.BackpressureRegulator
INFO: [192.168.0.211]:5701 [dev] [3.12.2] Backpressure is disabled
Oct 07, 2019 8:35:56 PM com.hazelcast.instance.Node
INFO: [192.168.0.211]:5701 [dev] [3.12.2] Creating MulticastJoiner
Oct 07, 2019 8:35:56 PM com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl
INFO: [192.168.0.211]:5701 [dev] [3.12.2] Starting 16 partition threads and 9 generic threads (1 dedicated for priority tasks)
Oct 07, 2019 8:35:56 PM com.hazelcast.internal.diagnostics.Diagnostics
INFO: [192.168.0.211]:5701 [dev] [3.12.2] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
Oct 07, 2019 8:35:56 PM com.hazelcast.core.LifecycleService
INFO: [192.168.0.211]:5701 [dev] [3.12.2] [192.168.0.211]:5701 is STARTING
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.hazelcast.internal.networking.nio.SelectorOptimizer (file:/Users/patrick/.m2/repository/com/hazelcast/hazelcast/3.12.2/hazelcast-3.12.2.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of com.hazelcast.internal.networking.nio.SelectorOptimizer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Oct 07, 2019 8:35:58 PM com.hazelcast.internal.cluster.ClusterService
INFO: [192.168.0.211]:5701 [dev] [3.12.2] 

Members {size:1, ver:1} [
    Member [192.168.0.211]:5701 - 5d8492ad-df09-46fc-8420-5d00784204d9 this
]

Oct 07, 2019 8:35:58 PM com.hazelcast.core.LifecycleService
INFO: [192.168.0.211]:5701 [dev] [3.12.2] [192.168.0.211]:5701 is STARTED
Oct 07, 2019 8:35:58 PM com.hazelcast.internal.partition.impl.PartitionStateManager
INFO: [192.168.0.211]:5701 [dev] [3.12.2] Initializing cluster partition table arrangement...
Customer with key 1: Joe
Map Size: 3
First customer: Tom
Second Customer: Mary
Queue size: 2

第二次运行:

Oct 07, 2019 8:39:31 PM com.hazelcast.instance.HazelcastInstanceFactory
WARNING: Hazelcast is starting in a Java modular environment (Java 9 and newer) but without proper access to required Java packages. Use additional Java arguments to provide Hazelcast access to Java internal API. The internal API access is used to get the best performance results. Arguments to be used:
 --add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
Oct 07, 2019 8:39:31 PM com.hazelcast.instance.AddressPicker
INFO: [LOCAL] [dev] [3.12.2] Prefer IPv4 stack is true, prefer IPv6 addresses is false
Oct 07, 2019 8:39:31 PM com.hazelcast.instance.AddressPicker
INFO: [LOCAL] [dev] [3.12.2] Picked [192.168.0.211]:5702, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5702], bind any local is true
Oct 07, 2019 8:39:31 PM com.hazelcast.system
INFO: [192.168.0.211]:5702 [dev] [3.12.2] Hazelcast 3.12.2 (20190802 - e34b163) starting at [192.168.0.211]:5702
Oct 07, 2019 8:39:31 PM com.hazelcast.system
INFO: [192.168.0.211]:5702 [dev] [3.12.2] Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved.
Oct 07, 2019 8:39:31 PM com.hazelcast.spi.impl.operationservice.impl.BackpressureRegulator
INFO: [192.168.0.211]:5702 [dev] [3.12.2] Backpressure is disabled
Oct 07, 2019 8:39:32 PM com.hazelcast.instance.Node
INFO: [192.168.0.211]:5702 [dev] [3.12.2] Creating MulticastJoiner
Oct 07, 2019 8:39:32 PM com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl
INFO: [192.168.0.211]:5702 [dev] [3.12.2] Starting 16 partition threads and 9 generic threads (1 dedicated for priority tasks)
Oct 07, 2019 8:39:32 PM com.hazelcast.internal.diagnostics.Diagnostics
INFO: [192.168.0.211]:5702 [dev] [3.12.2] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
Oct 07, 2019 8:39:32 PM com.hazelcast.core.LifecycleService
INFO: [192.168.0.211]:5702 [dev] [3.12.2] [192.168.0.211]:5702 is STARTING
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.hazelcast.internal.networking.nio.SelectorOptimizer (file:/Users/patrick/.m2/repository/com/hazelcast/hazelcast/3.12.2/hazelcast-3.12.2.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of com.hazelcast.internal.networking.nio.SelectorOptimizer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Oct 07, 2019 8:39:34 PM com.hazelcast.internal.cluster.ClusterService
INFO: [192.168.0.211]:5702 [dev] [3.12.2] 

Members {size:1, ver:1} [
    Member [192.168.0.211]:5702 - 10c3d969-f060-4253-8260-5cfc3be87e0f this
]

Oct 07, 2019 8:39:34 PM com.hazelcast.instance.Node
WARNING: [192.168.0.211]:5702 [dev] [3.12.2] Config seed port is 5701 and cluster size is 1. Some of the ports seem occupied!
Oct 07, 2019 8:39:34 PM com.hazelcast.core.LifecycleService
INFO: [192.168.0.211]:5702 [dev] [3.12.2] [192.168.0.211]:5702 is STARTED
Oct 07, 2019 8:39:34 PM com.hazelcast.internal.partition.impl.PartitionStateManager
INFO: [192.168.0.211]:5702 [dev] [3.12.2] Initializing cluster partition table arrangement...
Customer with key 1: Joe
Map Size: 3
First customer: Tom
Second Customer: Mary
Queue size: 2



4

4 回答 4

1

确保在 JVM 中指定了所需的选项:

--add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
于 2020-09-24T20:19:29.713 回答
0

我知道这是一个老问题,但我刚开始玩 Hazelcast,在 IntelliJ 和那个演示中遇到了同样的问题。我解决它的方法是不在本地机器上使用多播,而是通过环回适配器使用 tcp/ip,所以我将前几行更改为:

    Config cfg = new Config();
    final TcpIpConfig tcpIpConfig = cfg.getNetworkConfig().getJoin().getTcpIpConfig();
    tcpIpConfig.setEnabled(true);
    tcpIpConfig.setMembers(List.of("127.0.0.1"));

在那次改变并开始2次跑步之后,我得到了

Members {size:2, ver:2} [
    Member [127.0.0.1]:5701 - f5e2f023-4bb1-4d8f-b21d-fae2458fe79d
    Member [127.0.0.1]:5702 - f8a7618d-8682-4c86-8ca9-c6800570c427 this
]
于 2021-05-14T04:25:20.453 回答
0

(2019 年 10 月 8 日更新)

不太确定发生了什么,但我能够在升级到 MacOS Catalina 后得到预期的输出。不确定它是否与操作系统有关。

在此处输入图像描述

Oct 08, 2019 4:42:20 PM com.hazelcast.instance.HazelcastInstanceFactory
WARNING: Hazelcast is starting in a Java modular environment (Java 9 and newer) but without proper access to required Java packages. Use additional Java arguments to provide Hazelcast access to Java internal API. The internal API access is used to get the best performance results. Arguments to be used:
 --add-modules java.se --add-exports java.base/jdk.internal.ref=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/sun.nio.ch=ALL-UNNAMED --add-opens java.management/sun.management=ALL-UNNAMED --add-opens jdk.management/com.sun.management.internal=ALL-UNNAMED
Oct 08, 2019 4:42:20 PM com.hazelcast.instance.AddressPicker
INFO: [LOCAL] [dev] [3.12.2] Prefer IPv4 stack is true, prefer IPv6 addresses is false
Oct 08, 2019 4:42:20 PM com.hazelcast.instance.AddressPicker
INFO: [LOCAL] [dev] [3.12.2] Picked [192.168.0.247]:5701, using socket ServerSocket[addr=/0:0:0:0:0:0:0:0,localport=5701], bind any local is true
Oct 08, 2019 4:42:21 PM com.hazelcast.system
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Hazelcast 3.12.2 (20190802 - e34b163) starting at [192.168.0.247]:5701
Oct 08, 2019 4:42:21 PM com.hazelcast.system
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Copyright (c) 2008-2019, Hazelcast, Inc. All Rights Reserved.
Oct 08, 2019 4:42:21 PM com.hazelcast.spi.impl.operationservice.impl.BackpressureRegulator
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Backpressure is disabled
Oct 08, 2019 4:42:21 PM com.hazelcast.instance.Node
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Creating MulticastJoiner
Oct 08, 2019 4:42:21 PM com.hazelcast.spi.impl.operationexecutor.impl.OperationExecutorImpl
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Starting 16 partition threads and 9 generic threads (1 dedicated for priority tasks)
Oct 08, 2019 4:42:21 PM com.hazelcast.internal.diagnostics.Diagnostics
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Diagnostics disabled. To enable add -Dhazelcast.diagnostics.enabled=true to the JVM arguments.
Oct 08, 2019 4:42:21 PM com.hazelcast.core.LifecycleService
INFO: [192.168.0.247]:5701 [dev] [3.12.2] [192.168.0.247]:5701 is STARTING
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by com.hazelcast.internal.networking.nio.SelectorOptimizer (file:/Users/patrick/.m2/repository/com/hazelcast/hazelcast/3.12.2/hazelcast-3.12.2.jar) to field sun.nio.ch.SelectorImpl.selectedKeys
WARNING: Please consider reporting this to the maintainers of com.hazelcast.internal.networking.nio.SelectorOptimizer
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
Oct 08, 2019 4:42:24 PM com.hazelcast.internal.cluster.ClusterService
INFO: [192.168.0.247]:5701 [dev] [3.12.2] 

Members {size:1, ver:1} [
    Member [192.168.0.247]:5701 - 1d3f21e8-0294-434a-84c2-cbf128286987 this
]

Oct 08, 2019 4:42:24 PM com.hazelcast.core.LifecycleService
INFO: [192.168.0.247]:5701 [dev] [3.12.2] [192.168.0.247]:5701 is STARTED
Oct 08, 2019 4:42:24 PM com.hazelcast.internal.partition.impl.PartitionStateManager
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Initializing cluster partition table arrangement...
Customer with key 1: Joe
Map Size: 3
First customer: Tom
Second Customer: Mary
Queue size: 2
Oct 08, 2019 4:42:31 PM com.hazelcast.nio.tcp.TcpIpConnection
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Initialized new cluster connection between /192.168.0.247:5701 and /192.168.0.247:49798
Oct 08, 2019 4:42:37 PM com.hazelcast.internal.cluster.ClusterService
INFO: [192.168.0.247]:5701 [dev] [3.12.2] 

Members {size:2, ver:2} [
    Member [192.168.0.247]:5701 - 1d3f21e8-0294-434a-84c2-cbf128286987 this
    Member [192.168.0.247]:5702 - ccc3af03-5783-4808-b2c1-c709ea94f562
]

Oct 08, 2019 4:42:37 PM com.hazelcast.internal.partition.impl.MigrationManager
INFO: [192.168.0.247]:5701 [dev] [3.12.2] Re-partitioning cluster data... Migration queue size: 271
Oct 08, 2019 4:42:39 PM com.hazelcast.internal.partition.impl.MigrationThread
INFO: [192.168.0.247]:5701 [dev] [3.12.2] All migration tasks have been completed. (lastRepartitionTime=Tue Oct 08 16:42:37 HKT 2019, completedMigrations=271, totalCompletedMigrations=271, elapsedMigrationTime=602ms, totalElapsedMigrationTime=602ms)
于 2019-10-08T08:48:32.603 回答
0

您是否在本地环境中安装了虚拟化软件?hazelcast 的默认多播地址可能存在冲突。尝试将地址更改为:224.0.0.1:

cfg.getNetworkConfig().getJoin().getMulticastConfig().setMulticastGroup("224.0.0.1");

于 2019-10-07T18:02:33.783 回答