英文:
First hazelcast node is shutting down instead of becoming master
问题
以下是翻译好的内容:
我正在尝试使用tcp/ip发现方式形成一个集群。我无法理解为什么第一个节点没有被选择为主节点。集群中没有其他节点。错误日志不是很明确。
调试日志:
2020-10-27 05:31:46 调试 com.hazelcast.internal.cluster.ClusterService:49 - [192.168.10.31]:5701 [dev] [3.12] 将主地址设置为null
2020-10-27 05:31:46 调试 com.hazelcast.cluster.impl.TcpIpJoiner:49 - [192.168.10.31]:5701 [dev] [3.12] 加入后的主节点:null,isMaster: false
2020-10-27 05:31:46 错误 com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] 无法加入集群。立即关闭!
2020-10-27 05:31:46 信息 com.hazelcast.core.LifecycleService:49 - [192.168.10.31]:5701 [dev] [3.12] [192.168.10.31]:5701 正在关闭
2020-10-27 05:31:46 警告 com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] 强制终止...
2020-10-27 05:31:46 调试 com.hazelcast.internal.cluster.ClusterService:49 - [192.168.10.31]:5701 [dev] [3.12] 将主地址设置为null
2020-10-27 05:31:46 信息 com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] 正在关闭连接管理器...
Hazelcast版本:3.12
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>3.12</version>
</dependency>
Hazelcast配置:
String hazelcastClusterMemberOne = 192.168.10.*
Config config = new Config();
NetworkConfig network = config.getNetworkConfig();
JoinConfig join = network.getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().addMember(hazelcastClusterMemberOne)
.setEnabled(true);
HazelcastInstance hazelcast = Hazelcast.newHazelcastInstance(config);
错误日志:
2020-10-27 05:31:46 [主线程] 错误 com.hazelcast.instance.Node com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] 无法加入集群。立即关闭!
2020-10-27 05:31:46 [主线程] 信息 com.hazelcast.core.LifecycleService com.hazelcast.core.LifecycleService:49 - [192.168.10.31]:5701 [dev] [3.12] [192.168.10.31]:5701 正在关闭
2020-10-27 05:31:46 [主线程] 警告 com.hazelcast.instance.Node com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] 强制终止...
2020-10-27 05:31:46 [主线程] 信息 com.hazelcast.instance.Node com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] 正在关闭连接管理器...
编辑:
这个问题发生在托管在AWS云上的服务器上,但是上述配置在我的本地机器上运行良好。
英文:
I am trying to form a cluster using tcp/ip discovery. I am unable to understand as to why the first node is not being chosen as master. There are no other nodes in the cluster. And the error logs are not self explanatory.
Debug logs :
<pre>
2020-10-27 05:31:46 DEBUG com.hazelcast.internal.cluster.ClusterService:49 - [192.168.10.31]:5701 [dev] [3.12] Setting master address to null
2020-10-27 05:31:46 DEBUG com.hazelcast.cluster.impl.TcpIpJoiner:49 - [192.168.10.31]:5701 [dev] [3.12] PostJoin master: null, isMaster: false
2020-10-27 05:31:46 ERROR com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] Could not join cluster. Shutting down now!
2020-10-27 05:31:46 INFO com.hazelcast.core.LifecycleService:49 - [192.168.10.31]:5701 [dev] [3.12] [192.168.10.31]:5701 is SHUTTING_DOWN
2020-10-27 05:31:46 WARN com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] Terminating forcefully...
2020-10-27 05:31:46 DEBUG com.hazelcast.internal.cluster.ClusterService:49 - [192.168.10.31]:5701 [dev] [3.12] Setting master address to null
2020-10-27 05:31:46 INFO com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] Shutting down connection manager...
</pre>
Hazelcast version : 3.12
<dependency>
<groupId>com.hazelcast</groupId>
<artifactId>hazelcast</artifactId>
<version>3.12</version>
</dependency>
Hazelcast config :
String hazelcastClusterMemberOne = 192.168.10.*
Config config = new Config();
NetworkConfig network = config.getNetworkConfig();
JoinConfig join = network.getJoin();
join.getMulticastConfig().setEnabled(false);
join.getTcpIpConfig().addMember(hazelcastClusterMemberOne)
.setEnabled(true);
HazelcastInstance hazelcast = Hazelcast.newHazelcastInstance(config);
Error Logs :
<pre>
2020-10-27 05:31:46 [main] ERROR com.hazelcast.instance.Node com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] Could not join cluster. Shutting down now!
2020-10-27 05:31:46 [main] INFO com.hazelcast.core.LifecycleService com.hazelcast.core.LifecycleService:49 - [192.168.10.31]:5701 [dev] [3.12] [192.168.10.31]:5701 is SHUTTING_DOWN
2020-10-27 05:31:46 [main] WARN com.hazelcast.instance.Node com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] Terminating forcefully...
2020-10-27 05:31:46 [main] INFO com.hazelcast.instance.Node com.hazelcast.instance.Node:49 - [192.168.10.31]:5701 [dev] [3.12] Shutting down connection manager...
</pre>
EDIT :
This is happening on the server which is hosted on AWS cloud, but the above config works fine on my local machine
答案1
得分: 0
尝试将通配符更改为明确的 IP 地址。
例如:
不是
getTcpIpConfig().addMember("192.168.10.*")
.setEnabled(true);
而是
getTcpIpConfig().addMember("192.168.10.1")
.setEnabled(true);
或者如果您需要多种可能性,请明确列出它们
getTcpIpConfig().addMember("192.168.10.1")
.addMember("192.168.10.2")
.addMember("192.168.10.3")
.setEnabled(true);
以下已更新
TcpIpConfig
并不适用于大范围的可能性。通配符在此字段上未实现。您可以列出所有 256 种可能性,或者提交一个实现通配符的 PR。无论哪种方式,都将有 256 个要探测的端口,这会导致速度较慢。
如果您在运行时知道第一个节点的地址,您可以将其作为属性传递给其他节点。
如果不知道,那么其他发现机制中的一个可能会是更好的选择。
另请注意,TcpIpConfig
仅是发现机制的规范,而不是一旦发现后的通信机制。成员与成员之间通信的性能与发现机制的选择无关。
以下第二次更新
上述回答是不正确的,经过在 3.12.0 版中的尝试,通配符已实现。
英文:
Try changing from a wildcard to an explicit IP address.
Ie.
Not
getTcpIpConfig().addMember("192.168.10.*")
.setEnabled(true);
but
getTcpIpConfig().addMember("192.168.10.1")
.setEnabled(true);
Or if you need several possibilities, list them explicitly
getTcpIpConfig().addMember("192.168.10.1")
.addMember("192.168.10.2")
.addMember("192.168.10.3")
.setEnabled(true);
UPDATED BELOW
TcpIpConfig
wasn't intended for use with a large range of possibilities. Wwildcard is not implemented for this field. You could list all 256 possibilities, or submit a PR implementing wildcard. Either way it's 256 port to probe, which will be on the slow side.
If you know the address of the first node at runtime, you could pass this into the others as a property.
If you don't, then one of the other discovery mechanisms is probably going to be a better choice.
Note also, TcpIpConfig
is just the specification for discovery mechanism, not the communication mechanism once discovered. Performance of member to member communication is unrelated to the choice of discovery mechanism.
UPDATED 2 BELOW
The above answer is incorrect, having now tried it with 3.12.0, wildcard is implemented.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论