当前位置: 首页 > 面试题库 >

如何使安装在docker上不同aws实例上的Hazelcast节点彼此交互?

卫嘉佑
2023-03-14
问题内容

我有三台aws机器,我在上面安装了三个安装了hazelcast-3.5.4的docker容器(ubuntu),设置了aws配置,就像我通常使用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>

另外,根据类似帖子中的建议,我还添加了另外两个条目,该条目似乎对我不起作用。


问题答案:

您需要使用--net=host选项运行hazelcast
docker映像。我测试了由hazelcast(https://hub.docker.com/r/hazelcast/hazelcast/)发布的Docker镜像,版本3.5.4,在AWS
EC2上有两个实例。我的Docker版本是Docker version 1.9.1, build a34a1d5ec2上使用的ami 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命令,用于使用自定义配置文件运行hazelcast映像: docker run --net=host -e JAVA_OPTS="-Dhazelcast.config=/configFolder/hazelcast.xml" -v ~/configFolder:/configFolder -ti hazelcast/hazelcast

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

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



 类似资料:
  • 我在3台裸机Centos7服务器上设置了一个Kubernetes集群,其中有一个主服务器和两个从服务器。为此,我使用了kubeadm,遵循以下指南:https://kubernetes.io/docs/setup/independent/create-cluster-kubeadm/并将Weave Net用于pod网络。 为了进行测试,我设置了2个带有服务的default-http-backend

  • 问题内容: 我需要在Amazon Cloud中安装Redis。我需要它作为我的npm模块kue(部署)的一部分。考虑到我对Linux和管理的优缺点,任何人都可以将我的循序渐进的教程链接或解释如何做。 问题答案: 您可以创建一个运行redis 的Elasticache实例并让AWS为您管理所有实例,而不是启动EC2实例并在那里安装/管理Redis 。 如果您确实想运行自己的Redis服务器,则需要启

  • 我需要在EC2的Amazon ami linux实例上安装JDK15。使用命令我似乎找不到它,任何答案都将不胜感激!

  • 本文向大家介绍在docker上安装运行mysql实例,包括了在docker上安装运行mysql实例的使用技巧和注意事项,需要的朋友参考一下 希望在自己的机器模拟一下公司中微服务的构建,使用docker部署了mysql实例,使用spring boot进行了CRUD(增删改查)操作进行了一下验证,在后面的学习中也可以尝试更多的框架和组件。 ps:实验环境是:ubuntu 14.04, 64位 1.获取

  • 问题内容: 我有一个带有Phalcon3和php 7的Docker容器。我正在尝试安装php扩展名Mcrypt,但不走运。 如果我对容器执行ssh并执行: 我得到以下内容: 有没有办法安装它? 问题答案: 让我们看一下php docker镜像的 官方手册 部分PHP核心扩展 例如,如果您想要一个带有iconv,mcrypt和gd扩展名的PHP- FPM映像,则可以继承您喜欢的基本映像,并编写自己的

  • 问题内容: 我发现一个有4年历史的项目应该在lambda上安装phantomjs,但是我做错了什么,或者自从创建回购以来事情已经发生了变化,并且不再起作用。克隆并部署此存储库时,尝试运行phantomjs时出现此错误: 如果我使用最新的linux二进制文件而不是此仓库附带的二进制文件,则会收到有关另一个.so文件丢失的不同但相似的错误。 对于上下文,我要安装phantomjs的原因是因为我想在我的