使用Docker的AWS上的Hazelcast集群 [英] Hazelcast cluster over AWS using Docker

查看:340
本文介绍了使用Docker的AWS上的Hazelcast集群的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试通过AWS配置hazelcast集群.

Hi am trying to configure hazelcast cluster over AWS.

我正在docker容器中运行hazelcast,并使用--net = host使用主机网络配置.

I am running hazelcast in docker container and using --net=host to use host network config.

当我查看hazelcast日志时,我看到

when i look at hazelcast logs, I see

[172.17.0.1]:5701 [herald] [3.8] Established socket connection between /[node2]:5701 and /[node1]:47357
04:24:22.595 [hz._hzInstance_1_herald.IO.thread-out-0] DEBUG c.h.n.t.SocketWriterInitializerImpl - [172.17.0.1]:5701 [herald] [3.8] Initializing SocketWriter WriteHandler with Cluster Protocol
04:24:22.595 [hz._hzInstance_1_herald.IO.thread-in-0] WARN  c.h.nio.tcp.TcpIpConnectionManager - [172.17.0.1]:5701 [herald] [3.8] Wrong bind request from [172.17.0.1]:5701! This node is not requested endpoint: [node2]:5701
04:24:22.595 [hz._hzInstance_1_herald.IO.thread-in-0] INFO  c.hazelcast.nio.tcp.TcpIpConnection - [172.17.0.1]:5701 [herald] [3.8] Connection[id=40, /[node2]:5701->/[node1]:47357, endpoint=null, alive=false, type=MEMBER] closed. Reason: Wrong bind request from [172.17.0.1]:5701! This node is not requested endpoint: [node2]:5701

我可以看到错误消息,指出绑定请求是从172.17.0.1向node1发出的,而node1不接受此请求.

I can see error saying bind request is coming from 172.17.0.1 to node1, and node1 is not accepting this request.

        final Config config = new Config();
        config.setGroupConfig(clientConfig().getGroupConfig());
        final NetworkConfig networkConfig = new NetworkConfig();
        final JoinConfig joinConfig = new JoinConfig();
        final TcpIpConfig tcpIpConfig = new TcpIpConfig();
        final MulticastConfig multicastConfig = new MulticastConfig();
        multicastConfig.setEnabled(false);
        final AwsConfig awsConfig = new AwsConfig();
        awsConfig.setEnabled(true);
        // awsConfig.setSecurityGroupName("xxxx");
        awsConfig.setRegion("xxxx");
        awsConfig.setIamRole("xxxx");
        awsConfig.setTagKey("type");
        awsConfig.setTagValue("xxxx");
        awsConfig.setConnectionTimeoutSeconds(120);
        joinConfig.setAwsConfig(awsConfig);
        joinConfig.setMulticastConfig(multicastConfig);
        joinConfig.setTcpIpConfig(tcpIpConfig);
        networkConfig.setJoin(joinConfig);
        final InterfacesConfig interfaceConfig = networkConfig.getInterfaces();
        interfaceConfig.setEnabled(true).addInterface("172.29.238.71");
        config.setNetworkConfig(networkConfig);

上面是配置AWSConfig的代码 请帮助我解决此问题.

above is the code to configure AWSConfig Please help me resolve this issue.

谢谢

推荐答案

您正在遇到问题(#11795)在默认的Hazelcast绑定地址选择机制中.

You are experiencing an issue (#11795) in default Hazelcast bind address selection mechanism.

有几种解决方法:

您可以通过提供正确的IP地址作为hazelcast.local.localAddress系统属性来设置绑定地址:

You can set the bind address by providing correct IP address as a hazelcast.local.localAddress system property:

java -Dhazelcast.local.localAddress=[yourCorrectIpGoesHere]

System.setProperty("hazelcast.local.localAddress", "[yourCorrectIpGoesHere]")

阅读系统中的详细信息属性,参见《 Hazelcast参考手册》.

Read details in System properties chapter of Hazelcast Reference Manual.

Hazelcast网络配置允许您指定可用于绑定服务器的IP地址.

Hazelcast Network configuration allows you to specify which IP addresses can be used to bind the server.

hazelcast.xml中的声明:

Declarative in hazelcast.xml:

<hazelcast>
  ...
  <network>
    ...
    <interfaces enabled="true">
      <interface>10.3.16.*</interface> 
      <interface>10.3.10.4-18</interface> 
      <interface>192.168.1.3</interface>         
    </interfaces>    
  </network>
  ...
</hazelcast>

程序化:

Config config = new Config();
NetworkConfig network = config.getNetworkConfig();
InterfacesConfig interfaceConfig = network.getInterfaces();
interfaceConfig.setEnabled(true).addInterface("192.168.1.3");
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(config);

界面部分.

更新: 通过前面的步骤,您可以设置适当的绑定地址-例如ip addr show返回的本地地址.但是,如果您在本地IP和公共IP不同的环境(云,泊坞窗)中运行Hazelcast,这可能是不够的.

Update: With the earlier steps you are able to set a proper bind address - the local one returned by ip addr show for instance. Nevertheless, it could be insufficient if you run Hazelcast in an environment where local IP and public IP differs (clouds, docker).

在群集节点在另一个节点的报告本地地址下看不到彼此的环境中,此步骤是必需的.您必须设置公共地址-这是节点可以访问的地址(可以选择指定端口).

This step is necessary in environments, where cluster nodes doesn't see each other under the reported local address of the other node. You have to set the public address - it's the one which nodes are able to reach (optionally with port specified).

networkConfig.setPublicAddress("172.29.238.71");

// or if a non-default Hazelcast port is used - e.g.9991
networkConfig.setPublicAddress("172.29.238.71:9991");

这篇关于使用Docker的AWS上的Hazelcast集群的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆