如何使Hazelcast节点安装在docker上不同的aws实例互相交互? [英] How to make Hazelcast nodes installed in docker on different aws instances interact with each other?

查看:463
本文介绍了如何使Hazelcast节点安装在docker上不同的aws实例互相交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个aws机器,我已经在其上设置三个docker容器在他们(ubuntu)上安装hazelcast-3.5.4。aws配置设置为我通常使用Hazelcast(没有docker)。节点不发现彼此。如何让他们互动或发现彼此?

I have three aws machines on which I have setup three docker containers having hazelcast-3.5.4 installed on them(ubuntu).With aws configuration set as what I do normally with Hazelcast(without docker).The nodes are not discovering each other. How to make them interact or discover each other?

Hazelcast.xml文件如下所示:

Hazelcast.xml file looks like this:

    <join>
        <multicast enabled="false">
            <multicast-group>224.2.2.3</multicast-group>
            <multicast-port>54327</multicast-port>
        </multicast>
        <tcp-ip enabled="false">
            <interface>127.0.0.1</interface>
            <member-list>
                <member>127.0.0.1</member>
            </member-list>
        </tcp-ip>
        <aws enabled="true">
            <access-key>Some_key</access-key>
            <secret-key>Secret_key</secret-key>
            <!--optional, default is us-east-1 -->
            <region>us-east-1</region>
            <!--optional, default is ec2.amazonaws.com. If set, region shouldn't be set as it will override this property -->
            <host-header>ec2.amazonaws.com</host-header>
            <!-- optional, only instances belonging to this group will be discovered, default will try all running instances -->
            <!--security-group-name>hazelcast-sg</security-group-name-->
            <tag-key>type</tag-key>
            <tag-value>hz-nodes</tag-value>
        </aws>
    </join>

 <public-address>private-ip-of-aws-node</public-address>
<properties>
  <property name="hazelcast.local.localAddress">private-ip-of-aws-node</property>
</properties>

此外,我还添加了两个条目

Also I have added two more entries as suggested in a similar post somewhere which doesn't seem to work for me.

推荐答案

您需要运行您的hazelcast docker镜像 - net = host 选项。我测试了由hazelcast发布的docker图片( https://hub.docker.com/r/hazelcast/hazelcast/)与版本3.5.4与两个实例在aws ec2。我的Docker版本是 Docker版本1.9.1,构建a34a1d5
和ami我使用ec2是 Ubuntu Server 14.04 LTS(HVM) SSD卷类型 - ami-fce3c696 ,这里是我的 hazelcast.xml

You need to run your hazelcast docker image with --net=host option. I tested with docker image published by hazelcast (https://hub.docker.com/r/hazelcast/hazelcast/) with version 3.5.4 with two instances on aws ec2. My Docker version is Docker version 1.9.1, build a34a1d5 and ami I used on ec2 is Ubuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-fce3c696 and here is my hazelcast.xml :

<?xml version="1.0" encoding="UTF-8"?>
<hazelcast xsi:schemaLocation="http://www.hazelcast.com/schema/config hazelcast-config-3.5.xsd"
           xmlns="http://www.hazelcast.com/schema/config"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <group>
        <name>dev</name>
        <password>dev-pass</password>
    </group>
    <management-center enabled="false">http://localhost:8080/mancenter</management-center>
    <network>
        <port auto-increment="true" port-count="100">5701</port>
        <outbound-ports>
            <!--
            Allowed port range when connecting to other nodes.
            0 or * means use system provided port.
            -->
            <ports>0</ports>
        </outbound-ports>
        <join>
            <multicast enabled="false">
                <multicast-group>224.2.2.3</multicast-group>
                <multicast-port>54327</multicast-port>
            </multicast>
            <tcp-ip enabled="false">
                <interface>127.0.0.1</interface>
                <member-list>
                    <member>127.0.0.1</member>
                </member-list>
            </tcp-ip>
            <aws enabled="true">
                <access-key>your-acces-key</access-key>
                <secret-key>your-secret-key</secret-key>
            </aws>
        </join>
        <public-address>private-ip-address-of-ec2-instance</public-address>
    </network>
    <properties>
       <property name="hazelcast.local.localAddress">private-ip-address-of-ec2-instance</property>
   </properties>
</hazelcast>

这是我的docker命令用于运行带有自定义配置文件的hazelcast镜像:
docker run --net = host -e JAVA_OPTS = - Dhazelcast.config = / configFolder / hazelcast.xml-v〜/ configFolder:/ configFolder -ti hazelcast / hazelcast

This is my docker command for running hazelcast image with custom config file : docker run --net=host -e JAVA_OPTS="-Dhazelcast.config=/configFolder/hazelcast.xml" -v ~/configFolder:/configFolder -ti hazelcast/hazelcast

如果 - net = host 选项不起作用,请确保在您的安全组中,hazelcast使用的配置端口打开作为入站端口。您还可以启用调试以查看有关ec2发现发现的节点的更多详细信息。

If --net=host option does not work, make sure that in your security group config ports used by hazelcast are open as inbound ports. Also you can enable debugging to see more details about nodes discovered by ec2 discovery.

请参阅hazelcast ec2发现部分下的调试部分: http://docs.hazelcast.org/docs/latest-dev/manual/html- single / index.html#discovering-members-within-ec2-cloud

Please see Debugging section under hazelcast ec2 discovery section : http://docs.hazelcast.org/docs/latest-dev/manual/html-single/index.html#discovering-members-within-ec2-cloud

这篇关于如何使Hazelcast节点安装在docker上不同的aws实例互相交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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