AWS Discovery仅尝试3个端口5701,5702& 5703加入集群时

时间:2017-01-12 22:47:13

标签: amazon-web-services docker hazelcast

我有一个内部使用hazelcast的应用程序,并且应用程序作为docker容器部署在AWS中。当我启动docker容器并将主机端口5701/5702/5703映射到每个docker容器内部端口5701(即docker run .............. -p 5701:5701docker run .............. -p 5702:5701docker run .............. -p 5703:5701)时,它工作正常。我也会相应地设置公开地址,例如$DOCKER_HOST:5701$DOCKER_HOST:5702$DOCKER_HOST:5703

但是,当我将容器映射到除这些端口之外的任何其他主机端口时,它就不会加入群集。看起来AWS发现只查找私有实例IP,然后只检查这些私有IP中的5701/5702/5703端口。

有人可以告诉您如何在AWS发现中配置扫描更多端口吗?仅供参考我使用hazelcast-all-3.7.4.jar

使用TCPDiscovery,我们可以指定自动增量和增量计数,但是使用docker自动增量没有意义,因为每个docker容器将是它的隔离运行时,只有一个端口映射/暴露给主机(在Dockerfile EXPOSE 5701中)。

以下是我的示例hazelcast-spring.xml配置文件。

<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xmlns:hz="http://www.hazelcast.com/schema/spring"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
              http://www.hazelcast.com/schema/spring http://www.hazelcast.com/schema/spring/hazelcast-spring.xsd">


    <hz:hazelcast id="sampleHazelcastInstance">
        <hz:config>
            <!-- Hazelcast Instance Name -->
            <hz:instance-name>${sample.hz.instance.name}</hz:instance-name>
            <hz:group name="${sample.hz.group.name}" password="${sample.hz.group.pwd}"/>
            <hz:management-center  enabled="${sample.hz.management.center.enabled:false}" url="${sample.hz.management.center.url:}" update-interval="5"/>

            <hz:properties>
                <hz:property name="hazelcast.shutdownhook.enabled">${sample.hz.shutdownhook.enabled:false}</hz:property>
                <hz:property name="hazelcast.icmp.enabled">${sample.hz.icmp.enabled:true}</hz:property>
                <hz:property name="hazelcast.socket.bind.any">${sample.hz.socket.bind.any:true}</hz:property>
                <hz:property name="hazelcast.socket.server.bind.any">${sample.hz.socket.server.bind.any:true}</hz:property>
                <hz:property name="hazelcast.socket.client.bind.any">${sample.hz.socket.client.bind.any:true}</hz:property>
                <hz:property name="hazelcast.max.no.heartbeat.seconds">${sample.hz.max.no.heartbeat.seconds:30}</hz:property>
                <hz:property name="hazelcast.client.max.no.heartbeat.seconds">${sample.hz.client.max.no.heartbeat.seconds:30}</hz:property>
                <hz:property name="hazelcast.logging.type">${sample.hz.logging.type:slf4j}</hz:property>
                <hz:property name="hazelcast.local.localAddress">${sample.hz.localAddress}</hz:property>
            </hz:properties>

            <hz:network port="${sample.hz.network.port:5701}" port-auto-increment="${sample.hz.network.port.auto.increment:false}" 
                public-address="${sample.hz.publicAddress}">
                <hz:outbound-ports>
                    <hz:ports>0</hz:ports>
                </hz:outbound-ports>
                <hz:join>
                    <hz:multicast enabled="${sample.hz.multicast.enabled:false}" />
                    <hz:tcp-ip connection-timeout-seconds="${sample.hz.tcpip.conn.timeout:30}" enabled="${sample.hz.tcpip.enabled:false}" />
                    <hz:aws enabled="${sample.hz.aws.enabled:true}" 
                        access-key="${sample.hz.aws.access.key}"
                        secret-key="${sample.hz.aws.secret.key}"
                        iam-role="${sample.hz.aws.iam.role}"
                        region="${sample.hz.aws.region:us-east-1}"
                        host-header="${sample.hz.aws.host.header:ec2.amazonaws.com}"
                        security-group-name="${sample.hz.aws.security.group.name}"
                        tag-key="${sample.hz.aws.tag.key}"
                        tag-value="${sample.hz.aws.tag.value}" 
                        connection-timeout-seconds="${sample.hz.aws.conn.timeout:30}" />
                </hz:join>
                <hz:reuse-address>true</hz:reuse-address>
            </hz:network>

            <!-- Hazelcast Distributed Map configuration -->

</beans>

0 个答案:

没有答案