如何使用BRIDGE网络在Marathon中设置Cassandra Docker集群? [英] How to set up Cassandra Docker cluster in Marathon with BRIDGE network?

查看:122
本文介绍了如何使用BRIDGE网络在Marathon中设置Cassandra Docker集群?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个生产DC/OS(v1.8.4)集群,我正在尝试在其中建立一个Cassandra集群.我使用Marathon(v1.3.0)部署Cassandra节点.我使用的是Cassandra的官方Docker镜像,更具体地说是2.2.3版本.

I have a production DC/OS(v1.8.4) cluster and I am trying to setup a Cassandra cluster inside it. I use Marathon(v1.3.0) to deploy Cassandra nodes. I use the official Docker image of Cassandra and more specifically the 2.2.3 version.

第一种情况:使用HOST模式网络部署Cassandra-一切正常

在这种情况下,我首先部署一个称为cassasndra-seed的节点,并将其连接到IP 10.32.0.6的物理主机.从该服务的Marathon的标准输出日志中,我可以看到节点/10.32.0.6状态跳转到正常状态",并且listen_address和broadcast_address设置为10.32.0.6.如果我在主节点中使用"_cassandra-seed._tcp.marathon.mesos SRV"检查了mesos-dns记录,则可以看到为该服务解析的IP为10.32.0.6.该节点功能齐全,我设法创建一个测试数据库.

In this case, I first deploy a node that I call cassasndra-seed and it attaches to a physical host with IP 10.32.0.6. From the stdout log of Marathon for this service I can see that "Node /10.32.0.6 state jump to normal" and that listen_address and broadcast_address are set to 10.32.0.6. If I check the mesos-dns records using "_cassandra-seed._tcp.marathon.mesos SRV" in a master node I can see that the IP that resolves for this service is 10.32.0.6. The node is fully functional and I manage to create a test database.

{
  "id": "/cassandra-seed",
  "cpus": 1.5,
  "mem": 8192,
  "disk": 0,
  "instances": 1,
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "cassandra:2.2.3",
      "network": "HOST",
      "ports": [7199,7000,7001,9160,9042],
      "requirePorts": true,
      "privileged": true
    }
  },
  "constraints": [ ["hostname","UNIQUE"] ],
  "env": { "CASSANDRA_CLUSTER_NAME": "democluster" }
}

现在,我使用单独的部署添加一个cassandra节点,并提供10.32.0.6作为种子(在部署JSON的env部分中设置"CASSANDRA_SEEDS":"10.32.0.6").新节点获得另一个物理主机的IP(与以前的模式相同),并设法与种子节点进行八卦.因此,我们有了一个运行良好的Cassandra集群.

Now I add one more node of cassandra using a separate deployment and providing 10.32.0.6 as seed (set "CASSANDRA_SEEDS": "10.32.0.6" in the env section of the deployment JSON). The new node gets the IP of another physical host (same pattern as before) and manages to gossip with the seed node. Thus, we have a functioning Cassandra cluster.

{
  "id": "/cassandra",
  "cpus": 1.5,
  "mem": 8192,
  "disk": 0,
  "instances": 1,
  "container": {
    "type": "DOCKER",
    "docker": {
      "image": "cassandra:2.2.3",
      "network": "HOST",
      "ports": [7199,7000,7001,9160,9042],
      "requirePorts": true,
      "privileged": true
    }
  },
  "constraints": [ ["hostname","UNIQUE"] ],
  "env": { 
    "CASSANDRA_CLUSTER_NAME": "democluster",
    "CASSANDRA_SEEDS": "10.32.0.6" 
  }
}

第二种情况:使用BRIDGE模式网络部署Cassandra-休斯顿我们遇到了问题

在这种情况下,我还部署了第一个cassandra-seed节点,并将其附加到IP 10.32.0.6的物理主机上.但是,现在在Marathon中该服务的标准输出日志中,我可以看到节点/172.17.0.2状态跳转到正常状态",并且listen_address和broadcast_address设置为172.17.0.2. 172.17.0.2是Docker容器的IP(使用docker inspect找到).但是,如果在主节点中使用"_cassandra-seed._tcp.marathon.mesos SRV"检查mesos-dns记录,则可以看到为该服务解析的IP为10.32.0.6.该节点功能齐全,我设法创建一个测试数据库.

In this case, I also deploy a first cassandra-seed node and it attaches to a physical host with IP 10.32.0.6. However, now at the stdout log of the service in Marathon I can see that "Node /172.17.0.2 state jump to normal" and that listen_address and broadcast_address are set to 172.17.0.2. 172.17.0.2 is the IP of the docker container (found using docker inspect). However, if I check the mesos-dns records using "_cassandra-seed._tcp.marathon.mesos SRV" in a master node I can see that the IP that resolves for this service is 10.32.0.6. The node is fully functional and I manage to create a test database.

{
  "id": "/cassandra-seed",
  "cpus": 1.5,
  "mem": 8192,
  "disk": 0,
  "instances": 1,
  "container": {
    "type": "DOCKER",
      "docker": {
      "image": "cassandra:2.2.3",
      "network": "BRIDGE",
      "portMappings": [
        {"containerPort": 7000, "hostPort": 7000, "servicePort": 0 },
        {"containerPort": 7001, "hostPort": 7001, "servicePort": 0 },
        {"containerPort": 7199, "hostPort": 7199, "servicePort": 0 },
        {"containerPort": 9042, "hostPort": 9042, "servicePort": 0 },
        {"containerPort": 9160, "hostPort": 9160, "servicePort": 0 },
      ],
      "privileged": true,
    }
  },
  "constraints": [ [ "hostname", "UNIQUE" ] ],
  "env": {"CASSANDRA_CLUSTER_NAME": "democluster"}
}

现在,我使用单独的部署添加了一个cassandra的另一个节点,并提供了10.32.0.6作为种子.新节点连接到另一台主机,并获取其容器的IP(节点/172.17.0.2状态跳转到正常).结果是新节点无法与种子八卦.

Now I add one more node of cassandra using a separate deployment and providing 10.32.0.6 as seed. The new node attaches to another host and gets the IP of his container (Node /172.17.0.2 state jump to normal). The result is that the new node cannot gossip with the seed.

{
  "id": "/cassandra",
  "cpus": 1.5,
  "mem": 8192,
  "disk": 0,
  "instances": 1,
  "container": {
    "type": "DOCKER",
      "docker": {
      "image": "cassandra:2.2.3",
      "network": "BRIDGE",
      "portMappings": [
        {"containerPort": 7000, "hostPort": 7000, "servicePort": 0 },
        {"containerPort": 7001, "hostPort": 7001, "servicePort": 0 },
        {"containerPort": 7199, "hostPort": 7199, "servicePort": 0 },
        {"containerPort": 9042, "hostPort": 9042, "servicePort": 0 },
        {"containerPort": 9160, "hostPort": 9160, "servicePort": 0 },
      ],
      "privileged": true,
    }
  },
  "constraints": [ [ "hostname", "UNIQUE" ] ],
  "env": { 
    "CASSANDRA_CLUSTER_NAME": "democluster",
    "CASSANDRA_SEEDS": "10.32.0.6" 
  }
}

问题是在第二种情况下如何使两个节点成为八卦?为了找到第一个节点,我应提供哪个IP作为种子给第二个节点? 172.17.0.2是docker容器IP,第二个节点无法访问.例如,种子节点中的cassandra实例是否可以像主机网络模式那样获取物理主机的IP?

The question is how could I make the two nodes gossip in the second case? Which is the IP that I should provide as seed to the second node in order to find the first one? The 172.17.0.2 is the docker container IP and cannot be reached by the second node. For example, could cassandra instance in the seed node get the IP of the physical host just like in the host network mode?

提前谢谢!

推荐答案

在settinhs以下以桥接网络模式形成卡桑德拉群集时,应格外小心. 1.设置以下值来托管IP(不是容器ip)

When forming a cassandra cluster in bridge network mode below settinhs should be taken care. 1. Set below values to host Ip (not container ip)

种子:public_ip 广播地址:public_ip Broadcast_rpc_address:public_ip

Seeds : public_ip Broadcast_address : public_ip Broadcast_rpc_address : public_ip

  1. 将listen_address设置为容器Ip

Listen_address:172.17.x.x

Listen_address : 172.17.x.x

3.将rpc_address设置为0.0.0.0(不要使用localhost)

3 . Set rpc_address to 0.0.0.0 (don't use localhost)

通过这种方式,我们实际上可以使用网桥网络形成一个Cassandra集群.

This way we can actually form a Cassandra cluster using bridge network.

尝试一下.确保所需的端口应该可以从外部访问.

Give it a try. Make sure required ports should be accessible from outside world.

这篇关于如何使用BRIDGE网络在Marathon中设置Cassandra Docker集群?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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