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 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.
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 isDocker version 1.9.1, build a34a1d5
and ami I used on ec2 isUbuntu Server 14.04 LTS (HVM), SSD Volume Type - ami-fce3c696
and here is myhazelcast.xml
: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
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.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