如何使不同的aws实例中的docker安装Hazelcast节点相互交互?

我有三台机器,我已经安装了三个docker容器,在其上安装了hazelcast-3.5.4(ubuntu)。configuration了awsconfiguration,就像我通常使用Hazelcast(没有docker)那样。节点之间没有发现对方。 如何让他们互动或发现彼此?

Hazelcast.xml文件如下所示:

<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> 

另外,我还添加了两个类似的post中build议的条目,似乎并不适合我。

你需要使用--net=host选项运行你的hazelcast docker镜像。 我使用hazelcast( https://hub.docker.com/r/hazelcast/hazelcast/ )发布的docker映像testing了3.5.4版本,并在aws ec2上使用了两个实例。 我的Docker版本是Docker version 1.9.1, build a34a1d5和ami我在ec2上使用的是Ubuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-fce3c696 ,这里是我的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命令用于自定义configuration文件运行hazelcast图像: docker run --net=host -e JAVA_OPTS="-Dhazelcast.config=/configFolder/hazelcast.xml" -v ~/configFolder:/configFolder -ti hazelcast/hazelcast

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

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